diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index d3df1317..48269846 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -13,6 +13,8 @@ jobs: policy: runs-on: ubuntu-latest timeout-minutes: 5 + outputs: + lockfile_regenerated: ${{ steps.regen_lockfile.outputs.regenerated }} steps: - name: Checkout repository @@ -63,13 +65,30 @@ jobs: node ./scripts/check-release-package-bootstrap.mjs "${changed_paths[@]}" - name: Validate dependency resolution when manifests change + id: regen_lockfile run: | changed="$(git diff --name-only "${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }}")" manifest_pattern='(^|/)package\.json$|^pnpm-workspace\.yaml$|^\.npmrc$|^pnpmfile\.(cjs|js|mjs)$' if printf '%s\n' "$changed" | grep -Eq "$manifest_pattern"; then pnpm install --lockfile-only --ignore-scripts --no-frozen-lockfile + echo "regenerated=1" >> "$GITHUB_OUTPUT" + else + echo "regenerated=0" >> "$GITHUB_OUTPUT" fi + # Manifest-only PRs (where pnpm-lock.yaml stays at base because the policy + # job above blocks committing it) need the regenerated lockfile for the + # downstream `pnpm install --frozen-lockfile` steps. Upload it here so + # every job consumes the same hash without recomputing. + - name: Upload regenerated lockfile for downstream jobs + if: steps.regen_lockfile.outputs.regenerated == '1' + uses: actions/upload-artifact@v4 + with: + name: pr-lockfile + path: pnpm-lock.yaml + retention-days: 1 + if-no-files-found: error + typecheck_release_registry: name: Typecheck + Release Registry needs: [policy] @@ -85,6 +104,13 @@ jobs: with: version: 9.15.4 + - name: Restore regenerated PR lockfile (if policy uploaded one) + uses: actions/download-artifact@v4 + continue-on-error: true + with: + name: pr-lockfile + path: . + - name: Setup Node.js uses: actions/setup-node@v6 with: @@ -125,6 +151,13 @@ jobs: with: version: 9.15.4 + - name: Restore regenerated PR lockfile (if policy uploaded one) + uses: actions/download-artifact@v4 + continue-on-error: true + with: + name: pr-lockfile + path: . + - name: Setup Node.js uses: actions/setup-node@v6 with: @@ -171,6 +204,13 @@ jobs: with: version: 9.15.4 + - name: Restore regenerated PR lockfile (if policy uploaded one) + uses: actions/download-artifact@v4 + continue-on-error: true + with: + name: pr-lockfile + path: . + - name: Setup Node.js uses: actions/setup-node@v6 with: @@ -214,6 +254,13 @@ jobs: with: version: 9.15.4 + - name: Restore regenerated PR lockfile (if policy uploaded one) + uses: actions/download-artifact@v4 + continue-on-error: true + with: + name: pr-lockfile + path: . + - name: Setup Node.js uses: actions/setup-node@v6 with: @@ -241,6 +288,13 @@ jobs: with: version: 9.15.4 + - name: Restore regenerated PR lockfile (if policy uploaded one) + uses: actions/download-artifact@v4 + continue-on-error: true + with: + name: pr-lockfile + path: . + - name: Setup Node.js uses: actions/setup-node@v6 with: @@ -251,11 +305,20 @@ jobs: run: pnpm install --frozen-lockfile # `release.sh` always executes its Step 2/7 workspace build, even when - # `--skip-verify` bypasses the initial verification gate. + # `--skip-verify` bypasses the initial verification gate. release.sh + # also requires a clean working tree, so any in-place lockfile churn + # from `pnpm install --frozen-lockfile` must be reverted first — unless + # the policy job uploaded a regenerated lockfile (manifest-only PRs), + # in which case we keep the artifact-restored copy so the workspace + # build sees a lockfile that matches the manifest. - name: Release canary dry run via release.sh internal build + env: + USED_ARTIFACT_LOCKFILE: ${{ needs.policy.outputs.lockfile_regenerated || '0' }} run: | git checkout -B master HEAD - git checkout -- pnpm-lock.yaml + if [ "$USED_ARTIFACT_LOCKFILE" != "1" ]; then + git checkout -- pnpm-lock.yaml + fi ./scripts/release.sh canary --skip-verify --dry-run e2e: @@ -272,6 +335,13 @@ jobs: with: version: 9.15.4 + - name: Restore regenerated PR lockfile (if policy uploaded one) + uses: actions/download-artifact@v4 + continue-on-error: true + with: + name: pr-lockfile + path: . + - name: Setup Node.js uses: actions/setup-node@v6 with: