@@ -19,7 +19,7 @@ concurrency:
1919 cancel-in-progress : true
2020
2121env :
22- NODE_VERSION : ' 18 '
22+ NODE_VERSION : ' 22 '
2323
2424jobs :
2525 pre-check :
@@ -114,7 +114,7 @@ jobs:
114114 # strategy:
115115 # fail-fast: false
116116 # matrix:
117- # node: ['18 ', '20 ']
117+ # node: ['22 ', '24 ']
118118 steps :
119119 - uses : actions/checkout@v4
120120
@@ -135,14 +135,14 @@ jobs:
135135 run : pnpm run test:coverage
136136
137137 - name : Upload coverage artifact
138- # if: matrix.node == '18 ' # UNCOMMENT FOR MATRIX
138+ # if: matrix.node == '22 ' # UNCOMMENT FOR MATRIX
139139 uses : actions/upload-artifact@v4
140140 with :
141141 name : coverage-${{ github.sha }}
142142 path : coverage
143143
144144 - name : Upload to Codecov
145- # if: matrix.node == '18 ' # UNCOMMENT FOR MATRIX
145+ # if: matrix.node == '22 ' # UNCOMMENT FOR MATRIX
146146 uses : codecov/codecov-action@v5
147147 with :
148148 token : ${{ secrets.CODECOV_TOKEN }}
@@ -167,7 +167,7 @@ jobs:
167167 # fail-fast: false
168168 # matrix:
169169 # os: [windows-latest, macos-latest]
170- # node: ['20 ']
170+ # node: ['22 ']
171171 # runs-on: ${{ matrix.os }}
172172 # steps:
173173 # - uses: actions/checkout@v4
@@ -256,7 +256,20 @@ jobs:
256256 # own name, and a GitHub release holds one asset per name.
257257 - name : Check the release assets
258258 run : node scripts/check-release-assets.js
259-
259+
260+ # The tarball npm would publish, for the runtime-floor job to install as a consumer does.
261+ - name : Pack the package
262+ run : |
263+ mkdir -p "$RUNNER_TEMP/package"
264+ npm pack --ignore-scripts --pack-destination "$RUNNER_TEMP/package"
265+
266+ - name : Upload the packed package
267+ uses : actions/upload-artifact@v4
268+ with :
269+ name : package-${{ github.sha }}
270+ path : ${{ runner.temp }}/package/*.tgz
271+ if-no-files-found : error
272+
260273 - name : Bundle size check
261274 run : pnpm run size:check
262275
@@ -284,6 +297,53 @@ jobs:
284297 name : dist-${{ github.sha }}
285298 path : dist
286299
300+ # engines.node in package.json is the oldest Node a consumer may run magiclogger on. This
301+ # installs the packed package with npm on that Node, as a consumer would, and loads both entry
302+ # points through scripts/check-runtime-floor.cjs. The suite runs from src on Node 22 and
303+ # cannot see a build that needs a newer Node than engines claims.
304+ runtime-floor :
305+ runs-on : ubuntu-latest
306+ needs : build
307+ timeout-minutes : 10
308+ steps :
309+ - uses : actions/checkout@v4
310+ with :
311+ persist-credentials : false
312+
313+ - name : Read the oldest Node that engines allows
314+ id : floor
315+ run : |
316+ floor=$(node -p '(/^>=\s*(\d+\.\d+\.\d+)$/.exec(require("./package.json").engines.node) || [])[1] || ""')
317+ if [ -z "$floor" ]; then
318+ echo "::error::engines.node in package.json must read >=x.y.z"
319+ exit 1
320+ fi
321+ echo "version=$floor" >> "$GITHUB_OUTPUT"
322+
323+ - name : Download the packed package
324+ uses : actions/download-artifact@v4
325+ with :
326+ name : package-${{ github.sha }}
327+ path : ${{ runner.temp }}/package
328+
329+ - name : Setup Node.js ${{ steps.floor.outputs.version }}
330+ uses : actions/setup-node@v4
331+ with :
332+ node-version : ${{ steps.floor.outputs.version }}
333+
334+ - name : Install the package as a consumer
335+ working-directory : ${{ runner.temp }}
336+ run : |
337+ mkdir consumer
338+ cd consumer
339+ npm init -y > /dev/null
340+ npm install --no-audit --no-fund ../package/*.tgz
341+ cp "$GITHUB_WORKSPACE/scripts/check-runtime-floor.cjs" .
342+
343+ - name : Load both entry points
344+ working-directory : ${{ runner.temp }}/consumer
345+ run : node check-runtime-floor.cjs
346+
287347 release-draft :
288348 name : Update Release Draft
289349 runs-on : ubuntu-latest
@@ -317,50 +377,15 @@ jobs:
317377 node-version : ${{ env.NODE_VERSION }}
318378 cache : ' pnpm'
319379
320- - name : Cache website dependencies
321- uses : actions/cache@v4
322- with :
323- path : website/node_modules
324- key : ${{ runner.os }}-website-${{ hashFiles('website/package-lock.json') }}
325- restore-keys : |
326- ${{ runner.os }}-website-
327-
328- - name : Install root dependencies
329- run : pnpm install --frozen-lockfile
330-
331- - name : Build library (minified production)
332- run : |
333- echo "Building minified production library..."
334- NODE_ENV=production pnpm run build
335- env :
336- NODE_ENV : production
337-
338- - name : Generate API documentation
339- run : |
340- echo "Generating TypeDoc API documentation..."
341- pnpm run docs:api
342-
343- - name : Install website dependencies
344- working-directory : ./website
345- run : |
346- # Use pnpm for consistency with root project
347- pnpm install --frozen-lockfile
348-
349- - name : Sync documentation
350- run : |
351- if [ -f "scripts/sync-docs.js" ]; then
352- node scripts/sync-docs.js
353- else
354- cp -r docs/* website/docs/ 2>/dev/null || true
355- fi
356-
357- - name : Build Docusaurus (production minified)
358- working-directory : ./website
359- run : |
360- echo "Building minified Docusaurus site..."
361- NODE_ENV=production pnpm run build
380+ # The install, the library build, the API pages and the Docusaurus build, as docs-build.yml
381+ # runs them on pull requests, after the same setup steps. No website/node_modules cache is
382+ # restored first: the one that stood here keyed on website/package-lock.json, which does
383+ # not exist, so its key never changed and every deploy restored the folder one master run
384+ # saved, from an older dependency tree than the lockfile, before an install no
385+ # pull-request check ran from. setup-node's pnpm cache holds the store.
386+ - name : Build the site
387+ run : bash scripts/build-docs-site.sh
362388 env :
363- NODE_ENV : production
364389 GA_TRACKING_ID : ${{ secrets.GA_TRACKING_ID }}
365390 MS_CLARITY_ID : ${{ secrets.MS_CLARITY_ID }}
366391
@@ -381,9 +406,21 @@ jobs:
381406
382407 all-checks :
383408 runs-on : ubuntu-latest
384- needs : [quality, test-linux, build, security]
385- # needs: [quality, test-linux, test-cross, build, security] # UNCOMMENT FOR CROSS-PLATFORM
409+ needs : [quality, test-linux, build, security, runtime-floor ]
410+ # needs: [quality, test-linux, test-cross, build, security, runtime-floor ] # UNCOMMENT FOR CROSS-PLATFORM
386411 if : always()
387412 steps :
413+ # if: always() runs this job after a failed or skipped job too, so the needed jobs'
414+ # results decide it; an echo alone passed while test-linux or build had failed.
388415 - name : Final status
389- run : echo "✅ Core CI jobs completed"
416+ env :
417+ RESULTS : ${{ join(needs.*.result, ' ') }}
418+ run : |
419+ echo "Needed jobs: $RESULTS"
420+ for result in $RESULTS; do
421+ if [ "$result" != success ]; then
422+ echo "::error::a needed job ended $result"
423+ exit 1
424+ fi
425+ done
426+ echo "Core CI jobs passed"
0 commit comments