Skip to content

Commit 0c2281f

Browse files
authored
Merge pull request #441 from adityasharad/tests/matrix-tools-latest
PR checks: Run integration tests against both `tools: null` and `tools: latest`
2 parents 534192f + fcf0863 commit 0c2281f

2 files changed

Lines changed: 119 additions & 6 deletions

File tree

.github/workflows/codeql.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,56 @@ on:
77
branches: [main, v1]
88

99
jobs:
10+
# Identify the CodeQL tool versions to use in the analysis job.
11+
check-codeql-versions:
12+
runs-on: ubuntu-latest
13+
outputs:
14+
versions: ${{ steps.compare.outputs.versions }}
15+
16+
steps:
17+
- uses: actions/checkout@v2
18+
- name: Init with default CodeQL bundle from the VM image
19+
id: init-default
20+
uses: ./init
21+
with:
22+
languages: javascript
23+
- name: Remove empty database
24+
# allows us to run init a second time
25+
run: |
26+
rm -rf "$RUNNER_TEMP/codeql_databases"
27+
- name: Init with latest CodeQL bundle
28+
id: init-latest
29+
uses: ./init
30+
with:
31+
tools: latest
32+
languages: javascript
33+
- name: Compare default and latest CodeQL bundle versions
34+
id: compare
35+
env:
36+
CODEQL_DEFAULT: ${{ steps.init-default.outputs.codeql-path }}
37+
CODEQL_LATEST: ${{ steps.init-latest.outputs.codeql-path }}
38+
run: |
39+
CODEQL_VERSION_DEFAULT="$("$CODEQL_DEFAULT" version --format terse)"
40+
CODEQL_VERSION_LATEST="$("$CODEQL_LATEST" version --format terse)"
41+
echo "Default CodeQL bundle version is $CODEQL_VERSION_DEFAULT"
42+
echo "Latest CodeQL bundle version is $CODEQL_VERSION_LATEST"
43+
if [[ "$CODEQL_VERSION_DEFAULT" == "$CODEQL_VERSION_LATEST" ]]; then
44+
# Just use `tools: null` to avoid duplication in the analysis job.
45+
VERSIONS_JSON='[null]'
46+
else
47+
# Use both `tools: null` and `tools: latest` in the analysis job.
48+
VERSIONS_JSON='[null, "latest"]'
49+
fi
50+
# Output a JSON-encoded list with the distinct versions to test against.
51+
echo "Suggested matrix config for analysis job: $VERSIONS_JSON"
52+
echo "::set-output name=versions::${VERSIONS_JSON}"
53+
1054
build:
55+
needs: [check-codeql-versions]
1156
strategy:
1257
matrix:
1358
os: [ubuntu-latest,windows-latest,macos-latest]
59+
tools: ${{ fromJson(needs.check-codeql-versions.outputs.versions) }}
1460
runs-on: ${{ matrix.os }}
1561

1662
steps:
@@ -20,6 +66,7 @@ jobs:
2066
with:
2167
languages: javascript
2268
config-file: ./.github/codeql/codeql-config.yml
69+
tools: ${{ matrix.tools }}
2370
# confirm steps.init.outputs.codeql-path points to the codeql binary
2471
- name: Print CodeQL Version
2572
run: ${{steps.init.outputs.codeql-path}} version --format=json

.github/workflows/pr-checks.yml

Lines changed: 72 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,65 @@ jobs:
8080
exit 1
8181
fi
8282
83-
multi-language-repo_test-custom-queries-and-remote-config:
83+
# Identify the CodeQL tool versions to integration test against.
84+
check-codeql-versions:
8485
needs: [check-js, check-node-modules]
86+
runs-on: ubuntu-latest
87+
outputs:
88+
versions: ${{ steps.compare.outputs.versions }}
89+
90+
steps:
91+
- uses: actions/checkout@v2
92+
- name: Move codeql-action
93+
shell: bash
94+
run: |
95+
mkdir ../action
96+
mv * .github ../action/
97+
mv ../action/tests/multi-language-repo/{*,.github} .
98+
mv ../action/.github/workflows .github
99+
- name: Init with default CodeQL bundle from the VM image
100+
id: init-default
101+
uses: ./../action/init
102+
with:
103+
languages: javascript
104+
- name: Remove empty database
105+
# allows us to run init a second time
106+
run: |
107+
rm -rf "$RUNNER_TEMP/codeql_databases"
108+
- name: Init with latest CodeQL bundle
109+
id: init-latest
110+
uses: ./../action/init
111+
with:
112+
tools: latest
113+
languages: javascript
114+
- name: Compare default and latest CodeQL bundle versions
115+
id: compare
116+
env:
117+
CODEQL_DEFAULT: ${{ steps.init-default.outputs.codeql-path }}
118+
CODEQL_LATEST: ${{ steps.init-latest.outputs.codeql-path }}
119+
run: |
120+
CODEQL_VERSION_DEFAULT="$("$CODEQL_DEFAULT" version --format terse)"
121+
CODEQL_VERSION_LATEST="$("$CODEQL_LATEST" version --format terse)"
122+
echo "Default CodeQL bundle version is $CODEQL_VERSION_DEFAULT"
123+
echo "Latest CodeQL bundle version is $CODEQL_VERSION_LATEST"
124+
if [[ "$CODEQL_VERSION_DEFAULT" == "$CODEQL_VERSION_LATEST" ]]; then
125+
# Just use `tools: null` to avoid duplication in the integration tests.
126+
VERSIONS_JSON='[null]'
127+
else
128+
# Use both `tools: null` and `tools: latest` in the integration tests.
129+
VERSIONS_JSON='[null, "latest"]'
130+
fi
131+
# Output a JSON-encoded list with the distinct versions to test against.
132+
echo "Suggested matrix config for integration tests: $VERSIONS_JSON"
133+
echo "::set-output name=versions::${VERSIONS_JSON}"
134+
135+
multi-language-repo_test-custom-queries-and-remote-config:
136+
needs: [check-js, check-node-modules, check-codeql-versions]
85137
strategy:
86138
fail-fast: false
87139
matrix:
88140
os: [ubuntu-latest, windows-latest, macos-latest]
89-
tools: [~, latest]
141+
tools: ${{ fromJson(needs.check-codeql-versions.outputs.versions) }}
90142
runs-on: ${{ matrix.os }}
91143

