From 5d5ce53805d16c16dc8d126d5582519b4f2164ab Mon Sep 17 00:00:00 2001 From: Shahzad Lone Date: Tue, 8 Feb 2022 05:56:43 -0500 Subject: [PATCH 1/3] Add a check to only run the benchmark ec2 runner workflow if the other github workflows are successfull. --- .github/workflows/benchmark-ec2-runner.yml | 37 ++++++++++++++++++---- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/.github/workflows/benchmark-ec2-runner.yml b/.github/workflows/benchmark-ec2-runner.yml index fd3b097d72..2937798237 100644 --- a/.github/workflows/benchmark-ec2-runner.yml +++ b/.github/workflows/benchmark-ec2-runner.yml @@ -1,11 +1,35 @@ name: benchmark-ec2-runner -on: pull_request +on: + workflow_run: + workflows: + - "golangci-lint" + - "Code Test Coverage" + branches: + - master + - develop + tags: + - v* + types: [completed] jobs: + # Step-1: Ensure that other workflows ran successfully and passed. + ensure-other-workflows-passed: + name: Ensure other workflows passed + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'failure' }} + steps: + - name: Don't run the benchmarks as a workflow failed. + uses: actions/github-script@v3 + with: + script: | + core.setFailed('Not running benchmarks because a workflow failed!') + + # Step-2: Start the runner and get it registered as a github runner. start-runner: name: Start self-hosted EC2 runner + needs: ensure-other-workflows-passed # only run if the other workflows pass. runs-on: ubuntu-latest outputs: label: ${{ steps.start-ec2-runner.outputs.label }} @@ -37,24 +61,25 @@ jobs: ## {"Key": "GitHubRepository", "Value": "${{ github.repository }}"} ## ] + # Step-3: Run the benchmarks on the runner we just started. benchmark-ec2-runner: - name: Run the benchmarks on the started EC2 runner - needs: start-runner # required to start the main job when the runner is ready - + needs: + - ensure-other-workflows-passed # only run if the other workflows pass. + - start-runner # required to start the main job when the runner is ready runs-on: ${{ needs.start-runner.outputs.label }} # run the job on the newly created runner steps: - name: Setup benchmarks run: echo 'Replace with Johns Benchmarking Command Steps' + # Step-4: Stop the runner once the benchmarks have ran. stop-runner: - name: Stop self-hosted EC2 runner needs: + - ensure-other-workflows-passed # only run if the other workflows pass. - start-runner # required to get output from the start-runner job - benchmark-ec2-runner # required to wait when the main job is done - runs-on: ubuntu-latest if: ${{ always() }} # required to stop the runner even if the error happened in the previous jobs From a7a3b1f4616d4cbe0d5def6965180f796ab72132 Mon Sep 17 00:00:00 2001 From: Shahzad Lone Date: Tue, 8 Feb 2022 07:02:29 -0500 Subject: [PATCH 2/3] Ready to test, but github actions for workflow runs dependent on each other only work on default branches apparently. --- .github/workflows/benchmark-ec2-runner.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/benchmark-ec2-runner.yml b/.github/workflows/benchmark-ec2-runner.yml index 2937798237..84ead07db3 100644 --- a/.github/workflows/benchmark-ec2-runner.yml +++ b/.github/workflows/benchmark-ec2-runner.yml @@ -10,7 +10,8 @@ on: - develop tags: - v* - types: [completed] + types: + - completed jobs: From e1245b401391a7bccac44968fb7f672495f56f7e Mon Sep 17 00:00:00 2001 From: Shahzad Lone Date: Tue, 8 Feb 2022 13:22:18 -0500 Subject: [PATCH 3/3] Run the benchmarks on the EC2 container. --- .github/workflows/benchmark-ec2-runner.yml | 4 ++-- Makefile | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/benchmark-ec2-runner.yml b/.github/workflows/benchmark-ec2-runner.yml index 84ead07db3..550b43ac18 100644 --- a/.github/workflows/benchmark-ec2-runner.yml +++ b/.github/workflows/benchmark-ec2-runner.yml @@ -71,8 +71,8 @@ jobs: runs-on: ${{ needs.start-runner.outputs.label }} # run the job on the newly created runner steps: - - name: Setup benchmarks - run: echo 'Replace with Johns Benchmarking Command Steps' + - name: Start Running the bechmarks + run: make test:bench # Step-4: Stop the runner once the benchmarks have ran. stop-runner: diff --git a/Makefile b/Makefile index 5d5a7d1338..5f792c5b36 100644 --- a/Makefile +++ b/Makefile @@ -58,7 +58,7 @@ test\:clean: clean\:test test .PHONY: test\:bench test\:bench: - go test ./... -race -bench=. + make -C ./bench/ bench # This also takes integration tests into account. .PHONY: test\:coverage-full