From 9b747f6421c5a092b5c253f229edb9a4a396776a Mon Sep 17 00:00:00 2001 From: Jose Celano Date: Tue, 7 Jun 2022 10:11:16 +0100 Subject: [PATCH] fix: [#219] setup committer identity for e2e tests --- .github/workflows/test.yml | 5 ----- __tests__/e2e/main.test.ts | 19 ++++++++++++++++++- src/__tests__/inputs-builder.ts | 5 +++++ 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bdd32a5..7bc6f09 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,11 +27,6 @@ jobs: with: fetch-depth: 0 - - name: Set up git committer identity - run: | - git config --global user.name 'github-actions[bot]' - git config --global user.email 'github-actions[bot]@users.noreply.github.com' - - name: Install run: yarn install diff --git a/__tests__/e2e/main.test.ts b/__tests__/e2e/main.test.ts index 5918320..410ddef 100644 --- a/__tests__/e2e/main.test.ts +++ b/__tests__/e2e/main.test.ts @@ -35,9 +35,17 @@ function executeAction(env): string | Buffer { return output } +function committerIdentity(): object { + return { + GIT_COMMITTER_NAME: 'A Committer', + GIT_COMMITTER_EMAIL: 'committer@example.com' + } +} + function createSampleJob(gitRepo: GitRepo, payload: String): string | Buffer { return executeAction({ ...process.env, + ...committerIdentity(), INPUT_QUEUE_NAME: 'queue-name', INPUT_GIT_REPO_DIR: gitRepo.getDirPath(), INPUT_ACTION: 'create-job', @@ -63,6 +71,7 @@ function startSampleJob( ): string | Buffer { return executeAction({ ...process.env, + ...committerIdentity(), INPUT_QUEUE_NAME: 'queue-name', INPUT_GIT_REPO_DIR: gitRepo.getDirPath(), INPUT_ACTION: 'start-job', @@ -79,6 +88,7 @@ function finishSampleJob( ): string | Buffer { return executeAction({ ...process.env, + ...committerIdentity(), INPUT_QUEUE_NAME: 'queue-name', INPUT_GIT_REPO_DIR: gitRepo.getDirPath(), INPUT_ACTION: 'finish-job', @@ -221,6 +231,7 @@ describe('GitHub Action', () => { const env = { ...process.env, + ...committerIdentity(), INPUT_QUEUE_NAME: 'queue-name', INPUT_GIT_REPO_DIR: gitRepo.getDirPath(), INPUT_ACTION: 'create-job', @@ -240,11 +251,13 @@ describe('GitHub Action', () => { it('should allow to disable commit signing for a given commit', async () => { const inputs = await InputsBuilder.instance() + .forDefaultAction() .withNoGpgSignature() .buildInputs() const env = { ...process.env, + ...committerIdentity(), ...inputs } @@ -257,10 +270,14 @@ describe('GitHub Action', () => { }) it('should always overwrite the commit author with: NautilusCyberneering[bot] ', async () => { - const defaultInputs = await InputsBuilder.instance().buildInputs() + const defaultInputs = await InputsBuilder.instance() + .forDefaultAction() + .withNoGpgSignature() + .buildInputs() const env = { ...process.env, + ...committerIdentity(), ...defaultInputs } diff --git a/src/__tests__/inputs-builder.ts b/src/__tests__/inputs-builder.ts index 05b41db..faadc45 100644 --- a/src/__tests__/inputs-builder.ts +++ b/src/__tests__/inputs-builder.ts @@ -36,6 +36,11 @@ export class InputsBuilder { return this } + forDefaultAction(): InputsBuilder { + this.action = DEFAULT_ACTION + return this + } + async buildInputs(): Promise { if (this.queueName === null) { this.queueName = DEFAULT_QUEUE_NAME