92144
steps:
@@ -112,11 +164,12 @@ jobs:
112164

113165
# Currently is not possible to analyze Go in conjunction with other languages in macos
114166
multi-language-repo_test-go-custom-queries:
115-
needs: [check-js, check-node-modules]
167+
needs: [check-js, check-node-modules, check-codeql-versions]
116168
strategy:
117169
fail-fast: false
118170
matrix:
119171
os: [ubuntu-latest, windows-latest, macos-latest]
172+
tools: ${{ fromJson(needs.check-codeql-versions.outputs.versions) }}
120173
runs-on: ${{ matrix.os }}
121174

122175
steps:
@@ -136,6 +189,7 @@ jobs:
136189
with:
137190
languages: go
138191
config-file: ./.github/codeql/custom-queries.yml
192+
tools: ${{ matrix.tools }}
139193
- name: Build code
140194
shell: bash
141195
run: ./build.sh
@@ -144,11 +198,12 @@ jobs:
144198
TEST_MODE: true
145199

146200
go-custom-tracing:
147-
needs: [check-js, check-node-modules]
201+
needs: [check-js, check-node-modules, check-codeql-versions]
148202
strategy:
149203
fail-fast: false
150204
matrix:
151205
os: [ubuntu-latest, windows-latest, macos-latest]
206+
tools: ${{ fromJson(needs.check-codeql-versions.outputs.versions) }}
152207
runs-on: ${{ matrix.os }}
153208
env:
154209
CODEQL_EXTRACTOR_GO_BUILD_TRACING: "on"
@@ -169,6 +224,7 @@ jobs:
169224
- uses: ./../action/init
170225
with:
171226
languages: go
227+
tools: ${{ matrix.tools }}
172228
- name: Build code
173229
shell: bash
174230
run: go build main.go
@@ -177,7 +233,11 @@ jobs:
177233
TEST_MODE: true
178234

179235
go-custom-tracing-autobuild:
180-
needs: [check-js, check-node-modules]
236+
needs: [check-js, check-node-modules, check-codeql-versions]
237+
strategy:
238+
fail-fast: false
239+
matrix:
240+
tools: ${{ fromJson(needs.check-codeql-versions.outputs.versions) }}
181241
# No need to test Go autobuild on multiple OSes since
182242
# we're testing Go custom tracing with a manual build on all OSes.
183243
runs-on: ubuntu-latest
@@ -196,6 +256,7 @@ jobs:
196256
- uses: ./../action/init
197257
with:
198258
languages: go
259+
tools: ${{ matrix.tools }}
199260
- uses: ./../action/autobuild
200261
- uses: ./../action/analyze
201262
env:
@@ -235,7 +296,11 @@ jobs:
235296
TEST_MODE: true
236297

237298
test-proxy:
238-
needs: [check-js, check-node-modules]
299+
needs: [check-js, check-node-modules, check-codeql-versions]
300+
strategy:
301+
fail-fast: false
302+
matrix:
303+
tools: ${{ fromJson(needs.check-codeql-versions.outputs.versions) }}
239304
runs-on: ubuntu-latest
240305
container:
241306
image: ubuntu:18.04
@@ -259,6 +324,7 @@ jobs:
259324
- uses: ./../action/init
260325
with:
261326
languages: javascript
327+
tools: ${{ matrix.tools }}
262328
- uses: ./../action/analyze
263329
env:
264330
TEST_MODE: true

0 commit comments

Comments
 (0)