You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Tests fail if you execute them locally with yarn test without having any committer configuration in your Git configuration. If you remove these lines from your global git config:
[user]
name = Your Name
email = Your Email
signingkey = XXXX
You will see these errors:
Summary of all failing tests
FAIL __tests__/e2e/main.test.ts (11.704 s)
● GitHub Action › should create a new job
expect(received).toBe(expected) // Object.is equality
Expected: "true"
Received: undefined
124 | const output = executeAction(env)
125 |
> 126 | expect(getOutputVariable('job_created', output.toString())).toBe('true')
| ^
127 | expect(getOutputVariable('job_commit', output.toString())).toBe(
128 | getLatestCommitHash(gitRepo.getDir()).getHash()
129 | )
at __tests__/e2e/main.test.ts:126:65
at fulfilled (__tests__/e2e/main.test.ts:28:58)
● GitHub Action › should get the next job
expect(received).toBe(expected) // Object.is equality
Expected: "test"
Received: undefined
145 | const output = executeAction(env)
146 |
> 147 | expect(getOutputVariable('job_payload', output.toString())).toBe(
| ^
148 | dummyPayload()
149 | )
150 | expect(getOutputVariable('job_commit', output.toString())).toBe(
at __tests__/e2e/main.test.ts:147:65
at fulfilled (__tests__/e2e/main.test.ts:28:58)
● GitHub Action › should mark the pending job as started
expect(received).toBe(expected) // Object.is equality
Expected: "true"
Received: undefined
169 | const output = executeAction(env)
170 |
> 171 | expect(getOutputVariable('job_started', output.toString())).toBe('true')
| ^
172 | expect(getOutputVariable('job_commit', output.toString())).toBe(
173 | getLatestCommitHash(gitRepo.getDir()).getHash()
174 | )
at __tests__/e2e/main.test.ts:171:65
at fulfilled (__tests__/e2e/main.test.ts:28:58)
● GitHub Action › should mark the pending job as finished
expect(received).toBe(expected) // Object.is equality
Expected: "true"
Received: undefined
198 | })
199 |
> 200 | expect(getOutputVariable('job_finished', output.toString())).toBe('true')
| ^
201 | expect(getOutputVariable('job_commit', output.toString())).toBe(
202 | getLatestCommitHash(gitRepo.getDir()).getHash()
203 | )
at __tests__/e2e/main.test.ts:200:66
at fulfilled (__tests__/e2e/main.test.ts:28:58)
● GitHub Action › should allow to overwrite commit signing key
Command failed: git log --show-signature -n1
fatal: your current branch 'main' does not have any commits yet
88 | export function gitLogForLatestCommit(gitRepoDir: string): string {
89 | const output = cp
> 90 | .execFileSync('git', ['log', '--show-signature', '-n1'], {
| ^
91 | cwd: gitRepoDir
92 | })
93 | .toString()
at gitLogForLatestCommit (src/__tests__/helpers.ts:90:6)
at __tests__/e2e/main.test.ts:224:47
at fulfilled (__tests__/e2e/main.test.ts:28:58)
● GitHub Action › should allow to disable commit signing for a given commit
Command failed: git log --show-signature -n1
fatal: your current branch 'main' does not have any commits yet
88 | export function gitLogForLatestCommit(gitRepoDir: string): string {
89 | const output = cp
> 90 | .execFileSync('git', ['log', '--show-signature', '-n1'], {
| ^
91 | cwd: gitRepoDir
92 | })
93 | .toString()
at gitLogForLatestCommit (src/__tests__/helpers.ts:90:6)
at __tests__/e2e/main.test.ts:243:47
at fulfilled (__tests__/e2e/main.test.ts:28:58)
● GitHub Action › should always overwrite the commit author with: NautilusCyberneering[bot] <bot@nautilus-cyberneering.de>
Command failed: git log --show-signature -n1
fatal: your current branch 'main' does not have any commits yet
88 | export function gitLogForLatestCommit(gitRepoDir: string): string {
89 | const output = cp
> 90 | .execFileSync('git', ['log', '--show-signature', '-n1'], {
| ^
91 | cwd: gitRepoDir
92 | })
93 | .toString()
at gitLogForLatestCommit (src/__tests__/helpers.ts:90:6)
at __tests__/e2e/main.test.ts:259:47
at fulfilled (__tests__/e2e/main.test.ts:28:58)
Test Suites: 1 failed, 20 passed, 21 total
Tests: 7 failed, 117 passed, 124 total
I think this is related to #175. Tests should set up the configuration they need and not rely on preexisting configurations.
Probably, Git is failing to create the new commits because of the "unknown identify" error.
This error could be also related to this issue. From the tests output, you cannot know the problem was the missing committer configuration. But it's only because jest hides the action output. The tests are failing in the "assert" (when we get info of the latest commit) step instead of in the "commit" step.
Maybe the problem is the function executeAction captures the error and it returns a string anyway.
it('should return an error for invalid actions',async()=>{constgitRepo=awaitcreateInitializedGitRepo()constenv={
...process.env,INPUT_QUEUE_NAME: 'queue-name',INPUT_GIT_REPO_DIR: gitRepo.getDirPath(),INPUT_ACTION: 'INVALID ACTION',INPUT_JOB_PAYLOAD: dummyPayload(),INPUT_GIT_COMMIT_NO_GPG_SIGN: true}constoutput=executeAction(env)expect(output).toEqual(expect.stringContaining('::error::Invalid action. Actions can only be: create-job, next-job, start-job, finish-job'))})
It's the only case when we need to capture the exception. I suppose the obvious solution is to move the try/catch to that test, for the time being. If we have more cases wher<e we need to capture the exception we can implement a different function like expectActionExcetutionToThrowError(...).
The text was updated successfully, but these errors were encountered:
From: #201 (comment)
Tests fail if you execute them locally with
yarn test
without having any committer configuration in your Git configuration. If you remove these lines from your global git config:You will see these errors:
I think this is related to #175. Tests should set up the configuration they need and not rely on preexisting configurations.
Probably, Git is failing to create the new commits because of the "unknown identify" error.
This error could be also related to this issue. From the tests output, you cannot know the problem was the missing committer configuration. But it's only because
jest
hides the action output. The tests are failing in the "assert" (when we get info of the latest commit) step instead of in the "commit" step.Maybe the problem is the function
executeAction
captures the error and it returns a string anyway.I think I did that because of this test:
It's the only case when we need to capture the exception. I suppose the obvious solution is to move the try/catch to that test, for the time being. If we have more cases wher<e we need to capture the exception we can implement a different function like
expectActionExcetutionToThrowError(...)
.The text was updated successfully, but these errors were encountered: