Skip to content

Commit fe8a623

Browse files
added failure comment, updated checks
1 parent fd4dcdb commit fe8a623

1 file changed

Lines changed: 35 additions & 4 deletions

File tree

.github/workflows/benchmark_pr.yml

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ env:
1313
MAIN_REPO_NAME: hub
1414
jobs:
1515
benchmark-pr:
16-
if: ${{ contains(github.event.pull_request.labels.*.name, 'trigger-benchmark') && github.repository == 'activeloopai/hub' }}
16+
if: ${{ github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'trigger-benchmark') && github.repository == 'activeloopai/hub' }}
1717
runs-on: [looprunner]
1818
steps:
1919
- name: Cancel previous runs if available
@@ -36,7 +36,7 @@ jobs:
3636
- name: Creates initial issue comment
3737
uses: actions/github-script@v3
3838
with:
39-
github-token: ${{ secrets.REPOSITORY_PAT }}
39+
github-token: ${{ secrets.ACTIVELOOP_BOT_PAT }}
4040
script: |
4141
const workflowRunUrl =
4242
process.env.GITHUB_SERVER_URL +
@@ -131,7 +131,7 @@ jobs:
131131
pip install -r hub/requirements/plugins.txt
132132
pip install -r hub/requirements/tests.txt
133133
python setup.py install
134-
- name: Doing the benchmark and comparing with baseline -> Hub from PR
134+
- name: Doing the benchmark, publishing and comparing with baseline -> Hub from PR
135135
run: |
136136
cd benchmark-source
137137
python3 run.py --all --baseline=${BASELINE_REF} --github
@@ -142,8 +142,9 @@ jobs:
142142
mkdir comment-temp
143143
csv2md benchmark-source/results/improvements.csv > comment-temp/improvements.md
144144
csv2md benchmark-source/results/regressions.csv > comment-temp/regressions.md
145-
- name: Add benchmark results from file as a comment on pulll requests
145+
- name: Update benchmark results from file as a comment on pulll requests
146146
uses: actions/github-script@v3
147+
if: success()
147148
with:
148149
github-token: ${{ secrets.ACTIVELOOP_BOT_PAT }}
149150
script: |
@@ -192,3 +193,33 @@ jobs:
192193
comment_id: commentFromBot.id,
193194
body: prComment,
194195
});
196+
197+
- name: Update the comment if the job fails
198+
uses: actions/github-script@v3
199+
if: failure()
200+
with:
201+
github-token: ${{ secrets.ACTIVELOOP_BOT_PAT }}
202+
script: |
203+
const {data: comments} = await github.issues.listComments({
204+
owner: 'activeloopai',
205+
repo: '${{ env.MAIN_REPO_NAME }}',
206+
issue_number: context.issue.number
207+
});
208+
209+
const commentFromBot = comments.find(
210+
(item) => item.user.login === 'activeloop-bot'
211+
);
212+
const workflowRunUrl =
213+
process.env.GITHUB_SERVER_URL +
214+
'/' +
215+
process.env.GITHUB_REPOSITORY +
216+
'/actions/runs/${{ github.run_id }}';
217+
const prComment = 'Benchmark failed for ${{ github.event.pull_request.head.sha }}, please check: ' + workflowRunUrl;
218+
219+
await github.issues.updateComment({
220+
issue_number: context.issue.number,
221+
owner: 'activeloopai',
222+
repo: '${{ env.MAIN_REPO_NAME }}',
223+
comment_id: commentFromBot.id,
224+
body: prComment,
225+
});

0 commit comments

Comments
 (0)