@@ -15,13 +15,39 @@ jobs:
15
15
runs-on : ubuntu-latest
16
16
timeout-minutes : 45
17
17
18
+ strategy :
19
+ matrix :
20
+ node-types-version : [16.11, current] # run tests on 16.11 while CodeQL Action v2 is still supported
21
+
18
22
steps :
19
23
- name : Checkout
20
24
uses : actions/checkout@v4
21
25
22
26
- name : Lint
23
27
run : npm run-script lint
24
28
29
+ - name : Update version of @types/node
30
+ if : matrix.node-types-version != 'current'
31
+ env :
32
+ NODE_TYPES_VERSION : ${{ matrix.node-types-version }}
33
+ run : |
34
+ # Export `NODE_TYPES_VERSION` so it's available to jq
35
+ export NODE_TYPES_VERSION="${NODE_TYPES_VERSION}"
36
+ contents=$(jq '.devDependencies."@types/node" = env.NODE_TYPES_VERSION' package.json)
37
+ echo "${contents}" > package.json
38
+ # Usually we run `npm install` on macOS to ensure that we pick up macOS-only dependencies.
39
+ # However we're not checking in the updated lockfile here, so it's fine to run
40
+ # `npm install` on Linux.
41
+ npm install
42
+
43
+ if [ ! -z "$(git status --porcelain)" ]; then
44
+ git config --global user.email "github-actions@github.com"
45
+ git config --global user.name "github-actions[bot]"
46
+ # The period in `git add --all .` ensures that we stage deleted files too.
47
+ git add --all .
48
+ git commit -m "Use @types/node=${NODE_TYPES_VERSION}"
49
+ fi
50
+
25
51
- name : Check generated JS
26
52
run : .github/workflows/script/check-js.sh
27
53
45
71
uses : actions/checkout@v4
46
72
47
73
- name : Set up Python
48
- uses : actions/setup-python@v4
74
+ uses : actions/setup-python@v5
49
75
with :
50
76
python-version : 3.11
51
77
70
96
71
97
steps :
72
98
- name : Setup Python on MacOS
73
- uses : actions/setup-python@v4
99
+ uses : actions/setup-python@v5
74
100
if : |
75
101
matrix.os == 'macos-latest' && (
76
102
matrix.version == 'stable-20220908' ||
@@ -88,3 +114,44 @@ jobs:
88
114
# we won't be able to find them on Windows.
89
115
npm config set script-shell bash
90
116
npm test
117
+
118
+ check-node-version :
119
+ if : ${{ github.event.pull_request }}
120
+ name : Check Action Node versions
121
+ runs-on : ubuntu-latest
122
+ timeout-minutes : 45
123
+ env :
124
+ BASE_REF : ${{ github.base_ref }}
125
+
126
+ steps :
127
+ - uses : actions/checkout@v4
128
+ - id : head-version
129
+ name : Verify all Actions use the same Node version
130
+ run : |
131
+ NODE_VERSION=$(find . -name "action.yml" -exec yq -e '.runs.using' {} \; | grep node | sort | uniq)
132
+ echo "NODE_VERSION: ${NODE_VERSION}"
133
+ if [[ $(echo "$NODE_VERSION" | wc -l) -gt 1 ]]; then
134
+ echo "::error::More than one node version used in 'action.yml' files."
135
+ exit 1
136
+ fi
137
+ echo "node_version=${NODE_VERSION}" >> $GITHUB_OUTPUT
138
+
139
+ - id : checkout-base
140
+ name : ' Backport: Check out base ref'
141
+ if : ${{ startsWith(github.head_ref, 'backport-') }}
142
+ uses : actions/checkout@v4
143
+ with :
144
+ ref : ${{ env.BASE_REF }}
145
+
146
+ - name : ' Backport: Verify Node versions unchanged'
147
+ if : steps.checkout-base.outcome == 'success'
148
+ env :
149
+ HEAD_VERSION : ${{ steps.head-version.outputs.node_version }}
150
+ run : |
151
+ BASE_VERSION=$(find . -name "action.yml" -exec yq -e '.runs.using' {} \; | grep node | sort | uniq)
152
+ echo "HEAD_VERSION: ${HEAD_VERSION}"
153
+ echo "BASE_VERSION: ${BASE_VERSION}"
154
+ if [[ "$BASE_VERSION" != "$HEAD_VERSION" ]]; then
155
+ echo "::error::Cannot change the Node version of an Action in a backport PR."
156
+ exit 1
157
+ fi
0 commit comments