-
Notifications
You must be signed in to change notification settings - Fork 315
229 lines (221 loc) · 9.94 KB
/
ci3.yml
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# CI for Aztec. At a high-level, runs ./bootstrap.sh ci in root. See root README.md for more details.
name: CI3
on:
workflow_dispatch:
push:
branches:
- master
tags:
- "v*"
pull_request:
types: [opened, synchronize, reopened, ready_for_review, labeled]
# For external devs. Workflow file edits won't take effect in the PR.
pull_request_target:
types: [opened, synchronize, reopened, ready_for_review, labeled]
concurrency:
# On master (handled by push event) the group id is the unique run_id so we get parallel runs.
# On PR's the group id is the ref_name so only 1 can run at a time.
group: ci3-${{ github.event_name == 'push' && github.run_id || github.ref_name }}
cancel-in-progress: true
jobs:
ci-amd64:
runs-on: ubuntu-latest
# condition:
# - Always allow 'push' and 'workflow_dispatch' jobs.
# - Otherwise, only run pull_request events on internal PRs and pull_request_target on external PRs.
if: >
github.event_name == 'push' ||
github.event_name == 'workflow_dispatch' ||
(
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) ||
(github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository)
)
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# The commit to checkout. We want our actual commit, and not the result of merging the PR to the target.
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Validate External Changes
if: github.event_name == 'pull_request_target'
run: |
git fetch origin ${{ github.event.pull_request.base.ref }} --depth=1
git diff --name-only ${{ github.event.pull_request.base.ref }} HEAD ci3 ci.sh | grep -q . && { echo "Error: External PRs can't contain CI changes."; exit 1; }
- name: Fail If Draft
if: github.event.pull_request.draft && (github.event.action != 'labeled' || github.event.label.name != 'trigger-workflow')
run: echo "CI is not run on drafts." && exit 1
- name: CI Full Override
# TODO consolidate legacy labels to just ci-full.
if: contains(github.event.pull_request.labels.*.name, 'e2e-all') || contains(github.event.pull_request.labels.*.name, 'network-all') || contains(github.event.pull_request.labels.*.name, 'ci-full')
run: echo "CI_FULL=1" >> $GITHUB_ENV
- name: Setup
run: |
# Ensure we can SSH into the spot instances we request.
mkdir -p ~/.ssh
echo ${{ secrets.BUILD_INSTANCE_SSH_KEY }} | base64 --decode > ~/.ssh/build_instance_key
chmod 600 ~/.ssh/build_instance_key
- name: Run
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
GITHUB_TOKEN: ${{ secrets.AZTEC_BOT_GITHUB_TOKEN }}
ARCH: amd64
LOG_ID: ${{ github.run_id }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
run: |
./ci.sh ec2
- name: Download benchmarks
if: github.ref_name == 'master'
run: |
./ci3/cache_download barretenberg-bench-results-$(git rev-parse HEAD).tar.gz
./ci3/cache_download yarn-project-bench-results-$(git rev-parse HEAD).tar.gz
- name: Store barretenberg benchmark result
if: github.ref_name == 'master'
continue-on-error: true
uses: benchmark-action/github-action-benchmark@4de1bed97a47495fc4c5404952da0499e31f5c29
with:
name: C++ Benchmark
tool: "googlecpp"
output-file-path: ./bench-out/bb-bench.json
github-token: ${{ secrets.AZTEC_BOT_GITHUB_TOKEN }}
auto-push: true
alert-threshold: "105%"
comment-on-alert: true
fail-on-alert: false
alert-comment-cc-users: "@ludamad @codygunton"
max-items-in-chart: 50
- name: Store yarn project benchmark result
if: github.ref_name == 'master'
continue-on-error: true
uses: benchmark-action/github-action-benchmark@4de1bed97a47495fc4c5404952da0499e31f5c29
with:
name: "End-to-end Benchmark"
benchmark-data-dir-path: "dev/e2e-bench"
tool: "customSmallerIsBetter"
output-file-path: ./bench-out/yp-bench.json
github-token: ${{ secrets.AZTEC_BOT_GITHUB_TOKEN }}
auto-push: true
alert-threshold: "150%"
comment-on-alert: true
fail-on-alert: false
alert-comment-cc-users: "@philwindle @spalladino"
max-items-in-chart: 50
ci-arm64:
runs-on: ubuntu-latest
# condition:
# - Always allow 'push' and 'workflow_dispatch' jobs.
# - Otherwise, only run pull_request events on internal PRs and pull_request_target on external PRs.
# Then, **unlike ci-amd64**, if we aren't labeled 'arm64-ci', do nothing.
if: >
github.event_name == 'push' ||
github.event_name == 'workflow_dispatch' ||
(
(
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) ||
(github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository)
) &&
contains(github.event.pull_request.labels.*.name, 'arm64-ci')
)
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# The commit to checkout. We want our actual commit, and not the result of merging the PR to the target.
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Validate External Changes
if: github.event_name == 'pull_request_target'
run: |
git fetch origin ${{ github.event.pull_request.base.ref }} --depth=1
git diff --name-only ${{ github.event.pull_request.base.ref }} HEAD ci3 ci.sh | grep -q . && { echo "Error: External PRs can't contain CI changes."; exit 1; }
- name: Fail If Draft
if: github.event.pull_request.draft && (github.event.action != 'labeled' || github.event.label.name != 'trigger-workflow')
run: echo "CI is not run on drafts." && exit 1
- name: CI Full Override
# TODO consolidate legacy labels to just ci-full.
if: contains(github.event.pull_request.labels.*.name, 'e2e-all') || contains(github.event.pull_request.labels.*.name, 'network-all') || contains(github.event.pull_request.labels.*.name, 'ci-full')
run: echo "CI_FULL=1" >> $GITHUB_ENV
- name: Setup
run: |
# Ensure we can SSH into the spot instances we request.
mkdir -p ~/.ssh
echo ${{ secrets.BUILD_INSTANCE_SSH_KEY }} | base64 --decode > ~/.ssh/build_instance_key
chmod 600 ~/.ssh/build_instance_key
- name: Run
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
GITHUB_TOKEN: ${{ secrets.AZTEC_BOT_GITHUB_TOKEN }}
ARCH: arm64
LOG_ID: ${{ github.run_id }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
run: |
./ci.sh ec2
ci-grind:
runs-on: ubuntu-latest
needs: ci-amd64
if: github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/')
strategy:
fail-fast: false
matrix:
number: [1, 2, 3, 4, 5]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# The commit to checkout. We want our actual commit, and not the result of merging the PR to the target.
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Setup
run: |
# Ensure we can SSH into the spot instances we request.
mkdir -p ~/.ssh
echo ${{ secrets.BUILD_INSTANCE_SSH_KEY }} | base64 --decode > ~/.ssh/build_instance_key
chmod 600 ~/.ssh/build_instance_key
- name: Run
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
ARCH: amd64
LOG_ID: ${{ github.run_id }}
INSTANCE_POSTFIX: ${{ matrix.number }}
DRY_RUN: 1
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
./ci.sh ec2-test
notify:
runs-on: ubuntu-latest
if: github.event_name == 'push' && failure()
needs:
- ci-grind
- ci-arm64
- ci-amd64
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get Context
id: get_context
run: |
authors=$(git log -1 --pretty=format:'%an <%ae>')
echo "authors=${authors}" >> $GITHUB_OUTPUT
title=$(git log -1 --pretty=format:'%s')
echo "commit_title=${title}" >> $GITHUB_OUTPUT
failed_jobs=""
[ "${{ needs.ci-grind.result }}" = "failure" ] && failed_jobs+="ci-grind"
[ "${{ needs.ci-arm64.result }}" = "failure" ] && failed_jobs+="ci-arm64"
[ "${{ needs.ci-amd64.result }}" = "failure" ] && failed_jobs+="ci-amd64"
echo "failed_jobs=${failed_jobs}" >> $GITHUB_OUTPUT
cat $GITHUB_OUTPUT
- name: Send notification to aztec3-ci channel if workflow failed on master
uses: slackapi/[email protected]
with:
payload: |
{
"text": "Failure on ${{ github.ref_name }}\nCommit: ${{ steps.get_context.outputs.commit_title }}",
"url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
"authors": "${{ steps.get_context.outputs.authors }}",
"failed_jobs": "${{ steps.get_context.outputs.failed_jobs }}"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_NOTIFY_WORKFLOW_TRIGGER_URL2 }}