Skip to content

Commit 680d08e

Browse files
authored
Merge pull request #1105 from github/aeisenberg/fix-config-files
Re-enable passing the codescanning config file to the CLI
2 parents 5836ad9 + fa2bc21 commit 680d08e

Some content is hidden

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

56 files changed

+2313
-312
lines changed

Diff for: .github/check-codescanning-config/action.yml

+60
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

Diff for: .github/check-codescanning-config/index.ts

+39
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+
}

Diff for: .github/query-filter-test/action.yml

+1-1
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"

Diff for: .github/workflows/__ml-powered-queries.yml

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .github/workflows/__packaging-codescanning-config-inputs-js.yml

+100
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .github/workflows/__packaging-config-inputs-js.yml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .github/workflows/__packaging-config-js.yml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .github/workflows/__packaging-inputs-js.yml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .github/workflows/__split-workflow.yml

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)