is-next-compat #4202
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: is-next-compat | |
# ! If you want to use this workflow, the following secrets must be defined: | |
# ! - MONGODB_URI | |
# ! - GH_TOKEN | |
on: | |
workflow_dispatch: # * Treated like a scheduled run | |
schedule: | |
- cron: '0 */6 * * *' | |
env: | |
# * Selectively enable debugger verbose output in the pipeline | |
# ? See also: https://www.npmjs.com/package/debug#wildcards | |
# DEBUG: 'next-test-api-route-handler:*' | |
NODE_CURRENT_VERSION: '>=22.5.1' | |
NODE_OLDER_VERSIONS: '"18.x", "20.x"' | |
jobs: | |
metadata: | |
name: 'gather-metadata' | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
outputs: | |
node-matrix: ${{ steps.set-matrix.outputs.node-matrix }} | |
steps: | |
- name: Report mode statuses | |
run: | | |
if [ -n "$DEBUG" ]; then | |
echo "IS-NEXT-COMPAT IS RUNNING IN DEBUG MODE ($DEBUG)" | |
else | |
echo '(is-next-compat is not running in debug mode)' | |
fi | |
- name: Gather metadata | |
id: set-matrix | |
run: | | |
echo "node-matrix={\"node\":[$NODE_OLDER_VERSIONS, \"$NODE_CURRENT_VERSION\"]}" >> $GITHUB_OUTPUT | |
! [ -z "$DEBUG" ] && echo "set-output name=node-matrix::{\"node\":[$NODE_OLDER_VERSIONS, \"$NODE_CURRENT_VERSION\"]}" || true | |
check-compat: | |
runs-on: ubuntu-latest | |
needs: metadata | |
strategy: | |
fail-fast: false | |
matrix: ${{ fromJson(needs.metadata.outputs.node-matrix) }} | |
steps: | |
# GitHub Actions artifacts cannot handle filenames with certain characters | |
- name: Reify metadata | |
id: reified-metadata | |
env: | |
NODE_VERSION: ${{ matrix.node }} | |
run: > | |
node -p | |
'`node-version-sanitized=${process.env.NODE_VERSION.replaceAll( | |
/[":<>|*?\\\/=,\s'"'"']/g,"-")}`' >> "$GITHUB_OUTPUT" | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
# See: https://github.com/actions/setup-node/issues/214#issuecomment-810829250 | |
- name: Reconfigure git to use HTTP authentication | |
run: > | |
git config --global url."https://github.com/".insteadOf | |
ssh://[email protected]/ | |
- name: Use node ${{ matrix.node }} | |
uses: actions/[email protected] | |
with: | |
node-version: ${{ matrix.node }} | |
- name: Cache npm | |
uses: actions/cache@v4 | |
id: cache-npm | |
with: | |
key: | |
npm-node-${{ matrix.node }}-${{ runner.os }}-${{ | |
hashFiles('**/package-lock.json') }} | |
path: ~/.npm | |
restore-keys: npm-node-${{ matrix.node }}-${{ runner.os }}- | |
# tee eats exit codes... ... sigh | |
- name: Install CI dependencies | |
run: | | |
mkfifo '#pipe' | |
tee --append /tmp/output.txt < '#pipe' & | |
npm install --force --no-save semver > '#pipe' 2>&1 | |
rm '#pipe' | |
- name: Build distributables | |
run: | | |
mkfifo '#pipe' | |
tee --append /tmp/output.txt < '#pipe' & | |
npm run build:dist > '#pipe' 2>&1 | |
rm '#pipe' | |
- name: Build externals | |
run: npm run build:externals | |
- name: Run is-next-compat | |
env: | |
GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
MONGODB_URI: ${{ secrets.MONGODB_URI }} | |
NODE_TARGET_VERSION: ${{ env.NODE_CURRENT_VERSION }} | |
run: | | |
mkfifo '#pipe' | |
tee --append /tmp/output.txt < '#pipe' & | |
node --no-warnings external-scripts/bin/is-next-compat.js > '#pipe' 2>&1 | |
rm '#pipe' | |
- name: Upload output artifact | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: | |
output-node-${{ | |
steps.reified-metadata.outputs.node-version-sanitized }}-${{ | |
github.sha }} | |
path: /tmp/output.txt | |
if-no-files-found: error | |
retention-days: 1 |