-
Notifications
You must be signed in to change notification settings - Fork 3.6k
63 lines (55 loc) · 2.12 KB
/
Copy pathsocratiq-bundle-drift.yml
File metadata and controls
63 lines (55 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
name: '🔒 SocratiQ Bundle Drift'
# =============================================================================
# SocratiQ source-to-bundle drift guard
# =============================================================================
#
# The book ships a pre-built bundle at
# book/quarto/tools/scripts/socratiQ/bundle.js
# which is regenerated by `npm run build:vite` in socratiq/. Because the
# bundle is version-controlled, source edits that skip the rebuild step
# cause the rendered book to silently serve a stale widget.
#
# This workflow rebuilds the bundle on any PR that touches the widget's
# source or build inputs and fails if the committed bundle has drifted
# from what the sources produce.
#
# Triggers:
# - pull_request on changes to socratiq sources / config / lockfile
# - workflow_dispatch for manual runs
# =============================================================================
on:
workflow_dispatch:
pull_request:
paths:
- 'socratiq/src_shadow/**'
- 'socratiq/vite.config.prod.mjs'
- 'socratiq/vite.config.dev.mjs'
- 'socratiq/package.json'
- 'socratiq/package-lock.json'
permissions:
contents: read
jobs:
verify-bundle-matches-source:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v6
- name: Set up Node
uses: actions/setup-node@v6
with:
node-version: ${{ vars.NODE_VERSION || '20' }}
cache: npm
cache-dependency-path: socratiq/package-lock.json
- name: Install socratiq dependencies
run: npm ci
working-directory: socratiq
- name: Rebuild production bundle
run: npm run build:vite
working-directory: socratiq
- name: Fail if committed bundle drifted from source
run: |
if ! git diff --exit-code book/quarto/tools/scripts/socratiQ/bundle.js; then
echo "::error::socratiq sources changed but the committed bundle.js was not regenerated."
echo "::error::Run 'npm run build:vite' in socratiq/ and commit the regenerated book/quarto/tools/scripts/socratiQ/bundle.js."
exit 1
fi