From 8efd91412279d8e74171f97763539ab1b94f80eb Mon Sep 17 00:00:00 2001 From: yanyihan Date: Wed, 24 Jun 2026 12:53:47 +0800 Subject: [PATCH] ci: split tests into 4 shards with fail-fast disabled - Split unit tests into 4 parallel shards using bun test --shard - Set fail-fast: false so all shards complete even if one fails - Run tests directly in packages/opencode via test:ci script with JUnit reporter - Upload JUnit XML artifact per shard - Simplify setup-bun action: remove baseline URL, setuptools, Windows hoisted - Bump actions: checkout@v6, cache@v5, upload-artifact@v7 - turbo.json: only keep typecheck (remove build + cli/app test tasks) - Bump bun to 1.3.14 via packageManager --- .github/actions/setup-bun/action.yml | 42 +++------------------------- .github/workflows/lint.yml | 2 +- .github/workflows/test.yml | 28 +++++++++++-------- .github/workflows/typecheck.yml | 2 +- package.json | 2 +- turbo.json | 25 +---------------- 6 files changed, 24 insertions(+), 77 deletions(-) diff --git a/.github/actions/setup-bun/action.yml b/.github/actions/setup-bun/action.yml index d1e3bfc25..4b5e11d57 100644 --- a/.github/actions/setup-bun/action.yml +++ b/.github/actions/setup-bun/action.yml @@ -1,53 +1,19 @@ name: "Setup Bun" -description: "Setup Bun with caching and install dependencies" +description: "Setup Bun, cache dependencies, and install" runs: using: "composite" steps: - - name: Get baseline download URL - id: bun-url - shell: bash - run: | - if [ "$RUNNER_ARCH" = "X64" ]; then - V=$(node -p "require('./package.json').packageManager.split('@')[1]") - case "$RUNNER_OS" in - macOS) OS=darwin ;; - Linux) OS=linux ;; - Windows) OS=windows ;; - esac - echo "url=https://github.com/oven-sh/bun/releases/download/bun-v${V}/bun-${OS}-x64-baseline.zip" >> "$GITHUB_OUTPUT" - fi - - name: Setup Bun uses: oven-sh/setup-bun@v2 - with: - bun-version-file: ${{ !steps.bun-url.outputs.url && 'package.json' || '' }} - bun-download-url: ${{ steps.bun-url.outputs.url }} - - - name: Get cache directory - id: cache - shell: bash - run: echo "dir=$(bun pm cache)" >> "$GITHUB_OUTPUT" - name: Cache Bun dependencies - uses: actions/cache@v4 + uses: actions/cache@v5 with: - path: ${{ steps.cache.outputs.dir }} + path: ~/.bun/install/cache key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock') }} restore-keys: | ${{ runner.os }}-bun- - - name: Install setuptools for distutils compatibility - run: python3 -m pip install setuptools || pip install setuptools || true - shell: bash - - name: Install dependencies - run: | - # Workaround for patched peer variants - # e.g. ./patches/ for standard-openapi - # https://github.com/oven-sh/bun/issues/28147 - if [ "$RUNNER_OS" = "Windows" ]; then - bun install --linker hoisted - else - bun install - fi + run: bun install shell: bash diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 6a1291d49..e68c4803c 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Setup Bun uses: ./.github/actions/setup-bun diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d3d33498d..c601b0d60 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,9 +17,14 @@ permissions: jobs: unit: runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + shard: ["1/4", "2/4", "3/4", "4/4"] + name: unit (shard ${{ matrix.shard }}) steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Setup Bun uses: ./.github/actions/setup-bun @@ -29,15 +34,14 @@ jobs: git config --global user.email "ci@mimo.ai" git config --global user.name "mimo-ci" - - name: Cache Turbo - uses: actions/cache@v4 + - name: Run unit tests (shard ${{ matrix.shard }}) + timeout-minutes: 8 + working-directory: packages/opencode + run: bun run test:ci --shard ${{ matrix.shard }} + + - name: Upload JUnit + if: always() + uses: actions/upload-artifact@v7 with: - path: node_modules/.cache/turbo - key: turbo-${{ runner.os }}-${{ hashFiles('turbo.json', '**/package.json') }}-${{ github.sha }} - restore-keys: | - turbo-${{ runner.os }}-${{ hashFiles('turbo.json', '**/package.json') }}- - turbo-${{ runner.os }}- - - - name: Run unit tests - timeout-minutes: 20 - run: bun turbo test --output-logs=errors-only --log-order=grouped --log-prefix=task + name: junit-shard-${{ strategy.job-index }} + path: packages/opencode/.artifacts/unit/junit.xml diff --git a/.github/workflows/typecheck.yml b/.github/workflows/typecheck.yml index d99646c49..903ca0eba 100644 --- a/.github/workflows/typecheck.yml +++ b/.github/workflows/typecheck.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Setup Bun uses: ./.github/actions/setup-bun diff --git a/package.json b/package.json index 3e14abee2..1176a1743 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "AI-powered development tool", "private": true, "type": "module", - "packageManager": "bun@1.3.11", + "packageManager": "bun@1.3.14", "scripts": { "dev": "bun run --cwd packages/opencode script/dev.ts", "dev:desktop": "bun --cwd packages/desktop dev", diff --git a/turbo.json b/turbo.json index b8c75e581..2dde014cf 100644 --- a/turbo.json +++ b/turbo.json @@ -3,29 +3,6 @@ "globalEnv": ["CI", "OPENCODE_DISABLE_SHARE"], "globalPassThroughEnv": ["CI", "OPENCODE_DISABLE_SHARE"], "tasks": { - "typecheck": {}, - "build": { - "dependsOn": [], - "outputs": ["dist/**"] - }, - "@mimo-ai/cli#test": { - "dependsOn": ["^build"], - "outputs": [], - "passThroughEnv": ["*"] - }, - "@mimo-ai/cli#test:ci": { - "dependsOn": ["^build"], - "outputs": [".artifacts/unit/junit.xml"], - "passThroughEnv": ["*"] - }, - "@mimo-ai/app#test": { - "dependsOn": ["^build"], - "outputs": [] - }, - "@mimo-ai/app#test:ci": { - "dependsOn": ["^build"], - "outputs": [".artifacts/unit/junit.xml"], - "passThroughEnv": ["*"] - } + "typecheck": {} } }