Skip to content

Commit

Permalink
fix: remove output generation
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
wagoid committed Jan 28, 2021
1 parent 1128358 commit b674cd3
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 134 deletions.
8 changes: 0 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,6 @@ You can see more info about GitHub's default token [here](https://docs.github.co

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
Expand Down
3 changes: 0 additions & 3 deletions src/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const lint = require('@commitlint/lint').default
const { format } = require('@commitlint/format')
const load = require('@commitlint/load').default
const gitCommits = require('./gitCommits')
const generateOutputs = require('./generateOutputs')

const pullRequestEvent = 'pull_request'

Expand Down Expand Up @@ -136,8 +135,6 @@ const showLintResults = async ([from, to]) => {
)
const formattedResults = formatErrors(lintedCommits)

generateOutputs(lintedCommits)

// disable workflow commands
const token = uuidv4()
console.log(`::stop-commands::${token}`)
Expand Down
99 changes: 0 additions & 99 deletions src/action.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ const {
updatePullRequestEnvVars,
} = require('./testUtils')

const resultsOutputId = 'results'

const {
matchers: { contains },
} = td
Expand Down Expand Up @@ -44,7 +42,6 @@ describe('Commit Linter action', () => {
beforeEach(() => {
core = require('@actions/core')
td.replace(core, 'getInput')
td.replace(core, 'setOutput')
td.replace(console, 'log')
td.replace(console, 'error')
td.when(core.getInput('configFile')).thenReturn('./commitlint.config.js')
Expand Down Expand Up @@ -262,7 +259,6 @@ describe('Commit Linter action', () => {
})

describe('when there are multiple commits failing in the pull request', () => {
let expectedResultsOutput
const firstMessage = 'wrong message 1'
const secondMessage = 'wrong message 2'

Expand All @@ -285,23 +281,6 @@ describe('Commit Linter action', () => {
data: [first, to].map(sha => ({ sha })),
})
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 () => {
Expand All @@ -323,12 +302,6 @@ describe('Commit Linter action', () => {

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', () => {
Expand Down Expand Up @@ -392,27 +365,9 @@ describe('Commit Linter action', () => {

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', () => {
let expectedResultsOutput

beforeEach(async () => {
cwd = await git.bootstrap('fixtures/conventional')
await gitEmptyCommit(cwd, 'chore: previous commit')
Expand All @@ -426,24 +381,6 @@ describe('Commit Linter action', () => {
updatePushEnvVars(cwd, to)
td.replace(process, 'cwd', () => cwd)
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 () => {
Expand All @@ -453,12 +390,6 @@ describe('Commit Linter action', () => {
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', () => {
beforeEach(() => {
td.when(core.getInput('failOnWarnings')).thenReturn('true')
Expand All @@ -471,12 +402,6 @@ describe('Commit Linter action', () => {
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))
})
})
})

Expand Down Expand Up @@ -507,30 +432,6 @@ describe('Commit Linter action', () => {
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', () => {
beforeEach(() => {
td.when(core.getInput('failOnWarnings')).thenReturn('true')
Expand Down
24 changes: 0 additions & 24 deletions src/generateOutputs.js

This file was deleted.

0 comments on commit b674cd3

Please sign in to comment.