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

Setup committer identity for e2e tests #257

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
5 changes: 0 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
19 changes: 18 additions & 1 deletion __tests__/e2e/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand Down Expand Up @@ -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',
Expand All @@ -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
}

Expand All @@ -257,10 +270,14 @@ describe('GitHub Action', () => {
})

it('should always overwrite the commit author with: NautilusCyberneering[bot] <bot@nautilus-cyberneering.de>', async () => {
const defaultInputs = await InputsBuilder.instance().buildInputs()
const defaultInputs = await InputsBuilder.instance()
.forDefaultAction()
.withNoGpgSignature()
.buildInputs()

const env = {
...process.env,
...committerIdentity(),
...defaultInputs
}

Expand Down
5 changes: 5 additions & 0 deletions src/__tests__/inputs-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ export class InputsBuilder {
return this
}

forDefaultAction(): InputsBuilder {
this.action = DEFAULT_ACTION
return this
}

async buildInputs(): Promise<ActionInputs> {
if (this.queueName === null) {
this.queueName = DEFAULT_QUEUE_NAME
Expand Down