Skip to content

Commit 8de7091

Browse files
authored
fix: add publish integrity check for @aws-blocks/blocks docs sync (#186)
1 parent 5491cae commit 8de7091

2 files changed

Lines changed: 72 additions & 1 deletion

File tree

.changeset/blocks-docs-sync.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@aws-blocks/blocks": patch
3+
---
4+
5+
Include synced building block documentation updates.

.github/workflows/pr-checks.yml

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,67 @@ jobs:
5353
echo "source-changed=false" >> "$GITHUB_OUTPUT"
5454
fi
5555
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+
56117
build-and-test-local:
57118
name: Build, Unit Tests, E2E Local
58119
runs-on: ubuntu-latest
@@ -401,12 +462,17 @@ jobs:
401462
# (e2e-amplify-interop.yml) so their failures don't show red here.
402463
build-and-test:
403464
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]
405466
runs-on: ubuntu-latest
406467
if: always()
407468
steps:
408469
- name: Check results
409470
run: |
471+
if [[ "${{ needs.blocks-integrity.result }}" != "success" ]]; then
472+
echo "blocks-integrity failed"
473+
exit 1
474+
fi
475+
410476
if [[ "${{ needs.build-and-test-local.result }}" != "success" ]]; then
411477
echo "build-and-test-local failed"
412478
exit 1

0 commit comments

Comments
 (0)