diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cbdea73..84813ea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,20 +7,7 @@ on: branches: [main] jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - - uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 - with: - node-version: 24 - cache: npm - - - run: npm ci - - - name: Type check - run: npx tsc --noEmit - - - name: Build - run: npm run build + test: + # Install + typecheck + build come from the reusable workflow so + # ci.yml and publish.yml can't drift apart. + uses: ./.github/workflows/test.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 31f73a4..a3dbef5 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -9,7 +9,13 @@ permissions: contents: write jobs: + test: + # Install + typecheck + build come from the reusable workflow. + # Same source as ci.yml so the two gates can't drift apart. + uses: ./.github/workflows/test.yml + publish: + needs: test runs-on: ubuntu-latest steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 @@ -24,9 +30,6 @@ jobs: - run: npm ci - - name: Type check - run: npx tsc --noEmit - - name: Build run: npm run build diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..5baf6fd --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,27 @@ +name: Test + +# Reusable workflow called by ci.yml (PR gate) and publish.yml (tag gate). +# Single source of truth for install + typecheck + build. If a tool version +# or script name changes, update this file only — both callers pick it up. + +on: + workflow_call: + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + + - uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 + with: + node-version: 24 + cache: npm + + - run: npm ci + + - name: Type check + run: npx tsc --noEmit + + - name: Build + run: npm run build