forked from get-woke/woke
-
Notifications
You must be signed in to change notification settings - Fork 0
105 lines (86 loc) · 3.63 KB
/
Copy pathbenchmark.yml
File metadata and controls
105 lines (86 loc) · 3.63 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: Benchmark Regression
on:
pull_request:
paths:
- "**.go"
- go.mod
- go.sum
- .github/workflows/benchmark.yml
jobs:
docs:
name: benchmark
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.17
- name: Install cob
run: curl -sfL https://raw.githubusercontent.com/knqyf263/cob/master/install.sh | sudo sh -s -- -b /usr/local/bin
# POC -- should not be blocking yet until benchmarks are stable and can be used to block PRs
- name: Run Benchmark
id: cob
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#custom-shell
shell: bash {0}
continue-on-error: true
run: |
out=$(mktemp -q)
REF="origin/$GITHUB_BASE_REF"
set -o pipefail # causes exit code from cob to bubble up from tee
cob --base "$REF" 2>&1 | tee $out
EXIT_CODE=$?
base_commit="$(git rev-parse $REF)"
# https://github.community/t/set-output-truncates-multiline-strings/16852/3
# also remove colors, which don't translate in the github comment
result="$(cat $out | sed -e 's/\x1B\[1;91m/-/g' -e 's/\x1B\[0m\s//g' -e 's/\x1B\[1;34m/\+/g')"
result="${result//'%'/'%25'}"
result="${result//$'\n'/'%0A'}"
result="${result//$'\r'/'%0D'}"
echo "::set-output name=result::$result"
echo "::set-output name=exit_code::$EXIT_CODE"
echo "::set-output name=base_commit::$base_commit"
exit $EXIT_CODE
# FIXME: The action to comment on PRs does not work for forks
# https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#restrictions-on-repository-forks
# - name: Find Comment
# uses: peter-evans/find-comment@v1
# id: comment
# with:
# issue-number: ${{ github.event.pull_request.number }}
# comment-author: 'github-actions[bot]'
# body-includes: <!-- cob-output -->
# - name: Create or update comment if benchmark failed
# uses: peter-evans/create-or-update-comment@v1
# if: steps.cob.outputs.exit_code != '0'
# with:
# comment-id: ${{ steps.comment.outputs.comment-id }}
# issue-number: ${{ github.event.pull_request.number }}
# body: |
# <!-- cob-output -->
# ### Benchmark comparison to `origin/main`
# * Comparison commit: ${{ steps.cob.outputs.base_commit }}
# _This is currently only informational_
# **This PR may have a negative performance impact**
# ```
# ${{ steps.cob.outputs.result }}
# ```
# edit-mode: replace
# - name: Update comment if benchmark succeeded
# uses: peter-evans/create-or-update-comment@v1
# if: steps.comment.outputs.comment-id != '' && steps.cob.outputs.exit_code == '0'
# with:
# comment-id: ${{ steps.comment.outputs.comment-id }}
# issue-number: ${{ github.event.pull_request.number }}
# body: |
# <!-- cob-output -->
# ### Benchmark comparison to `origin/main`
# * Comparison commit: ${{ steps.cob.outputs.base_commit }}
# _This is currently only informational_
# **This PR previously reported a negative performance impact that appears to have been resolved**
# ```
# ${{ steps.cob.outputs.result }}
# ```
# edit-mode: replace