1
1
name : Benchmark Regression Check
2
2
3
3
on :
4
+ workflow_dispatch :
4
5
pull_request :
5
6
branches : [ main ]
6
7
paths :
14
15
- ' .github/workflows/**'
15
16
16
17
jobs :
17
- test-twice :
18
+ run_benchmark_twice :
18
19
runs-on : ubuntu-20.04
19
-
20
20
steps :
21
21
- uses : actions/setup-go@v4
22
22
with :
@@ -28,43 +28,80 @@ jobs:
28
28
- run : make
29
29
- name : Run benchmark
30
30
run : make benchmarks-perf-test
31
- - name : Make previous directory
32
- run : mkdir -v ${{ github.workspace }}/previous
33
- - name : Copy results to previous directory
34
- run : cp -r ${{ github.workspace }}/benchmark/performanceTest/output ${{ github.workspace }}/previous
31
+ - name : Upload latest benchmark result
32
+ uses : actions/upload-artifact@v3
33
+ with :
34
+ name : benchmark-result-artifact-main
35
+ path : ${{github.workspace}}/benchmark/performanceTest/output/results.json
36
+ - name : remove output directory
37
+ run : sudo rm -rf ${{ github.workspace }}/benchmark/performanceTest/output
38
+ - name : Stash uncommitted changes
39
+ run : git stash push --keep-index --include-untracked -m "Stashing changes for tests"
40
+
35
41
- name : Check out PR
36
42
uses : actions/checkout@v3
37
43
with :
38
44
ref : ${{ github.event.pull_request.head.sha }}
39
45
- run : make
40
46
- name : Run benchmark
41
47
run : make benchmarks-perf-test
42
- - name : Make current directory
43
- run : mkdir -v ${{ github.workspace }}/current
44
- - name : Copy results to current directory
45
- run : cp -r ${{ github.workspace }}/benchmark/performanceTest/output ${{ github.workspace }}/current
46
- - name : Perform Comparison and log results
47
- id : run-compare
48
- run : |
49
- sudo chmod +x ${{ github.workspace }}/scripts/check_regression.sh
50
- if sudo ${{ github.workspace }}/scripts/check_regression.sh ${{ github.workspace }}/previous/results.json ${{github.workspace}}/current/results.json; then
51
- echo "Comparison successful. All P90 values are within the acceptable range."
52
- else
53
- echo "Comparison failed. Current P90 values exceed 110% of the corresponding past values."
54
- echo "regression-detected=true" >> $GITHUB_OUTPUT
55
- fi
56
- - name : Stop the workflow if regression is detected
57
- if : steps.run-compare.outputs.regression-detected == 'true'
58
- uses : actions/github-script@v6
48
+ - name : Upload latest benchmark result
49
+ uses : actions/upload-artifact@v3
59
50
with :
60
- github-token : ${{ secrets.GITHUB_TOKEN }}
61
- script : |
62
- const comment = `
63
- :warning: **Regression Detected** :warning:
51
+ name : benchmark-result-artifact-pr
52
+ path : ${{github.workspace}}/benchmark/performanceTest/output/results.json
53
+
54
+ download_and_perform_comparison :
55
+ runs-on : ubuntu-20.04
56
+ needs : run_benchmark_twice
57
+ steps :
58
+ - uses : actions/setup-go@v4
59
+ with :
60
+ go-version : ' 1.18.10'
61
+ - name : Checkout main
62
+ uses : actions/checkout@v3
63
+ with :
64
+ ref : main
65
+ - run : make
66
+ - name : Install basic calculator
67
+ run : sudo apt-get install bc
68
+
69
+ - name : Create previous directory
70
+ run : mkdir -v ${{ github.workspace }}/previous
71
+ - name : Create current directory
72
+ run : mkdir -v ${{ github.workspace }}/current
73
+ - name : Download previous benchmark result
74
+ uses : actions/download-artifact@v3
75
+ with :
76
+ name : benchmark-result-artifact-main
77
+ path : ${{github.workspace}}/previous
78
+ - name : Download current benchmark result
79
+ uses : actions/download-artifact@v3
80
+ with :
81
+ name : benchmark-result-artifact-pr
82
+ path : ${{github.workspace}}/current
83
+ - name : Perform Comparison and log results
84
+ id : run-compare
85
+ run : |
86
+ sudo chmod +x ${{ github.workspace }}/scripts/check_regression.sh
87
+ if sudo ${{ github.workspace }}/scripts/check_regression.sh ${{ github.workspace }}/previous/results.json ${{github.workspace}}/current/results.json; then
88
+ echo "Comparison successful. All P90 values are within the acceptable range."
89
+ else
90
+ echo "Comparison failed. Current P90 values exceed 150% threshold of the corresponding past values."
91
+ echo "regression-detected=true" >> $GITHUB_OUTPUT
92
+ fi
93
+ - name : Stop the workflow if regression is detected
94
+ if : steps.run-compare.outputs.regression-detected == 'true'
95
+ uses : actions/github-script@v6
96
+ with :
97
+ github-token : ${{ secrets.GITHUB_TOKEN }}
98
+ script : |
99
+ const comment = `
100
+ :warning: **Regression Detected** :warning:
64
101
65
- The benchmark comparison indicates that there has been a performance regression.
66
- Please investigate and address the issue.
67
- To Investigate check logs of the previous job above.
68
- `;
102
+ The benchmark comparison indicates that there has been a performance regression.
103
+ Please investigate and address the issue.
104
+ To Investigate check logs of the previous job above.
105
+ `;
69
106
70
- core.setFailed(comment);
107
+ core.setFailed(comment);
0 commit comments