forked from iree-org/iree
-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (65 loc) · 3.01 KB
/
post_benchmark_comment.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Copyright 2022 The IREE Authors
#
# Licensed under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
name: Post benchmark comment
on:
workflow_run:
# TODO(#17001): switch to just "Benchmark" after finishing refactor and
# pending PRs have been rebased
workflows: ["CI", "Benchmark"]
types: [completed]
env:
PR_CI_STAGE: ${{ github.event.workflow_run.event == 'pull_request' && 'presubmit' || 'postsubmit' }}
PR_CI_RUN_ID: ${{ github.event.workflow_run.id }}
PR_CI_RUN_ATTEMPT: ${{ github.event.workflow_run.run_attempt }}
jobs:
post_comment:
# Only run the workflow if it's triggered from a pull request.
if: github.event.workflow_run.event == 'pull_request'
runs-on: ubuntu-20.04
permissions:
issues: write
pull-requests: write
steps:
- name: "Checking out repository"
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
- name: "Checking benchmark processing job"
id: check
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BENCHMARK_PROCESS_JOB: process_benchmark_results
run: |
# Assume the workflow has fewer than 100 jobs.
export CONCLUSION=$(gh api \
"/repos/${GITHUB_REPOSITORY}/actions/runs/${PR_CI_RUN_ID}/attempts/${PR_CI_RUN_ATTEMPT}/jobs?per_page=100" \
| jq --raw-output --arg job "${BENCHMARK_PROCESS_JOB}" \
'.jobs | map(select(.name==$job))[0] | .conclusion')
echo "job-conclusion=${CONCLUSION}" >> "${GITHUB_OUTPUT}"
- name: "Downloading artifacts"
if: steps.check.outputs.job-conclusion == 'success'
id: download
env:
# Currently GitHub managed runner doesn't have GCP credential. Fetch
# from public URL directly.
PR_CI_GCS_URL: https://storage.googleapis.com/iree-github-actions-${{ env.PR_CI_STAGE }}-artifacts/${{ env.PR_CI_RUN_ID }}/${{ env.PR_CI_RUN_ATTEMPT }}
BENCHMARK_COMMENT_ARTIFACT: benchmark-comment.json
run: |
wget -O "${BENCHMARK_COMMENT_ARTIFACT}" \
"${PR_CI_GCS_URL}/${BENCHMARK_COMMENT_ARTIFACT}"
echo "benchmark-comment-artifact=${BENCHMARK_COMMENT_ARTIFACT}" >> "${GITHUB_OUTPUT}"
- name: Posting comments
if: steps.check.outputs.job-conclusion == 'success'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GIST_BOT_TOKEN: ${{ secrets.GIST_BOT_TOKEN }}
COMMENT_BOT_USER: github-actions[bot]
# Get PR number from the event instead of the untrusted comment
# artifact, to make sure we won't incorrectly update other PRs.
BENCHMARK_COMMENT_ARTIFACT: ${{ steps.download.outputs.benchmark-comment-artifact }}
run: |
./build_tools/benchmarks/post_benchmark_comment.py \
--verbose \
--github_event_json="${GITHUB_EVENT_PATH}" \
"${BENCHMARK_COMMENT_ARTIFACT}"