forked from lerna/lerna
-
Notifications
You must be signed in to change notification settings - Fork 0
221 lines (187 loc) · 8.95 KB
/
other-node-versions.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
name: Other Node Versions
on:
workflow_dispatch:
schedule:
# Every day at 7:30am UTC
- cron: "30 7 * * *"
concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.ref }}
cancel-in-progress: true
env:
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
NX_VERBOSE_LOGGING: false
COREPACK_ENABLE_AUTO_PIN: "0"
COREPACK_ENABLE_STRICT: "0"
jobs:
set-node-versions:
name: Set Node Versions
runs-on: ubuntu-latest
outputs:
node-versions: ${{ steps.node-matrix.outputs.node-versions }}
steps:
- name: Set node matrix
id: node-matrix
# These versions intentionally do not contain our primary major version because that has already been tested by ci.yml
run: |
NODE_VERSIONS_JSON_ARRAY=$(node -e "console.log(JSON.stringify(['18']));")
echo $NODE_VERSIONS_JSON_ARRAY
echo "node-versions=$NODE_VERSIONS_JSON_ARRAY" >> $GITHUB_OUTPUT
main:
name: Nx Cloud - Main Job - node-${{ matrix.node }}
needs: set-node-versions
runs-on: ubuntu-latest
env:
NX_CI_EXECUTION_ENV: linux-node-${{ matrix.node }}
strategy:
# Do not kill all versions of node just because one version failed
fail-fast: false
matrix:
node: ${{ fromJson(needs.set-node-versions.outputs.node-versions) }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install node v${{ matrix.node }} and dependencies
uses: ./.github/actions/install-node-and-dependencies
with:
node-version: ${{ matrix.node }}
- name: Remove the volta key from package.json to ensure the explicitly installed version is respected
run: |
jq 'del(.volta)' package.json > package.json.tmp
mv package.json.tmp package.json
- name: Enable corepack
run: corepack enable
shell: bash
- name: Install pnpm v8
run: corepack install -g pnpm@8
shell: bash
- name: Print installed node, npm, yarn and pnpm versions
run: |
node --version
npm --version
yarn --version
pnpm --version
shell: bash
- name: Configure git metadata
run: |
git config --global user.email [email protected]
git config --global user.name "Tester McPerson"
- name: Generate and configure GPG for signing commits and tags in E2E tests
run: |
# Generate a GPG key for [email protected] and store the output from stderr
GPG_OUTPUT=$(echo "Key-Type: default
Key-Length: 2048
Subkey-Type: default
Subkey-Length: 2048
Name-Real: Tester McPerson
Name-Email: [email protected]
Expire-Date: 0
%no-protection" | gpg --pinentry-mode loopback --batch --generate-key 2>&1)
# Find and extract the revocation file path from sdterr
REVOCATION_FILE=$(echo "$GPG_OUTPUT" | grep '.rev' | tr '\n' ' ' | awk -F "'" '{print $4}')
# Get the GPG key ID and the full fingerprint
export GPG_KEY_ID=$(gpg --list-secret-keys --keyid-format LONG | grep sec | awk '{print $2}' | cut -d'/' -f2)
export GPG_FULL_KEY_ID=$(gpg --list-secret-keys --keyid-format LONG | grep "$GPG_KEY_ID" | grep -v "sec" | awk '{print $1}' | cut -d'/' -f2)
# Export fingerprint and the path to the revocation file to GITHUB_ENV
# This allows the last step in this job to revoke and delete the key
echo "GPG_FULL_KEY_ID=$GPG_FULL_KEY_ID" >> $GITHUB_ENV
echo "REVOCATION_FILE=$REVOCATION_FILE" >> $GITHUB_ENV
# Setup git signing for commits and tags
git config commit.gpgsign true
git config tag.gpgsign true
git config --global user.signingkey $GPG_KEY_ID
- name: Run parallel distributed builds and tests on each node version
uses: jameshenry/parallel-bash-commands@v1
with:
cmd1: npx nx run-many -t build --parallel=3
cmd2: npx nx run-many -t test --parallel=3 --ci --maxWorkers=2
cmd3: npx nx run integration:integration --ci --maxWorkers=2
# e2e tests for everything except the primary task runner
- run: PUBLISHED_VERSION=999.9.9-e2e.0 npx nx run-many --t e2e --parallel=1
- name: Run e2e tests for task-runner
run: |
# We do not want the automatic Github Actions grouping to be applied to the e2e tests, or the snapshots won't match local
unset GITHUB_ACTIONS
npx nx prepare-for-e2e e2e-run-task-runner && e2e/run/task-runner/src/run-tests.sh
shell: bash
env:
# Silently disable nx cloud for task runner e2e (using NX_NO_CLOUD produces a warning log)
NX_CLOUD_ACCESS_TOKEN: ""
NX_CLOUD_DISTRIBUTED_EXECUTION: false
- name: Stop all running agents
# It's important that we always run this step, otherwise in the case of any failures in preceding non-Nx steps, the agents will keep running and waste billable minutes
if: ${{ always() }}
run: npx nx-cloud stop-all-agents
- name: Revoke and delete GPG key
# It's important that we always run this step, otherwise the key will remain active if any of the steps above fail
if: ${{ always() }}
run: |
# As instructed in the text of revocation file, there is a colon that needs to be removed manually
sed -i "s/:-----BEGIN PGP PUBLIC KEY BLOCK-----/-----BEGIN PGP PUBLIC KEY BLOCK-----/" $REVOCATION_FILE
# Revoke the key and delete it
gpg --yes --import $REVOCATION_FILE
gpg --batch --yes --delete-secret-and-public-key $GPG_FULL_KEY_ID
agents:
name: Nx Cloud - Agent - node-${{ matrix.node }}-agent-${{ matrix.agent }}
needs: set-node-versions
runs-on: ubuntu-latest
env:
NX_CI_EXECUTION_ENV: linux-node-${{ matrix.node }}
strategy:
# Do not kill all versions of node just because one version failed
fail-fast: false
matrix:
node: ${{ fromJson(needs.set-node-versions.outputs.node-versions) }}
# Create 4 agents per node version
agent: [1, 2, 3, 4]
steps:
- uses: actions/checkout@v4
- name: Configure git metadata
run: |
git config --global user.email [email protected]
git config --global user.name "Tester McPerson"
- name: Generate and configure GPG for signing commits and tags in E2E tests
run: |
# Generate a GPG key for [email protected] and store the output from stderr
GPG_OUTPUT=$(echo "Key-Type: default
Key-Length: 2048
Subkey-Type: default
Subkey-Length: 2048
Name-Real: Tester McPerson
Name-Email: [email protected]
Expire-Date: 0
%no-protection" | gpg --pinentry-mode loopback --batch --generate-key 2>&1)
# Find and extract the revocation file path from sdterr
REVOCATION_FILE=$(echo "$GPG_OUTPUT" | grep '.rev' | tr '\n' ' ' | awk -F "'" '{print $4}')
# Get the GPG key ID and the full fingerprint
export GPG_KEY_ID=$(gpg --list-secret-keys --keyid-format LONG | grep sec | awk '{print $2}' | cut -d'/' -f2)
export GPG_FULL_KEY_ID=$(gpg --list-secret-keys --keyid-format LONG | grep "$GPG_KEY_ID" | grep -v "sec" | awk '{print $1}' | cut -d'/' -f2)
# Export fingerprint and the path to the revocation file to GITHUB_ENV
# This allows the last step in this job to revoke and delete the key
echo "GPG_FULL_KEY_ID=$GPG_FULL_KEY_ID" >> $GITHUB_ENV
echo "REVOCATION_FILE=$REVOCATION_FILE" >> $GITHUB_ENV
# Setup git signing for commits and tags
git config commit.gpgsign true
git config tag.gpgsign true
git config --global user.signingkey $GPG_KEY_ID
- name: Install node v${{ matrix.node }} and dependencies
uses: ./.github/actions/install-node-and-dependencies
with:
node-version: ${{ matrix.node }}
- name: Remove the volta key from package.json to ensure the explicitly installed version is respected
run: |
jq 'del(.volta)' package.json > package.json.tmp
mv package.json.tmp package.json
- name: Start Nx Agent node-${{ matrix.node }}-agent-${{ matrix.agent }}
run: npx nx-cloud start-agent
env:
NX_AGENT_NAME: node-${{ matrix.node }}-agent-${{ matrix.agent }}
- name: Revoke and delete GPG key
# It's important that we always run this step, otherwise the key will remain active if any of the steps above fail
if: ${{ always() }}
run: |
# As instructed in the text of revocation file, there is a colon that needs to be removed manually
sed -i "s/:-----BEGIN PGP PUBLIC KEY BLOCK-----/-----BEGIN PGP PUBLIC KEY BLOCK-----/" $REVOCATION_FILE
# Revoke the key and delete it
gpg --yes --import $REVOCATION_FILE
gpg --batch --yes --delete-secret-and-public-key $GPG_FULL_KEY_ID