Skip to content

Commit f8ccf38

Browse files
committed
PR check: Check toolcache empty at start
1 parent 8c0517f commit f8ccf38

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

.github/workflows/__extract-direct-to-toolcache.yml

Lines changed: 12 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pr-checks/checks/extract-direct-to-toolcache.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,18 @@ steps:
1717
const path = require('path');
1818
const codeqlPath = path.join(process.env['RUNNER_TOOL_CACHE'], 'CodeQL');
1919
fs.rmdirSync(codeqlPath, { recursive: true });
20+
- name: Install @actions/tool-cache
21+
run: npm install @actions/tool-cache
22+
- name: Check toolcache does not contain CodeQL
23+
uses: actions/github-script@v7
24+
with:
25+
script: |
26+
const toolcache = require('@actions/tool-cache');
27+
const allCodeqlVersions = toolcache.findAllVersions('CodeQL');
28+
if (allCodeqlVersions.length !== 0) {
29+
throw new Error(`CodeQL should not be found in the toolcache, but found ${allCodeqlVersions}`);
30+
}
31+
console.log('No versions of CodeQL found in the toolcache');
2032
- id: init
2133
uses: ./../action/init
2234
with:
@@ -26,8 +38,6 @@ steps:
2638
with:
2739
output: ${{ runner.temp }}/results
2840
upload-database: false
29-
- name: Install @actions/tool-cache
30-
run: npm install @actions/tool-cache
3141
- name: Check CodeQL is installed within the toolcache
3242
uses: actions/github-script@v7
3343
with:
@@ -41,4 +51,3 @@ steps:
4151
if (allCodeqlVersions.length > 1) {
4252
throw new Error('Multiple CodeQL versions found in toolcache');
4353
}
44-
console.log(`CodeQL version: ${allCodeqlVersions[0]}`);

0 commit comments

Comments
 (0)