Skip to content

Commit 7685dfc

Browse files
committed
Add regression check automation
This commit adds benchmark_regression_test.yml workflow that runs a regression test by comparing the benchmark results of the current branch with the previous benchmark results of the code in main branch. Signed-off-by: Arjun Raja Yogidas <[email protected]>
1 parent bde429d commit 7685dfc

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Benchmark Regression Check
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
paths:
7+
- '**.go'
8+
- 'go.*'
9+
- 'cmd/go.*'
10+
- 'Makefile'
11+
- 'Dockerfile'
12+
- 'integration/**'
13+
- 'scripts/**'
14+
- '.github/workflows/**'
15+
16+
jobs:
17+
benchmark:
18+
name: Run Benchmark on current Branch
19+
runs-on: ubuntu-20.04
20+
steps:
21+
- uses: actions/checkout@v3
22+
- uses: actions/setup-go@v4
23+
with:
24+
go-version: '1.18.10'
25+
- run: make
26+
- name: Run benchmark
27+
run: make benchmarks-perf-test
28+
29+
fetch-previous-results_and_compare:
30+
name: Fetch results from previous run
31+
needs: benchmark
32+
runs-on: ubuntu-20.04
33+
steps:
34+
- uses: actions/checkout@v3
35+
- uses: actions/setup-go@v4
36+
with:
37+
go-version: '1.18.10'
38+
- name: Make previous directory
39+
run: mkdir -v ${{ github.workspace }}/previous
40+
- name: Download previous run artifact
41+
id: download-artifact
42+
uses: dawidd6/action-download-artifact@v2
43+
with:
44+
github_token: ${{secrets.GITHUB_TOKEN}}
45+
name: benchmark-result-artifact
46+
name_is_regexp: true
47+
path: ${{ github.workspace }}/previous
48+
repo: ${{ github.repository }}
49+
check_artifacts: false
50+
search_artifacts: true
51+
skip_unpack: false
52+
if_no_artifact_found: fail
53+
workflow: benchmark_visualization.yml
54+
- name: Perform Comparison and log results
55+
id: run-compare
56+
run: |
57+
sudo chmod +x ${{ github.workspace }}/scripts/check_regression.sh
58+
if sudo ${{ github.workspace }}/scripts/check_regression.sh ${{ github.workspace }}/previous/benchmark-result-artifact/results.json ${{github.workspace}}/benchmark/performanceTest/output/results.json; then
59+
echo "Comparison successful. All P90 values are within the acceptable range."
60+
else
61+
echo "Comparison failed. Current P90 values exceed 110% of the corresponding past values."
62+
echo "regression-detected=true" >> $GITHUB_OUTPUT
63+
fi
64+
65+
- name: Stop the workflow if regression is detected
66+
if: steps.run-compare.outputs.regression-detected == 'true'
67+
uses: actions/github-script@v6
68+
with:
69+
github-token: ${{ secrets.GITHUB_TOKEN }}
70+
script: |
71+
const comment = `
72+
:warning: **Regression Detected** :warning:
73+
74+
The benchmark comparison indicates that there has been a performance regression.
75+
Please investigate and address the issue.
76+
To Investigate check logs of the previous job above.
77+
`;
78+
79+
core.setFailed(comment);

0 commit comments

Comments
 (0)