Skip to content

Commit db66184

Browse files
Run tests with nightly CLI
1 parent 93e7dae commit db66184

File tree

3 files changed

+47
-10
lines changed

3 files changed

+47
-10
lines changed

.github/workflows/main.yml

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,30 @@ jobs:
5151
name: vscode-codeql-extension
5252
path: artifacts
5353

54+
find-nightly:
55+
name: Find Nightly Release
56+
runs-on: ubuntu-latest
57+
outputs:
58+
url: ${{ steps.get-url.outputs.nightly-url }}
59+
steps:
60+
- name: Get Nightly Release URL
61+
id: get-url
62+
env:
63+
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
64+
shell: bash
65+
# This workflow step gets an unstable testing version of the CodeQL CLI. It should not be used outside of these tests.
66+
run: |
67+
LATEST=`gh api repos/dsp-testing/codeql-cli-nightlies/releases --jq '.[].tag_name' --method GET --raw-field 'per_page=1'`
68+
echo "::set-output name=nightly-url::https://github.com/dsp-testing/codeql-cli-nightlies/releases/download/$LATEST"
69+
5470
test:
5571
name: Test
5672
runs-on: ${{ matrix.os }}
73+
needs: [find-nightly]
5774
strategy:
5875
matrix:
5976
os: [ubuntu-latest, windows-latest]
77+
version: [stable, nightly]
6078
steps:
6179
- name: Checkout
6280
uses: actions/checkout@v2
@@ -89,7 +107,12 @@ jobs:
89107
- name: Install CodeQL
90108
run: |
91109
mkdir codeql-home
92-
curl -L --silent https://github.com/github/codeql-cli-binaries/releases/latest/download/codeql.zip -o codeql-home/codeql.zip
110+
if [ ${{ matrix.version }} = "stable" ]
111+
then
112+
curl -L --silent https://github.com/github/codeql-cli-binaries/releases/latest/download/codeql.zip -o codeql-home/codeql.zip
113+
else
114+
curl -L --silent ${{ needs.find-nightly.outputs.url }}/codeql.zip -o codeql-home/codeql.zip
115+
fi
93116
unzip -q -o codeql-home/codeql.zip -d codeql-home
94117
unzip -q -o codeql-home/codeql.zip codeql/codeql.exe -d codeql-home
95118
rm codeql-home/codeql.zip
@@ -124,12 +147,14 @@ jobs:
124147
cli-test:
125148
name: CLI Test
126149
runs-on: ${{ matrix.os }}
150+
needs: [find-nightly]
127151
strategy:
128152
matrix:
129153
os: [ubuntu-latest, windows-latest]
130-
version: ['v2.2.6', 'v2.3.3', 'v2.4.6', 'v2.5.7']
154+
version: ['v2.2.6', 'v2.3.3', 'v2.4.6', 'v2.5.7', 'nightly']
131155
env:
132156
CLI_VERSION: ${{ matrix.version }}
157+
NIGHTLY_URL: ${{ needs.find-nightly.outputs.url }}
133158
TEST_CODEQL_PATH: '${{ github.workspace }}/codeql'
134159

135160
steps:

extensions/ql-vscode/src/vscode-tests/cli-integration/run-cli.test.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@ describe('Use cli', function() {
2424
}
2525
});
2626

27-
it('should have the correct version of the cli', async () => {
28-
expect(
29-
(await cli.getVersion()).toString()
30-
).to.eq(
31-
new SemVer(process.env.CLI_VERSION || '').toString()
32-
);
33-
});
27+
if (process.env.CLI_VERSION !== 'nightly') {
28+
it('should have the correct version of the cli', async () => {
29+
expect(
30+
(await cli.getVersion()).toString()
31+
).to.eq(
32+
new SemVer(process.env.CLI_VERSION || '').toString()
33+
);
34+
});
35+
}
3436

3537
it('should resolve ram', async () => {
3638
const result = await (cli as any).resolveRam(8192);

extensions/ql-vscode/src/vscode-tests/ensureCli.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,15 @@ import { workspace } from 'vscode';
66

77
/**
88
* This module ensures that the proper CLI is available for tests of the extension.
9-
* There are two environment variables to control this module:
9+
* There are three environment variables to control this module:
1010
*
1111
* - CLI_VERSION: The version of the CLI to install. Defaults to the most recent
1212
* version. Note that for now, we must maintain the default version by hand.
13+
* This may be set to `nightly`, in which case the `NIGHTLY_URL` variable must
14+
* also be set.
15+
*
16+
* - NIGHTLY_URL: The URL for a nightly release of the CodeQL CLI that will be
17+
* used if `CLI_VERSION` is set to `nightly`.
1318
*
1419
* - CLI_BASE_DIR: The base dir where the CLI will be downloaded and unzipped.
1520
* The download location is `${CLI_BASE_DIR}/assets` and the unzip loction is
@@ -133,6 +138,11 @@ export function skipIfNoCodeQL(context: Mocha.Context) {
133138
* Url to download from
134139
*/
135140
function getCliDownloadUrl(assetName: string) {
141+
if (CLI_VERSION === 'nightly') {
142+
if (!process.env.NIGHTLY_URL)
143+
throw new Error('Nightly CLI was specified but no URL to download it from was given!');
144+
return process.env.NIGHTLY_URL + `/${assetName}`;
145+
}
136146
return `https://github.com/github/codeql-cli-binaries/releases/download/${CLI_VERSION}/${assetName}`;
137147
}
138148

0 commit comments

Comments
 (0)