-
-
Notifications
You must be signed in to change notification settings - Fork 15
144 lines (122 loc) · 4.76 KB
/
is-nextjestjs-swc-comat.yml
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: is-nextjestjs-swc-comat
on:
workflow_dispatch: # * Treated like a scheduled run
schedule:
- cron: '15 */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.x
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-NEXTJESTJS-SWC-COMAT IS RUNNING IN DEBUG MODE ($DEBUG)"
else
echo '(is-nextjestjs-swc-comat 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
timeout-minutes: 10
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://git@github.com/
- name: Use node ${{ matrix.node }}
uses: actions/setup-node@v4.1.0
- 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 }}-
# Turns out tee eats exit codes... ... sigh
# Also, we use npm install over npm ci for more accurate test results
- name: Install CI dependencies
run: |
mkfifo '#pipe.ignore'
tee --append /tmp/output.txt < '#pipe.ignore' &
npm install --force > '#pipe.ignore' 2>&1
rm '#pipe.ignore'
- name: Build externals (we're only interested in util.js)
run: npm run build:externals
# We need to install Next.js's peer dependencies by hand because it is
# possible that Vercel devs publish broken package.json peerDependencies
#
# Also, note that, when piping stuff, npm install seems to break the pipe
# for any processes that come after it. Not sure why, but can be fixed by
# rm-ing and re-mkfifo-ing the pipe.
- name: Run davidmytton's example repo tests
# https://github.com/Xunnamius/next-test-api-route-handler/discussions/983#
run: |
previous_cwd=$(pwd)
mkdir -p /tmp/ntarh-test
git clone https://github.com/Xunnamius/ntarh-nextjestjs-swc-compat-test /tmp/ntarh-test
cd /tmp/ntarh-test
mkfifo '#pipe.ignore'
tee --append /tmp/output.txt < '#pipe.ignore' &
npm install --force > '#pipe.ignore' 2>&1
extra_installs=$(node -e '(async () => console.log((await require("'"$previous_cwd"'/external-scripts/bin/util.js").getNextjsReactPeerDependencies("next@latest")).join(" ")))()')
rm '#pipe.ignore'
mkfifo '#pipe.ignore'
tee --append /tmp/output.txt < '#pipe.ignore' &
if [[ -n "$extra_installs" ]]; then
echo installing extra_installs:
npm install --force --no-save $(echo $extra_installs) > '#pipe.ignore' 2>&1
fi
echo listing deps:
npm list next
npm list next-test-api-route-handler
npm list react
npm list react-dom
echo running jest:
npx jest
echo done
rm '#pipe.ignore'
- 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