Permalink
Cannot retrieve contributors at this time
39 lines (31 sloc)
1010 Bytes
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
codeql-action/.github/actions/check-codescanning-config/index.ts
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} | |
} |