mirror of
https://github.com/github/codeql-action.git
synced 2025-12-27 09:40:17 +08:00
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).
40 lines
1010 B
TypeScript
40 lines
1010 B
TypeScript
|
|
import * as core from '@actions/core'
|
|
import * as yaml from 'js-yaml'
|
|
import * as fs from 'fs'
|
|
import * as assert from 'assert'
|
|
|
|
const actualConfig = loadActualConfig()
|
|
|
|
const rawExpectedConfig = process.argv[3].trim()
|
|
if (!rawExpectedConfig) {
|
|
core.info('No expected configuration provided')
|
|
} else {
|
|
core.startGroup('Expected generated user config')
|
|
core.info(yaml.dump(JSON.parse(rawExpectedConfig)))
|
|
core.endGroup()
|
|
}
|
|
|
|
const expectedConfig = rawExpectedConfig ? JSON.parse(rawExpectedConfig) : undefined;
|
|
|
|
assert.deepStrictEqual(
|
|
actualConfig,
|
|
expectedConfig,
|
|
'Expected configuration does not match actual configuration'
|
|
);
|
|
|
|
|
|
function loadActualConfig() {
|
|
if (!fs.existsSync(process.argv[2])) {
|
|
core.info('No configuration file found')
|
|
return undefined
|
|
} else {
|
|
const rawActualConfig = fs.readFileSync(process.argv[2], 'utf8')
|
|
core.startGroup('Actual generated user config')
|
|
core.info(rawActualConfig)
|
|
core.endGroup()
|
|
|
|
return yaml.load(rawActualConfig)
|
|
}
|
|
}
|