|
53 | 53 | echo "source-changed=false" >> "$GITHUB_OUTPUT" |
54 | 54 | fi |
55 | 55 |
|
| 56 | + blocks-integrity: |
| 57 | + name: Blocks Package Integrity |
| 58 | + runs-on: ubuntu-latest |
| 59 | + timeout-minutes: 10 |
| 60 | + steps: |
| 61 | + - uses: actions/checkout@v5 |
| 62 | + with: |
| 63 | + ref: ${{ github.event.pull_request.head.sha }} |
| 64 | + persist-credentials: false |
| 65 | + fetch-depth: 0 |
| 66 | + |
| 67 | + - uses: actions/setup-node@v5 |
| 68 | + with: |
| 69 | + node-version-file: '.nvmrc' |
| 70 | + cache: npm |
| 71 | + |
| 72 | + - run: npm ci |
| 73 | + |
| 74 | + - name: Sync block docs (prebuild step) |
| 75 | + run: node scripts/sync-block-docs.mjs |
| 76 | + |
| 77 | + - name: Check blocks package integrity |
| 78 | + run: | |
| 79 | + cd packages/blocks |
| 80 | +
|
| 81 | + # Pack the local package to get its shasum |
| 82 | + LOCAL_TARBALL=$(npm pack --pack-destination /tmp 2>/dev/null) |
| 83 | + LOCAL_INTEGRITY=$(shasum -a 512 "/tmp/$LOCAL_TARBALL" | awk '{print $1}') |
| 84 | +
|
| 85 | + # Get the current published version |
| 86 | + VERSION=$(node -p "require('./package.json').version") |
| 87 | +
|
| 88 | + # Fetch the published integrity hash — if the version isn't published yet, skip |
| 89 | + PUBLISHED_INTEGRITY=$(npm view "@aws-blocks/blocks@$VERSION" dist.shasum 2>/dev/null || echo "") |
| 90 | +
|
| 91 | + if [ -z "$PUBLISHED_INTEGRITY" ]; then |
| 92 | + echo "✅ Version $VERSION is not yet published on npm — nothing to compare." |
| 93 | + exit 0 |
| 94 | + fi |
| 95 | +
|
| 96 | + echo "Local shasum: $LOCAL_INTEGRITY" |
| 97 | + echo "Published shasum: $PUBLISHED_INTEGRITY" |
| 98 | +
|
| 99 | + if [ "$LOCAL_INTEGRITY" = "$PUBLISHED_INTEGRITY" ]; then |
| 100 | + echo "✅ Package content matches the published version." |
| 101 | + exit 0 |
| 102 | + fi |
| 103 | +
|
| 104 | + # Content differs — check if a changeset already bumps @aws-blocks/blocks |
| 105 | + cd "$GITHUB_WORKSPACE" |
| 106 | + CHANGESET_BUMPS=$(find .changeset -name '*.md' ! -name 'README.md' -exec grep -l '"@aws-blocks/blocks"' {} \;) |
| 107 | +
|
| 108 | + if [ -n "$CHANGESET_BUMPS" ]; then |
| 109 | + echo "✅ Package content changed but a changeset already bumps @aws-blocks/blocks:" |
| 110 | + echo "$CHANGESET_BUMPS" |
| 111 | + exit 0 |
| 112 | + fi |
| 113 | +
|
| 114 | + echo "❌ The @aws-blocks/blocks package content has changed (synced docs from sibling packages), but no changeset bumps it. Add \"@aws-blocks/blocks\": patch to your changeset file." |
| 115 | + exit 1 |
| 116 | +
|
56 | 117 | build-and-test-local: |
57 | 118 | name: Build, Unit Tests, E2E Local |
58 | 119 | runs-on: ubuntu-latest |
@@ -401,12 +462,17 @@ jobs: |
401 | 462 | # (e2e-amplify-interop.yml) so their failures don't show red here. |
402 | 463 | build-and-test: |
403 | 464 | name: Build and Test |
404 | | - needs: [build-and-test-local, e2e-templates, e2e-sandbox, e2e-sandbox-vpc, e2e-production, e2e-supabase, e2e-hosting] |
| 465 | + needs: [blocks-integrity, build-and-test-local, e2e-templates, e2e-sandbox, e2e-sandbox-vpc, e2e-production, e2e-supabase, e2e-hosting] |
405 | 466 | runs-on: ubuntu-latest |
406 | 467 | if: always() |
407 | 468 | steps: |
408 | 469 | - name: Check results |
409 | 470 | run: | |
| 471 | + if [[ "${{ needs.blocks-integrity.result }}" != "success" ]]; then |
| 472 | + echo "blocks-integrity failed" |
| 473 | + exit 1 |
| 474 | + fi |
| 475 | +
|
410 | 476 | if [[ "${{ needs.build-and-test-local.result }}" != "success" ]]; then |
411 | 477 | echo "build-and-test-local failed" |
412 | 478 | exit 1 |
|
0 commit comments