Skip to content

Commit a33954e

Browse files
authored
Merge pull request #62 from coderbirju/test_twice
Test twice
2 parents ae37c37 + 32891ca commit a33954e

File tree

2 files changed

+76
-1
lines changed

2 files changed

+76
-1
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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+
test-twice:
18+
runs-on: ubuntu-20.04
19+
20+
steps:
21+
- uses: actions/setup-go@v4
22+
with:
23+
go-version: '1.18.10'
24+
- name: Checkout main
25+
uses: actions/checkout@v3
26+
with:
27+
ref: main
28+
- run: make
29+
- name: Run benchmark
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
35+
- name: Check out PR
36+
uses: actions/checkout@v3
37+
with:
38+
ref: ${{ github.event.pull_request.head.sha }}
39+
- run: make
40+
- name: Run benchmark
41+
run: make benchmarks-perf-test
42+
- name: Make current directory
43+
run: mkdir -v ${{ github.workspace }}/current
44+
- name: Stash uncommitted changes
45+
run: git stash push --keep-index --include-untracked -m "Stashing changes for tests"
46+
# If you're using Git version 2.28 or later, use this line instead:
47+
# run: git stash push --keep-index --include-untracked -m "Stashing changes for tests"
48+
# This will ensure that uncommitted changes do not interfere with the tests.
49+
- name: Copy results to current directory
50+
run: cp -r ${{ github.workspace }}/benchmark/performanceTest/output ${{ github.workspace }}/current
51+
- name: Perform Comparison and log results
52+
id: run-compare
53+
run: |
54+
sudo chmod +x ${{ github.workspace }}/scripts/check_regression.sh
55+
if sudo ${{ github.workspace }}/scripts/check_regression.sh ${{ github.workspace }}/previous/results.json ${{github.workspace}}/current/results.json; then
56+
echo "Comparison successful. All P90 values are within the acceptable range."
57+
else
58+
echo "Comparison failed. Current P90 values exceed 110% of the corresponding past values."
59+
echo "regression-detected=true" >> $GITHUB_OUTPUT
60+
fi
61+
- name: Stop the workflow if regression is detected
62+
if: steps.run-compare.outputs.regression-detected == 'true'
63+
uses: actions/github-script@v6
64+
with:
65+
github-token: ${{ secrets.GITHUB_TOKEN }}
66+
script: |
67+
const comment = `
68+
:warning: **Regression Detected** :warning:
69+
70+
The benchmark comparison indicates that there has been a performance regression.
71+
Please investigate and address the issue.
72+
To Investigate check logs of the previous job above.
73+
`;
74+
75+
core.setFailed(comment);

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ build-benchmarks:
104104

105105
benchmarks-perf-test:
106106
@echo "$@"
107-
@cd benchmark/performanceTest ; sudo rm -rf output ; GO111MODULE=$(GO111MODULE_VALUE) go build -o ../bin/PerfTests . && sudo ../bin/PerfTests -show-commit
107+
@cd benchmark/performanceTest ; sudo rm -rf output ; GO111MODULE=$(GO111MODULE_VALUE) go build -o ../bin/PerfTests . && sudo ../bin/PerfTests -show-commit -count 2
108108

109109
benchmarks-stargz:
110110
@echo "$@"

0 commit comments

Comments
 (0)