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

ci: Add rule to only run benchmark if other check are successful #194

Merged
merged 3 commits into from
Feb 14, 2022
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
42 changes: 34 additions & 8 deletions .github/workflows/benchmark-ec2-runner.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,36 @@
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 }}
Expand Down Expand Up @@ -37,24 +62,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'
- name: Start Running the bechmarks
run: make test:bench

# 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
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down