Skip to content

Commit 03047d6

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 03047d6

File tree

1 file changed

+68
-32
lines changed

1 file changed

+68
-32
lines changed

.github/workflows/benchmark_regression_test.yml

Lines changed: 68 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ on:
1414
- '.github/workflows/**'
1515

1616
jobs:
17-
test-twice:
17+
run_benchmark_twice:
1818
runs-on: ubuntu-20.04
19-
2019
steps:
2120
- uses: actions/setup-go@v4
2221
with:
@@ -28,43 +27,80 @@ jobs:
2827
- run: make
2928
- name: Run benchmark
3029
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
30+
- name: Upload latest benchmark result
31+
uses: actions/upload-artifact@v3
32+
with:
33+
name: benchmark-result-artifact-main
34+
path: ${{github.workspace}}/benchmark/performanceTest/output/results.json
35+
- name: remove output directory
36+
run: sudo rm -rf ${{ github.workspace }}/benchmark/performanceTest/output
37+
- name: Stash uncommitted changes
38+
run: git stash push --keep-index --include-untracked -m "Stashing changes for tests"
39+
3540
- name: Check out PR
3641
uses: actions/checkout@v3
3742
with:
3843
ref: ${{ github.event.pull_request.head.sha }}
3944
- run: make
4045
- name: Run benchmark
4146
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
47+
- name: Upload latest benchmark result
48+
uses: actions/upload-artifact@v3
5949
with:
60-
github-token: ${{ secrets.GITHUB_TOKEN }}
61-
script: |
62-
const comment = `
63-
:warning: **Regression Detected** :warning:
50+
name: benchmark-result-artifact-pr
51+
path: ${{github.workspace}}/benchmark/performanceTest/output/results.json
52+
53+
download_and_perform_comparison:
54+
runs-on: ubuntu-20.04
55+
needs: run_benchmark_twice
56+
steps:
57+
- uses: actions/setup-go@v4
58+
with:
59+
go-version: '1.18.10'
60+
- name: Checkout main
61+
uses: actions/checkout@v3
62+
with:
63+
ref: main
64+
- run: make
65+
- name: Install basic calculator
66+
run: sudo apt-get install bc
67+
68+
- name: Create previous directory
69+
run: mkdir -v ${{ github.workspace }}/previous
70+
- name: Create current directory
71+
run: mkdir -v ${{ github.workspace }}/current
72+
- name: Download previous benchmark result
73+
uses: actions/download-artifact@v3
74+
with:
75+
name: benchmark-result-artifact-main
76+
path: ${{github.workspace}}/previous
77+
- name: Download current benchmark result
78+
uses: actions/download-artifact@v3
79+
with:
80+
name: benchmark-result-artifact-pr
81+
path: ${{github.workspace}}/current
82+
- name: Perform Comparison and log results
83+
id: run-compare
84+
run: |
85+
sudo chmod +x ${{ github.workspace }}/scripts/check_regression.sh
86+
if sudo ${{ github.workspace }}/scripts/check_regression.sh ${{ github.workspace }}/previous/results.json ${{github.workspace}}/current/results.json; then
87+
echo "Comparison successful. All P90 values are within the acceptable range."
88+
else
89+
echo "Comparison failed. Current P90 values exceed 150% threshold of the corresponding past values."
90+
echo "regression-detected=true" >> $GITHUB_OUTPUT
91+
fi
92+
- name: Stop the workflow if regression is detected
93+
if: steps.run-compare.outputs.regression-detected == 'true'
94+
uses: actions/github-script@v6
95+
with:
96+
github-token: ${{ secrets.GITHUB_TOKEN }}
97+
script: |
98+
const comment = `
99+
:warning: **Regression Detected** :warning:
64100
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-
`;
101+
The benchmark comparison indicates that there has been a performance regression.
102+
Please investigate and address the issue.
103+
To Investigate check logs of the previous job above.
104+
`;
69105
70-
core.setFailed(comment);
106+
core.setFailed(comment);

0 commit comments

Comments
 (0)