mirror of
https://github.com/wagoid/commitlint-github-action.git
synced 2025-11-07 08:06:54 +00:00
fix: remove output generation
After the CVE-2020-15228 vulnerability, we can't issue commands with sensitive data on this action anymore. Due to that, the JSON output that this action generated was removed.
This commit is contained in:
parent
1128358de3
commit
b674cd3ec4
4 changed files with 0 additions and 134 deletions
|
|
@ -62,14 +62,6 @@ You can see more info about GitHub's default token [here](https://docs.github.co
|
||||||
|
|
||||||
default: `${{ github.token }}`
|
default: `${{ github.token }}`
|
||||||
|
|
||||||
## Outputs
|
|
||||||
|
|
||||||
### `results`
|
|
||||||
|
|
||||||
The error and warning messages for each one of the analyzed commits. This is useful if you want to use the commitlint results in a JSON format in other jobs. See [the documentation](https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#fromjson) on how to read JSON information from outputs.
|
|
||||||
|
|
||||||
Below you can see an example text output together with its corresponding JSON output:
|
|
||||||
|
|
||||||
```
|
```
|
||||||
You have commit messages with errors
|
You have commit messages with errors
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ const lint = require('@commitlint/lint').default
|
||||||
const { format } = require('@commitlint/format')
|
const { format } = require('@commitlint/format')
|
||||||
const load = require('@commitlint/load').default
|
const load = require('@commitlint/load').default
|
||||||
const gitCommits = require('./gitCommits')
|
const gitCommits = require('./gitCommits')
|
||||||
const generateOutputs = require('./generateOutputs')
|
|
||||||
|
|
||||||
const pullRequestEvent = 'pull_request'
|
const pullRequestEvent = 'pull_request'
|
||||||
|
|
||||||
|
|
@ -136,8 +135,6 @@ const showLintResults = async ([from, to]) => {
|
||||||
)
|
)
|
||||||
const formattedResults = formatErrors(lintedCommits)
|
const formattedResults = formatErrors(lintedCommits)
|
||||||
|
|
||||||
generateOutputs(lintedCommits)
|
|
||||||
|
|
||||||
// disable workflow commands
|
// disable workflow commands
|
||||||
const token = uuidv4()
|
const token = uuidv4()
|
||||||
console.log(`::stop-commands::${token}`)
|
console.log(`::stop-commands::${token}`)
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,6 @@ const {
|
||||||
updatePullRequestEnvVars,
|
updatePullRequestEnvVars,
|
||||||
} = require('./testUtils')
|
} = require('./testUtils')
|
||||||
|
|
||||||
const resultsOutputId = 'results'
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
matchers: { contains },
|
matchers: { contains },
|
||||||
} = td
|
} = td
|
||||||
|
|
@ -44,7 +42,6 @@ describe('Commit Linter action', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
core = require('@actions/core')
|
core = require('@actions/core')
|
||||||
td.replace(core, 'getInput')
|
td.replace(core, 'getInput')
|
||||||
td.replace(core, 'setOutput')
|
|
||||||
td.replace(console, 'log')
|
td.replace(console, 'log')
|
||||||
td.replace(console, 'error')
|
td.replace(console, 'error')
|
||||||
td.when(core.getInput('configFile')).thenReturn('./commitlint.config.js')
|
td.when(core.getInput('configFile')).thenReturn('./commitlint.config.js')
|
||||||
|
|
@ -262,7 +259,6 @@ describe('Commit Linter action', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('when there are multiple commits failing in the pull request', () => {
|
describe('when there are multiple commits failing in the pull request', () => {
|
||||||
let expectedResultsOutput
|
|
||||||
const firstMessage = 'wrong message 1'
|
const firstMessage = 'wrong message 1'
|
||||||
const secondMessage = 'wrong message 2'
|
const secondMessage = 'wrong message 2'
|
||||||
|
|
||||||
|
|
@ -285,23 +281,6 @@ describe('Commit Linter action', () => {
|
||||||
data: [first, to].map(sha => ({ sha })),
|
data: [first, to].map(sha => ({ sha })),
|
||||||
})
|
})
|
||||||
td.replace(process, 'cwd', () => cwd)
|
td.replace(process, 'cwd', () => cwd)
|
||||||
|
|
||||||
expectedResultsOutput = [
|
|
||||||
{
|
|
||||||
hash: to,
|
|
||||||
message: secondMessage,
|
|
||||||
valid: false,
|
|
||||||
errors: ['subject may not be empty', 'type may not be empty'],
|
|
||||||
warnings: [],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
hash: first,
|
|
||||||
message: firstMessage,
|
|
||||||
valid: false,
|
|
||||||
errors: ['subject may not be empty', 'type may not be empty'],
|
|
||||||
warnings: [],
|
|
||||||
},
|
|
||||||
]
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should NOT show errors for a message from before the push', async () => {
|
it('should NOT show errors for a message from before the push', async () => {
|
||||||
|
|
@ -323,12 +302,6 @@ describe('Commit Linter action', () => {
|
||||||
|
|
||||||
td.verify(console.error(contains(secondMessage)))
|
td.verify(console.error(contains(secondMessage)))
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should generate a JSON output of the errors', async () => {
|
|
||||||
await runAction()
|
|
||||||
|
|
||||||
td.verify(core.setOutput(resultsOutputId, expectedResultsOutput))
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('when it fails to fetch commits', () => {
|
describe('when it fails to fetch commits', () => {
|
||||||
|
|
@ -392,27 +365,9 @@ describe('Commit Linter action', () => {
|
||||||
|
|
||||||
td.verify(console.log('Lint free! 🎉'))
|
td.verify(console.log('Lint free! 🎉'))
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should generate a JSON output of the messages', async () => {
|
|
||||||
const expectedResultsOutput = [
|
|
||||||
{
|
|
||||||
hash: commitHash,
|
|
||||||
message: 'chore: correct message',
|
|
||||||
valid: true,
|
|
||||||
errors: [],
|
|
||||||
warnings: [],
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
await runAction()
|
|
||||||
|
|
||||||
td.verify(core.setOutput(resultsOutputId, expectedResultsOutput))
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('when all errors are just warnings', () => {
|
describe('when all errors are just warnings', () => {
|
||||||
let expectedResultsOutput
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
cwd = await git.bootstrap('fixtures/conventional')
|
cwd = await git.bootstrap('fixtures/conventional')
|
||||||
await gitEmptyCommit(cwd, 'chore: previous commit')
|
await gitEmptyCommit(cwd, 'chore: previous commit')
|
||||||
|
|
@ -426,24 +381,6 @@ describe('Commit Linter action', () => {
|
||||||
updatePushEnvVars(cwd, to)
|
updatePushEnvVars(cwd, to)
|
||||||
td.replace(process, 'cwd', () => cwd)
|
td.replace(process, 'cwd', () => cwd)
|
||||||
td.replace(console, 'log')
|
td.replace(console, 'log')
|
||||||
|
|
||||||
expectedResultsOutput = [
|
|
||||||
{
|
|
||||||
hash: to,
|
|
||||||
message:
|
|
||||||
'chore: correct message\n\nsome context without leading blank line',
|
|
||||||
valid: true,
|
|
||||||
errors: [],
|
|
||||||
warnings: ['body must have leading blank line'],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
hash: from,
|
|
||||||
message: 'chore: correct message with no warnings',
|
|
||||||
valid: true,
|
|
||||||
errors: [],
|
|
||||||
warnings: [],
|
|
||||||
},
|
|
||||||
]
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should pass and show that warnings exist', async () => {
|
it('should pass and show that warnings exist', async () => {
|
||||||
|
|
@ -453,12 +390,6 @@ describe('Commit Linter action', () => {
|
||||||
td.verify(console.log(contains('You have commit messages with warnings')))
|
td.verify(console.log(contains('You have commit messages with warnings')))
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should show the results in an output', async () => {
|
|
||||||
await runAction()
|
|
||||||
|
|
||||||
td.verify(core.setOutput(resultsOutputId, expectedResultsOutput))
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('and failOnWarnings is set to true', () => {
|
describe('and failOnWarnings is set to true', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
td.when(core.getInput('failOnWarnings')).thenReturn('true')
|
td.when(core.getInput('failOnWarnings')).thenReturn('true')
|
||||||
|
|
@ -471,12 +402,6 @@ describe('Commit Linter action', () => {
|
||||||
console.error(contains('You have commit messages with errors')),
|
console.error(contains('You have commit messages with errors')),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should show the results in an output', async () => {
|
|
||||||
await runAction()
|
|
||||||
|
|
||||||
td.verify(core.setOutput(resultsOutputId, expectedResultsOutput))
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -507,30 +432,6 @@ describe('Commit Linter action', () => {
|
||||||
td.verify(console.error(contains('You have commit messages with errors')))
|
td.verify(console.error(contains('You have commit messages with errors')))
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should show the results in an output', async () => {
|
|
||||||
const expectedResultsOutput = [
|
|
||||||
{
|
|
||||||
hash: secondHash,
|
|
||||||
message: 'wrong message',
|
|
||||||
valid: false,
|
|
||||||
errors: ['subject may not be empty', 'type may not be empty'],
|
|
||||||
warnings: [],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
hash: firstHash,
|
|
||||||
message:
|
|
||||||
'chore: correct message\n\nsome context without leading blank line',
|
|
||||||
valid: true,
|
|
||||||
errors: [],
|
|
||||||
warnings: ['body must have leading blank line'],
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
await runAction()
|
|
||||||
|
|
||||||
td.verify(core.setOutput(resultsOutputId, expectedResultsOutput))
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('and failOnWarnings is set to true', () => {
|
describe('and failOnWarnings is set to true', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
td.when(core.getInput('failOnWarnings')).thenReturn('true')
|
td.when(core.getInput('failOnWarnings')).thenReturn('true')
|
||||||
|
|
|
||||||
|
|
@ -1,24 +0,0 @@
|
||||||
const core = require('@actions/core')
|
|
||||||
|
|
||||||
const resultsOutputId = 'results'
|
|
||||||
|
|
||||||
const mapMessageValidation = item => item.message
|
|
||||||
|
|
||||||
const mapResultOutput = ({
|
|
||||||
hash,
|
|
||||||
lintResult: { valid, errors, warnings, input },
|
|
||||||
}) => ({
|
|
||||||
hash,
|
|
||||||
message: input,
|
|
||||||
valid,
|
|
||||||
errors: errors.map(mapMessageValidation),
|
|
||||||
warnings: warnings.map(mapMessageValidation),
|
|
||||||
})
|
|
||||||
|
|
||||||
const generateOutputs = lintedCommits => {
|
|
||||||
const resultsOutput = lintedCommits.map(mapResultOutput)
|
|
||||||
|
|
||||||
core.setOutput(resultsOutputId, resultsOutput)
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = generateOutputs
|
|
||||||
Loading…
Reference in a new issue