Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dont force repo #125

Merged
merged 4 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 63 additions & 1 deletion __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@
const newConf: IMainConfig = MockMain.getTestConf(
main.config0 as IMainConfig
)
Object.assign(main.config0!, newConf)

Check warning on line 85 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Forbidden non-null assertion

Check warning on line 85 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

Forbidden non-null assertion
const myFile: string | undefined = main.config0!.inputJsonFilename

Check warning on line 86 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Forbidden non-null assertion

Check warning on line 86 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

Forbidden non-null assertion

// eslint-disable-next-line github/no-then
const hsaErr = await run().then(
Expand All @@ -106,6 +106,68 @@
expect(errorMock).not.toHaveBeenCalled()
}, 10000)

it('works with multiple repo ids', async () => {
// Set the action's inputs as return values from core.getInput()
getInputMock.mockImplementation(name => {
switch (name) {
case 'WORKSPACE_ID':
return '5e3018c2d1'
case 'REPO_ID':
return '500,501'
case 'FROM_PIPELINE':
return 'My from'
case 'TO_PIPELINE':
return 'My to'
case 'FROM_DATE':
return ''
case 'TO_DATE':
return ''
default:
return ''
}
})

main.init()

expect(getInputMock).toHaveBeenNthCalledWith(4, 'WORKSPACE_ID')
expect(getInputMock).toHaveBeenNthCalledWith(3, 'REPO_ID')
expect(getInputMock).toHaveBeenNthCalledWith(2, 'FROM_DATE')
expect(getInputMock).toHaveBeenNthCalledWith(1, 'TO_DATE')

const newConf: IMainConfig = MockMain.getTestConf(
main.config0 as IMainConfig
)
Object.assign(main.config0!, newConf)

Check warning on line 140 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Forbidden non-null assertion

Check warning on line 140 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

Forbidden non-null assertion
const myFile: string | undefined = main.config0!.inputJsonFilename

Check warning on line 141 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Forbidden non-null assertion

Check warning on line 141 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

Forbidden non-null assertion

// eslint-disable-next-line github/no-then
const hsaErr = await run().then(
() => false,
() => {
return true
}
)
expect(hsaErr).toBeFalsy()
expect(runMock).toHaveReturned()

// Verify that all of the core library functions were called correctly
expect(debugMock).toHaveBeenNthCalledWith(1, `Got file ${myFile}`)

expect(setOutputMock).toHaveBeenNthCalledWith(
1,
'markdownContent',
expect.stringMatching(/.+/)
)
expect(errorMock).not.toHaveBeenCalled()

expect(JSON.stringify(main.config0?.includeRepos)).toEqual(
JSON.stringify([500, 501])
)
expect(JSON.stringify(newConf.includeRepos)).toEqual(
JSON.stringify([500, 501])
)
}, 10000)

it('bad workspace id', async () => {
// Set the action's inputs as return values from core.getInput()
getInputMock.mockImplementation((name: string) => {
Expand Down Expand Up @@ -197,7 +259,7 @@
// Verify that all the core library functions were called correctly
expect(setFailedMock).toHaveBeenNthCalledWith(
1,
`Need to export WORKSPACE_ID (${WORKSPACE_ID}) and REPO_ID (${REPO_ID}) (${FROM_PIPELINE})`
`Need to export WORKSPACE_ID (${WORKSPACE_ID}) (${FROM_PIPELINE})`
)
expect(errorMock).not.toHaveBeenCalled()
}, 10000)
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ inputs:
required: true
REPO_ID:
description: 'Your github repo ID'
required: true
required: false
FROM_PIPELINE:
description: 'Zenhub start pipeline'
required: true
Expand Down
4 changes: 2 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.

4 changes: 2 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ class Main implements IMain {
const repoId = core.getInput('REPO_ID')
const workspaceId =
core.getInput('WORKSPACE_ID') || process.env.WORKSPACE_ID
if (!workspaceId || !repoId) {
const errMsg = `Need to export WORKSPACE_ID (${workspaceId || ''}) and REPO_ID (${repoId}) (${core.getInput('FROM_PIPELINE')})`
if (!workspaceId) {
const errMsg = `Need to export WORKSPACE_ID (${workspaceId || ''}) (${core.getInput('FROM_PIPELINE')})`
console.error(errMsg)
throw new Error(errMsg)
}
Expand Down
Loading