Skip to content

Commit

Permalink
chore: fix CI which has been broken since v2 release (#848)
Browse files Browse the repository at this point in the history
* chore: fix CI which has been broken since v2 release

* chore: add copy of update-dist.yml to see if this fixes

* nit: fix linter warning in main

* test: fix the configPath mocking

* test: add more mocked input into the test

* test: make repro more consistent with dependabot CI

* fix: found a way to default the config path

* chore: sync the dependency update to the /dist dir

* chore: remove the repro CI workflow

---------

Co-authored-by: GitHub Action <[email protected]>
  • Loading branch information
myyk and actions-user authored Oct 16, 2023
1 parent d356e68 commit abc8f0e
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 8 deletions.
13 changes: 12 additions & 1 deletion __tests__/main.test.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
import * as core from '@actions/core'
import * as github from '@actions/github'
import {GitHub} from '@actions/github/lib/utils'
import {run} from '../src/main'

// Inputs for mock @actions/core
let inputs = {
token: process.env['INPUT_TOKEN'],
repository: 'myyk/git-democracy',
} as any

test('test runs', () => {
// make sure to run with `INPUT_TOKEN=your-token yarn run test`
// Example on mocking patterns: https://github.com/actions/checkout/blob/master/__test__/input-helper.test.ts
process.env['INPUT_REPOSITORY'] = 'myyk/git-democracy'

const octokit = new GitHub({
auth: process.env['INPUT_TOKEN'] as string
})

// Mock getInput
jest.spyOn(core, 'getInput').mockImplementation((name: string) => {
return inputs[name]
})

// Mock github context
jest.spyOn(github.context, 'issue', 'get').mockImplementation(() => {
return {
Expand Down
10 changes: 8 additions & 2 deletions 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.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"format-check": "prettier --check **/*.ts",
"lint": "eslint src/**/*.ts",
"package": "ncc build --source-map --license licenses.txt",
"test": "jest",
"test": "GITHUB_REPOSITORY=myyk/git-democracy jest",
"all": "npm run build && npm run format && npm run lint && npm run package && npm test"
},
"repository": {
Expand Down
12 changes: 9 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@ export async function run(): Promise<void> {
}
core.info(`Inputs: ${inspect(inputs)}`)

if (!inputs.configPath) {
// TODO: Please someone help me understand why this was the only way to get this default to work
inputs.configPath = './.github/workflows'
}

const [owner, repo] = inputs.repository.split('/')
core.info(`repository: ${owner}/${repo}`)

Expand Down Expand Up @@ -242,7 +247,8 @@ export async function run(): Promise<void> {

try {
run()
} catch (error: any) {
core.error(error.stack)
core.setFailed(`error while running action: ${error}`)
} catch (error: unknown) {
const err = error as Error
core.error(err.stack ?? 'Unknown error occurred')
core.setFailed(`error while running action: ${err}`)
}

0 comments on commit abc8f0e

Please sign in to comment.