ci: split test workflow across shards

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
YeonGyu-Kim
2026-05-15 11:41:35 +09:00
parent 53de295b21
commit fdd40815ba
2 changed files with 71 additions and 12 deletions
+53 -5
View File
@@ -32,7 +32,34 @@ jobs:
echo "PR targets '${BASE_REF}' branch - OK" echo "PR targets '${BASE_REF}' branch - OK"
fi fi
test: test-isolated:
name: Isolated tests (${{ matrix.shard }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
shard: [0, 1, 2, 3]
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
with:
bun-version: "1.3.12"
- uses: actions/cache@v4
with:
path: ~/.bun/install/cache
key: ${{ runner.os }}-bun-1.3.12-${{ hashFiles('bun.lock') }}
- name: Install dependencies
run: bun install --frozen-lockfile
env:
BUN_INSTALL_ALLOW_SCRIPTS: "@ast-grep/napi"
- name: Run isolated tests
run: bun run script/run-ci-tests.ts --phase=isolated --shard-count=4 --shard-index=${{ matrix.shard }}
test-shared:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
@@ -41,16 +68,24 @@ jobs:
with: with:
bun-version: "1.3.12" bun-version: "1.3.12"
- uses: actions/cache@v4
with:
path: ~/.bun/install/cache
key: ${{ runner.os }}-bun-1.3.12-${{ hashFiles('bun.lock') }}
- name: Install dependencies - name: Install dependencies
run: bun install --frozen-lockfile run: bun install --frozen-lockfile
env: env:
BUN_INSTALL_ALLOW_SCRIPTS: "@ast-grep/napi" BUN_INSTALL_ALLOW_SCRIPTS: "@ast-grep/napi"
- name: Build plugin - name: Run shared tests
run: bun run build run: bun run script/run-ci-tests.ts --phase=shared
- name: Run tests test:
run: bun run script/run-ci-tests.ts runs-on: ubuntu-latest
needs: [test-isolated, test-shared]
steps:
- run: echo "All test shards passed"
typecheck: typecheck:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@@ -61,6 +96,11 @@ jobs:
with: with:
bun-version: "1.3.12" bun-version: "1.3.12"
- uses: actions/cache@v4
with:
path: ~/.bun/install/cache
key: ${{ runner.os }}-bun-1.3.12-${{ hashFiles('bun.lock') }}
- name: Install dependencies - name: Install dependencies
run: bun install --frozen-lockfile run: bun install --frozen-lockfile
env: env:
@@ -86,6 +126,11 @@ jobs:
with: with:
bun-version: "1.3.12" bun-version: "1.3.12"
- uses: actions/cache@v4
with:
path: ~/.bun/install/cache
key: ${{ runner.os }}-bun-1.3.12-${{ hashFiles('bun.lock') }}
- name: Install dependencies - name: Install dependencies
run: bun install --frozen-lockfile run: bun install --frozen-lockfile
env: env:
@@ -99,6 +144,9 @@ jobs:
test -f dist/index.js || (echo "ERROR: dist/index.js not found!" && exit 1) test -f dist/index.js || (echo "ERROR: dist/index.js not found!" && exit 1)
test -f dist/index.d.ts || (echo "ERROR: dist/index.d.ts not found!" && exit 1) test -f dist/index.d.ts || (echo "ERROR: dist/index.d.ts not found!" && exit 1)
- name: Verify dist bundle tests
run: bun test src/shared/dist-bundle-bun-globals.test.ts
- name: Auto-commit schema changes - name: Auto-commit schema changes
if: github.event_name == 'push' && github.ref == 'refs/heads/master' if: github.event_name == 'push' && github.ref == 'refs/heads/master'
run: | run: |
+18 -7
View File
@@ -3,19 +3,30 @@
import { describe, expect, test } from "bun:test" import { describe, expect, test } from "bun:test"
import { readFileSync } from "node:fs" import { readFileSync } from "node:fs"
const workflowPaths = [ const workflowChecks = [
new URL("../.github/workflows/ci.yml", import.meta.url), {
new URL("../.github/workflows/publish.yml", import.meta.url), path: new URL("../.github/workflows/ci.yml", import.meta.url),
testRuns: [
"run: bun run script/run-ci-tests.ts --phase=isolated --shard-count=4 --shard-index=${{ matrix.shard }}",
"run: bun run script/run-ci-tests.ts --phase=shared",
"run: bun test src/shared/dist-bundle-bun-globals.test.ts",
],
},
{
path: new URL("../.github/workflows/publish.yml", import.meta.url),
testRuns: ["run: bun run script/run-ci-tests.ts"],
},
] ]
describe("test workflows", () => { describe("test workflows", () => {
test("use pure bun test for workflows", () => { test("use pure bun test for workflows", () => {
for (const workflowPath of workflowPaths) { for (const workflowCheck of workflowChecks) {
// #given // #given
const workflow = readFileSync(workflowPath, "utf8") const workflow = readFileSync(workflowCheck.path, "utf8")
expect(workflow).toContain("- name: Run tests") for (const testRun of workflowCheck.testRuns) {
expect(workflow).toMatch(/run: bun (test|run script\/run-ci-tests\.ts)/) expect(workflow).toContain(testRun)
}
} }
}) })
}) })