Skip to content

Commit

Permalink
colors in debug results of 'prechecks'
Browse files Browse the repository at this point in the history
  • Loading branch information
GrantBirki committed Aug 17, 2023
1 parent 521c02a commit 028782a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
10 changes: 6 additions & 4 deletions __tests__/functions/prechecks.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import {prechecks} from '../../src/functions/prechecks'
import {COLORS} from '../../src/functions/colors'
import * as isAdmin from '../../src/functions/admin'
import * as core from '@actions/core'

// Globals for testing
const infoMock = jest.spyOn(core, 'info')
const warningMock = jest.spyOn(core, 'warning')
const debugMock = jest.spyOn(core, 'debug')

var environmentObj
var help_trigger
Expand Down Expand Up @@ -218,8 +220,8 @@ test('runs prechecks and finds that the IssueOps command is valid without define
ref: 'test-ref',
sha: 'abc123'
})
expect(infoMock).toHaveBeenCalledWith(
"Could not retrieve PR commit status: TypeError: Cannot read properties of undefined (reading 'nodes') - Handled: OK"
expect(debugMock).toHaveBeenCalledWith(
`could not retrieve PR commit status: TypeError: Cannot read properties of undefined (reading 'nodes') - Handled: ${COLORS.success}OK`
)
expect(infoMock).toHaveBeenCalledWith(
'Skipping commit status check and proceeding...'
Expand Down Expand Up @@ -317,8 +319,8 @@ test('runs prechecks and finds that reviews and CI checks have not been defined'
ref: 'test-ref',
sha: 'abc123'
})
expect(infoMock).toHaveBeenCalledWith(
"Could not retrieve PR commit status: TypeError: Cannot read properties of undefined (reading 'nodes') - Handled: OK"
expect(debugMock).toHaveBeenCalledWith(
`could not retrieve PR commit status: TypeError: Cannot read properties of undefined (reading 'nodes') - Handled: ${COLORS.success}OK`
)
expect(infoMock).toHaveBeenCalledWith(
'Skipping commit status check and proceeding...'
Expand Down
5 changes: 4 additions & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion src/functions/prechecks.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as core from '@actions/core'
import {validPermissions} from './valid-permissions'
import {isAdmin} from './admin'
import {stringToArray} from './string-to-array'
import {COLORS} from './colors'

// Runs precheck logic before the branch deployment can proceed
// :param comment: The comment body of the event
Expand Down Expand Up @@ -214,7 +215,9 @@ export async function prechecks(
.state
}
} catch (e) {
core.info(`Could not retrieve PR commit status: ${e} - Handled: OK`)
core.debug(
`could not retrieve PR commit status: ${e} - Handled: ${COLORS.success}OK`
)
core.info('Skipping commit status check and proceeding...')
commitStatus = null

Expand Down

0 comments on commit 028782a

Please sign in to comment.