Skip to content

Commit

Permalink
Add ability to persist a score artifact
Browse files Browse the repository at this point in the history
  • Loading branch information
lerebear committed Mar 3, 2024
1 parent eeb5acf commit 2aa924c
Show file tree
Hide file tree
Showing 11 changed files with 105,131 additions and 12,344 deletions.
1 change: 1 addition & 0 deletions .github/linters/.eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ extends:
rules:
{
'camelcase': 'off',
'eslint-comments/no-unlimited-disable': 'off',
'eslint-comments/no-use': 'off',
'eslint-comments/no-unused-disable': 'off',
'i18n-text/no-en': 'off',
Expand Down
37 changes: 37 additions & 0 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,43 @@ describe('action', () => {
)
})

it('skips creating a score artifact by default', async () => {
// Mock the @actions/github context.
Object.defineProperty(github, 'context', {
value: pullRequestEventContext()
})

await main.run()

expect(runMock).toHaveReturned()
expect(setFailedMock).not.toHaveBeenCalled()
expect(infoMock).toHaveBeenCalledWith('Skipping score artifact creation')
})

it("logs that it's creating an artifact when configured to do so", async () => {
// This test does not actually exercise getting to the end of the artifact
// creation process; only that we've started it.

// Mock the @actions/github context.
Object.defineProperty(github, 'context', {
value: pullRequestEventContext()
})

loadConfigurationMock.mockImplementation(() => ({
persistScoreArtifact: true
}))

await main.run()

expect(runMock).toHaveReturned()

// The failure mock actually will be called in this test (due to the
// unmocked call to `fs.mkdirSync`, so we intentionally omit this line
// expect(setFailedMock).not.toHaveBeenCalled()

expect(infoMock).toHaveBeenCalledWith('Creating score artifact')
})

it('runs the workflow sucessfully when optIns configuration is present and the pull request author is in it', async () => {
// Mock the @actions/github context.
Object.defineProperty(github, 'context', {
Expand Down
2 changes: 1 addition & 1 deletion badges/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions dist/config/schema.json

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

Loading

0 comments on commit 2aa924c

Please sign in to comment.