8000 Use recent versions of the cli for running the tests · github/gh-codeql@12dff87 · GitHub
[go: up one dir, main page]

Skip to content

Commit 12dff87

Browse files
committed
Use recent versions of the cli for running the tests
This workflow was failing since it was using an old version of the cli that can't run the latest queries. Instead, always ensure we are running the latest CLI and the two previous instances.
1 parent 8efc4e5 commit 12dff87

File tree

1 file changed

+43
-32
lines changed

1 file changed

+43
-32
lines changed

.github/workflows/pr-checks.yml

Lines changed: 43 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,29 @@ jobs:
2020
uses: actions/checkout@v2
2121

2222
- name: Install extension
23-
shell: bash
2423
run: |
2524
gh extensions install .
2625
27-
- name: Check automatically installs latest
26+
- name: Get recent CLI versions
2827
shell: bash
2928
run: |
30-
LATEST=`gh release list --repo github/codeql-cli-binaries -L 1 | cut -f 3`
29+
THREE_VERSIONS="$(gh release list --repo github/codeql-cli-binaries -L 3 | cut -f 3)"
30+
LATEST="$(echo $THREE_VERSIONS | awk '{print $1}')"
31+
SECOND_LATEST="$(echo $THREE_VERSIONS | awk '{print $2}')"
32+
THIRD_LATEST="$(echo $THREE_VERSIONS | awk '{print $3}')"
33+
34+
echo "Using versions $LATEST : $SECOND_LATEST : $THIRD_LATEST"
3135
36+
echo "LATEST=$LATEST" >> $GITHUB_ENV
37+
echo "SECOND_LATEST=$SECOND_LATEST" >> $GITHUB_ENV
38+
echo "THIRD_LATEST=$THIRD_LATEST" >> $GITHUB_ENV
39+
40+
- name: Check automatically installs latest
41+
shell: bash
42+
run: |
3243
# Note we need to run a command before trying to parse the output below, or the
3344
# messages from the download will end up in the JSON that jq tries to parse
34-
gh codeql version
45+
gh codeql version
3546
3647
INSTALLED=`gh codeql version --format json | jq -r '.version'`
3748
if [[ "v$INSTALLED" != $LATEST ]]; then
@@ -43,7 +54,7 @@ jobs:
4354
working-directory: test-resources
4455
shell: bash
4556
run: |
46-
gh codeql set-version 2.6.1
57+
gh codeql set-version "$LATEST"
4758
gh codeql database create -l cpp -s test-repo -c "gcc -o main main.c" test-db
4859
gh codeql pack install test-pack
4960
gh codeql database analyze --format=sarif-latest --output=out.sarif test-db test-pack/allExpressions.ql
@@ -57,17 +68,17 @@ jobs:
5768
shell: bash
5869
run: |
5970
# Set the version without a v prefix
60-
gh codeql set-version 2.5.9
71+
gh codeql set-version "$SECOND_LATEST"
6172
VERSION=`gh codeql version --format json | jq -r '.version'`
62-
if [[ $VERSION != "2.5.9" ]]; then
63-
echo "::error::Expected version 2.5.9 but got $VERSION"
73+
if [[ $VERSION != "$SECOND_LATEST" ]]; then
74+
echo "::error::Expected version $SECOND_LATEST but got $VERSION"
6475
exit 1
6576
fi
66-
gh codeql list-installed | grep v2.5.9
77+
gh codeql list-installed | grep v$SECOND_LATEST
6778
6879
# Set the version with a v prefix
6980
COUNT_BEFORE=`gh codeql list-installed | wc -l`
70-
gh codeql set-version v2.5.9
81+
gh codeql set-version v$SECOND_LATEST
7182
COUNT_AFTER=`gh codeql list-installed | wc -l`
7283
if [[ $COUNT_BEFORE != $COUNT_BEFORE ]]; then
7384
echo "::error::Installing an already installed version changed the number of installed versions from $COUNT_BEFORE to $COUNT_AFTER!"
@@ -79,8 +90,8 @@ jobs:
7990
run: |
8091
gh codeql set-version latest
8192
VERSION=`gh codeql version --format json | jq -r '.version'`
82-
if [[ $VERSION == "2.5.9" ]]; then
83-
echo "::error::Expected latest version but got 2.5.9"
93+
if [[ $VERSION == "$SECOND_LATEST" ]]; then
94+
echo "::error::Expected latest version but got $SECOND_LATEST"
8495
exit 1
8596
fi
8697
@@ -93,10 +104,10 @@ jobs:
93104
# Get the latest installed version
94105
LATEST=`gh codeql version --format json | jq -r '.version'`
95106
# Set a local version
96-
gh codeql set-local-version 2.5.9
107+
gh codeql set-local-version $SECOND_LATEST
97108
VERSION=`gh codeql version --format json | jq -r '.version'`
98-
if [[ $VERSION != "2.5.9" ]]; then
99-
echo "::error::Expected version 2.5.9 but got $VERSION"
109+
if [[ $VERSION != "$SECOND_LATEST" ]]; then
110+
echo "::error::Expected version $SECOND_LATEST but got $VERSION"
100111
exit 1
101112
fi
102113
@@ -124,11 +135,11 @@ jobs:
124135
# Get the latest installed version
125136
LATEST=`gh codeql version --format json | jq -r '.version'`
126137
# Set a local version
127-
gh codeql set-local-version 2.5.9
138+
gh codeql set-local-version $SECOND_LATEST
128139
# Unset the local version
129140
gh codeql unset-local-version
130-
if [[ $VERSION == "2.5.9" ]]; then
131-
echo "::error::Expected $LATEST version but got 2.5.9"
141+
if [[ $VERSION == "$SECOND_LATEST" ]]; then
142+
echo "::error::Expected $LATEST version but got $SECOND_LATEST"
132143
exit 1
133144
fi
134145
# Disable local version support
@@ -143,20 +154,20 @@ jobs:
143154
# Get the latest installed version
144155
LATEST=`gh codeql version --format json | jq -r '.version'`
145156
# Set a local version
146-
gh codeql set-local-version 2.5.9
157+
gh codeql set-local-version $SECOND_LATEST
147158
VERSION=`gh codeql version --format json | jq -r '.version'`
148-
if [[ $VERSION != "2.5.9" ]]; then
149-
echo "::error::Expected version 2.5.9 but got $VERSION"
159+
if [[ $VERSION != "$SECOND_LATEST" ]]; then
160+
echo "::error::Expected version $SECOND_LATEST but got $VERSION"
150161
exit 1
151162
fi
152163
153164
# Modify the pinned version without using the CLI
154-
echo v2.7.6 > .codeql-version
165+
echo v$THIRD_LATEST > .codeql-version
155166
# We run the command twice to prevent cURL output from causing a `jq` parser error.
156167
gh codeql version
157168
VERSION=`gh codeql version --format json | jq -r '.version'`
158-
if [[ $VERSION != "2.7.6" ]]; then
159-
echo "::error::Expected version 2.7.6 but got $VERSION"
169+
if [[ $VERSION != "$SECOND_LATEST" ]]; then
170+
echo "::error::Expected version $SECOND_LATEST but got $VERSION"
160171
exit 1
161172
fi
162173
gh codeql unset-local-version
@@ -168,15 +179,15 @@ jobs:
168179
run: |
169180
gh codeql set-version latest
170181
# Get the latest installed version
171-
LATEST=`gh codeql version --format json | jq -r '.version'`
182+
LATEST_INSTALLED=`gh codeql version --format json | jq -r '.version'`
172183
173184
# Modify the pinned version without using the CLI
174-
echo v2.7.6 > .codeql-version
185+
echo v$SECOND_LATEST > .codeql-version
175186
# We run the command twice to prevent cURL output from causing a `jq` parser error.
176187
gh codeql version
177188
VERSION=`gh codeql version --format json | jq -r '.version'`
178-
if [[ $VERSION = "2.7.6" ]]; then
179-
echo "::error::Expected version $LATEST but got $VERSION"
189+
if [[ $VERSION = "$SECOND_LATEST" ]]; then
190+
echo "::error::Expected version $LATEST_INSTALLED but got $VERSION"
180191
exit 1
181192
fi
182193
rm .codeql-version
@@ -200,11 +211,11 @@ jobs:
200211
# We run the command with a version override twice such that first run will download the CodeQL CLI
201212
# and the cURL output doesn't confuse the `jq` parser in the second run.
202213
# This implicit download is to test that we properly support the implicit download of a requested version if it is not present.
203-
GH_CODEQL_VERSION=v2.7.6 gh codeql version
204-
VERSION=`GH_CODEQL_VERSION=v2.7.6 gh codeql version --format json | jq -r '.version'`
214+
GH_CODEQL_VERSION=v$SECOND_LATEST gh codeql version
215+
VERSION=`GH_CODEQL_VERSION=v$SECOND_LATEST gh codeql version --format json | jq -r '.version'`
205216
206-
if [[ $VERSION != "2.7.6" ]]; then
207-
echo "::error::Expected version 2.7.6 but got $VERSION"
217+
if [[ $VERSION != "$SECOND_LATEST" ]]; then
218+
echo "::error::Expected version $SECOND_LATEST but got $VERSION"
208219
exit 1
209220
fi
210221

0 commit comments

Comments
 (0)
0