Skip to content

Commit d264006

Browse files
committed
Update workflow to use upload artifact action
Updated the workflow to use upload artifact action Signed-off-by: Arjun Raja Yogidas <[email protected]>
1 parent ca3d3bc commit d264006

File tree

1 file changed

+69
-32
lines changed

1 file changed

+69
-32
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: Benchmark Regression Check
22

33
on:
4+
workflow_dispatch:
45
pull_request:
56
branches: [ main ]
67
paths:
@@ -14,9 +15,8 @@ on:
1415
- '.github/workflows/**'
1516

1617
jobs:
17-
test-twice:
18+
run_benchmark_twice:
1819
runs-on: ubuntu-20.04
19-
2020
steps:
2121
- uses: actions/setup-go@v4
2222
with:
@@ -28,43 +28,80 @@ jobs:
2828
- run: make
2929
- name: Run benchmark
3030
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+
3541
- name: Check out PR
3642
uses: actions/checkout@v3
3743
with:
3844
ref: ${{ github.event.pull_request.head.sha }}
3945
- run: make
4046
- name: Run benchmark
4147
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
5950
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:
64101
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+
`;
69106
70-
core.setFailed(comment);
107+
core.setFailed(comment);

0 commit comments

Comments
 (0)