Skip to content

Commit 62097bc

Browse files
committed
Add packs and queries from input
This commit adds the packs and queries from the actions input to the config file used by the CodeQL CLI. When the `+` is used, the actions input value is combined with the config value and when it is not used, the input value overrides the config value. This commit also adds a bunch of integration tests for this feature. In order to avoid adding too many new jobs, all of the tests are run sequentially in a single job (matrixed across relevant operating systems and OSes).
1 parent 237260b commit 62097bc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+2085
-209
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Check Code-Scanning Config
2+
description: |
3+
Checks the code scanning configuration file generated by the
4+
action to ensure it contains the expected contents
5+
inputs:
6+
languages:
7+
required: false
8+
description: The languages field passed to the init action.
9+
10+
packs:
11+
required: false
12+
description: The packs field passed to the init action.
13+
14+
queries:
15+
required: false
16+
description: The queries field passed to the init action.
17+
18+
config-file-test:
19+
required: false
20+
description: |
21+
The location of the config file to use. If empty,
22+
then no config file is used.
23+
24+
expected-config-file-contents:
25+
required: true
26+
description: |
27+
A JSON string containing the exact contents of the config file.
28+
29+
tools:
30+
required: true
31+
description: |
32+
The url of codeql to use.
33+
34+
runs:
35+
using: composite
36+
steps:
37+
- uses: ./../action/init
38+
with:
39+
languages: ${{ inputs.languages }}
40+
config-file: ${{ inputs.config-file-test }}
41+
queries: ${{ inputs.queries }}
42+
packs: ${{ inputs.packs }}
43+
tools: ${{ inputs.tools }}
44+
db-location: ${{ runner.temp }}/codescanning-config-cli-test
45+
46+
- name: Install dependencies
47+
shell: bash
48+
run: npm install --location=global ts-node js-yaml
49+
50+
- name: Check config
51+
working-directory: ${{ github.action_path }}
52+
shell: bash
53+
run: ts-node ./index.ts "${{ runner.temp }}/user-config.yaml" '${{ inputs.expected-config-file-contents }}'
54+
55+
- name: Clean up
56+
shell: bash
57+
if: always()
58+
run: |
59+
rm -rf ${{ runner.temp }}/codescanning-config-cli-test
60+
rm -rf ${{ runner.temp }}/user-config.yaml
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
2+
import * as core from '@actions/core'
3+
import * as yaml from 'js-yaml'
4+
import * as fs from 'fs'
5+
import * as assert from 'assert'
6+
7+
const actualConfig = loadActualConfig()
8+
9+
const rawExpectedConfig = process.argv[3].trim()
10+
if (!rawExpectedConfig) {
11+
core.info('No expected configuration provided')
12+
} else {
13+
core.startGroup('Expected generated user config')
14+
core.info(yaml.dump(JSON.parse(rawExpectedConfig)))
15+
core.endGroup()
16+
}
17+
18+
const expectedConfig = rawExpectedConfig ? JSON.parse(rawExpectedConfig) : undefined;
19+
20+
assert.deepStrictEqual(
21+
actualConfig,
22+
expectedConfig,
23+
'Expected configuration does not match actual configuration'
24+
);
25+
26+
27+
function loadActualConfig() {
28+
if (!fs.existsSync(process.argv[2])) {
29+
core.info('No configuration file found')
30+
return undefined
31+
} else {
32+
const rawActualConfig = fs.readFileSync(process.argv[2], 'utf8')
33+
core.startGroup('Actual generated user config')
34+
core.info(rawActualConfig)
35+
core.endGroup()
36+
37+
return yaml.load(rawActualConfig)
38+
}
39+
}

.github/query-filter-test/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,4 @@ runs:
4949
queries-not-run: ${{ inputs.queries-not-run}}
5050
- name: Cleanup after test
5151
shell: bash
52-
run: rm -rf "$RUNNER_TEMP/results" "$RUNNER_TEMP//query-filter-test"
52+
run: rm -rf "$RUNNER_TEMP/results" "$RUNNER_TEMP/query-filter-test"

.github/workflows/__ml-powered-queries.yml

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

.github/workflows/__packaging-codescanning-config-inputs-js.yml

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

.github/workflows/__packaging-config-inputs-js.yml

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

.github/workflows/__packaging-config-js.yml

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

.github/workflows/__packaging-inputs-js.yml

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

.github/workflows/__split-workflow.yml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy