@@ -20,18 +20,29 @@ jobs:
20
20
uses : actions/checkout@v2
21
21
22
22
- name : Install extension
23
- shell : bash
24
23
run : |
25
24
gh extensions install .
26
25
27
- - name : Check automatically installs latest
26
+ - name : Get recent CLI versions
28
27
shell : bash
29
28
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"
31
35
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 : |
32
43
# Note we need to run a command before trying to parse the output below, or the
33
44
# messages from the download will end up in the JSON that jq tries to parse
34
- gh codeql version
45
+ gh codeql version
35
46
36
47
INSTALLED=`gh codeql version --format json | jq -r '.version'`
37
48
if [[ "v$INSTALLED" != $LATEST ]]; then
43
54
working-directory : test-resources
44
55
shell : bash
45
56
run : |
46
- gh codeql set-version 2.6.1
57
+ gh codeql set-version "$LATEST"
47
58
gh codeql database create -l cpp -s test-repo -c "gcc -o main main.c" test-db
48
59
gh codeql pack install test-pack
49
60
gh codeql database analyze --format=sarif-latest --output=out.sarif test-db test-pack/allExpressions.ql
@@ -57,17 +68,17 @@ jobs:
57
68
shell : bash
58
69
run : |
59
70
# Set the version without a v prefix
60
- gh codeql set-version 2.5.9
71
+ gh codeql set-version "$SECOND_LATEST"
61
72
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"
64
75
exit 1
65
76
fi
66
- gh codeql list-installed | grep v2.5.9
77
+ gh codeql list-installed | grep v$SECOND_LATEST
67
78
68
79
# Set the version with a v prefix
69
80
COUNT_BEFORE=`gh codeql list-installed | wc -l`
70
- gh codeql set-version v2.5.9
81
+ gh codeql set-version v$SECOND_LATEST
71
82
COUNT_AFTER=`gh codeql list-installed | wc -l`
72
83
if [[ $COUNT_BEFORE != $COUNT_BEFORE ]]; then
73
84
echo "::error::Installing an already installed version changed the number of installed versions from $COUNT_BEFORE to $COUNT_AFTER!"
79
90
run : |
80
91
gh codeql set-version latest
81
92
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 "
84
95
exit 1
85
96
fi
86
97
@@ -93,10 +104,10 @@ jobs:
93
104
# Get the latest installed version
94
105
LATEST=`gh codeql version --format json | jq -r '.version'`
95
106
# Set a local version
96
- gh codeql set-local-version 2.5.9
107
+ gh codeql set-local-version $SECOND_LATEST
97
108
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"
100
111
exit 1
101
112
fi
102
113
@@ -124,11 +135,11 @@ jobs:
124
135
# Get the latest installed version
125
136
LATEST=`gh codeql version --format json | jq -r '.version'`
126
137
# Set a local version
127
- gh codeql set-local-version 2.5.9
138
+ gh codeql set-local-version $SECOND_LATEST
128
139
# Unset the local version
129
140
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 "
132
143
exit 1
133
144
fi
134
145
# Disable local version support
@@ -143,20 +154,20 @@ jobs:
143
154
# Get the latest installed version
144
155
LATEST=`gh codeql version --format json | jq -r '.version'`
145
156
# Set a local version
146
- gh codeql set-local-version 2.5.9
157
+ gh codeql set-local-version $SECOND_LATEST
147
158
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"
150
161
exit 1
151
162
fi
152
163
153
164
# Modify the pinned version without using the CLI
154
- echo v2.7.6 > .codeql-version
165
+ echo v$THIRD_LATEST > .codeql-version
155
166
# We run the command twice to prevent cURL output from causing a `jq` parser error.
156
167
gh codeql version
157
168
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"
160
171
exit 1
161
172
fi
162
173
gh codeql unset-local-version
@@ -168,15 +179,15 @@ jobs:
168
179
run : |
169
180
gh codeql set-version latest
170
181
# 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'`
172
183
173
184
# Modify the pinned version without using the CLI
174
- echo v2.7.6 > .codeql-version
185
+ echo v$SECOND_LATEST > .codeql-version
175
186
# We run the command twice to prevent cURL output from causing a `jq` parser error.
176
187
gh codeql version
177
188
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"
180
191
exit 1
181
192
fi
182
193
rm .codeql-version
@@ -200,11 +211,11 @@ jobs:
200
211
# We run the command with a version override twice such that first run will download the CodeQL CLI
201
212
# and the cURL output doesn't confuse the `jq` parser in the second run.
202
213
# 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'`
205
216
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"
208
219
exit 1
209
220
fi
210
221
0 commit comments