Repository navigation
194 lines (182 loc) · 11 KB
/
Copy pathci3.yml
File metadata and controls
194 lines (182 loc) · 11 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
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
# CI for Aztec. At a high-level, runs ./bootstrap.sh ci in root. See root README.md for more details.
# Only for internal devs. For external devs, see ci3-external.yml.
#
# CAREFUL! We use "exec" a lot to ensure signal propagation to the child process, to allow proper ec2 cleanup.
name: CI3
on:
workflow_dispatch:
push:
branches:
- next
tags:
- "v*"
pull_request:
types: [opened, synchronize, reopened, ready_for_review, labeled]
merge_group: {}
concurrency:
# Pushes to next: one run per commit, so a later merge does not cancel the full run (and
# benchmarks) of the one before. Everything else: one run per branch.
group: ci3-${{ (github.event_name == 'push' && github.ref == 'refs/heads/next' && github.sha) || github.event.merge_group.head_ref || github.ref_name }}
cancel-in-progress: true
jobs:
# The main CI job for Aztec pull requests. It gatekeeps merges to next, intended for the merge queue.
#
# This orchestrates AWS EC2 spot instances then remotely runs ./bootstrap.sh
# The ci-full label enables heavier tests. For other labels, see ci3.sh.
#
# Standard PR) Merge Queue
# | |
# | 1x AMD64 EC2 Spot | | [ 4x AMD64 EC2 Spot ] |
# | [ 1x ARM64 EC2 Spot ] |
# |
# Filters out "accidental"
# successes, but non-determinism
# can still cause flaky tests.
#
# If you suspect a flaky test, look for people recently reporting similar things.
# Otherwise, spend time ensuring it is not your PR. Spend some time attempting to fix it.
# Try not to just increase timeouts. Post either about your fix or your efforts where
# engineers can broadly see it.
ci:
runs-on: ubuntu-latest
# exclusive with ci3-external.yml: never run on forks
# (github.event.pull_request.head.repo.fork resolves to nil if not a pull request)
if: github.event.pull_request.head.repo.fork != true && (github.event.pull_request.draft == false || contains(github.event.pull_request.labels.*.name, 'ci-draft'))
environment: ${{ startsWith(github.ref, 'refs/tags/v') && 'master' || '' }}
permissions:
id-token: write # required for OIDC assume-role with AWS
contents: read # checkout/fetch with the default github.token
pull-requests: read # merge_group mode looks up the source PR
steps:
# Do NOT bump actions/checkout to v6 here. v6 ("persist creds to a separate file", #2286)
# stores the persisted github.token in a temp credentials file pulled in via includeIf, which
# `git config --unset-all http....extraheader` cannot clear. Our runner-side pushes (ci3.sh
# release-pr tag, ci3_success.sh squash-and-merge) rely on swapping that header for a bot-PAT
# remote, so under v6 they push as github-actions[bot] (contents: read) and 403. v5.0.1 is still
# node24 but keeps the credential as a removable local extraheader.
- name: Checkout
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
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 }}
# Fetch PR commits depth. squash-pr.sh works on this shallow checkout without deepening it.
fetch-depth: ${{ github.event.pull_request.commits || 1 }}
# Persisted for authenticated reads (e.g. the aztec-packages-private mirror); pushes swap in
# a bot-PAT remote at each push site.
persist-credentials: true
- name: Check out the ci3 submodule
# Only the ci3 submodule: `submodules: true` would also clone noir-repo and the contract
# libraries. The others are marked update = none in this checkout, so `bootstrap.sh init`, which
# every script that sources ci3 runs, leaves them out too. A no-op on refs from before ci3 became
# a submodule.
run: if [ "$(git ls-files -s ci3 | cut -c1-6)" = 160000 ]; then git submodule update --init --depth 1 ci3 && git config -f .gitmodules --name-only --get-regexp '\.path$' | sed 's/\.path$/.update/' | grep -vx submodule.ci3.update | xargs -I{} git config {} none; fi
- name: Configure AWS credentials (OIDC)
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ vars.AWS_OIDC_ROLE_ARN || secrets.AWS_OIDC_ROLE_ARN }}
aws-region: us-east-2
role-session-name: ci3-${{ github.run_id }}
role-duration-seconds: 7200 # 2h – covers max AWS_SHUTDOWN_TIME (90 min ARM) + 30 min buffer
- name: Determine CI Mode
env:
MERGE_GROUP_BASE_REF: ${{ github.event.merge_group.base_ref }}
PR_BASE_REF: ${{ github.event.pull_request.base.ref }}
GITHUB_REF_NAME: ${{ github.ref_name }}
GITHUB_TOKEN: ${{ github.token }}
PR_LABELS_JSON: ${{ toJson(github.event.pull_request.labels.*.name) }}
run: |
# Parse labels from JSON env var to avoid shell injection via label names
mapfile -t LABELS < <(echo "$PR_LABELS_JSON" | jq -r '.[]')
./.github/ci3_labels_to_env.sh "${LABELS[@]}"
- name: Run
env:
GITHUB_TOKEN: ${{ secrets.AZTEC_BOT_GITHUB_TOKEN }}
# Only set in the private repo: the service account private releases deploy npm packages with.
# The _KEY suffix keeps ci3/redact treating the value as sensitive.
GCP_PRIVATE_NPM_DEPLOY_KEY: ${{ secrets.GCP_PRIVATE_NPM_DEPLOY }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
# Used by docs CI scripts to post to #docs-alerts (the SLACK_BOT_TOKEN bot lacks access there).
AZTEC_FOUNDATION_CI_SLACK_BOT_TOKEN: ${{ secrets.AZTEC_FOUNDATION_CI_SLACK_BOT_TOKEN }}
AZTEC_TOOLCHAIN_DEFAULT_MAJOR_VERSION: ${{ vars.AZTEC_TOOLCHAIN_DEFAULT_MAJOR_VERSION }}
# For automatic documentation updates via Claude Code
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
# Internal GCP Artifact Registry the private repo's release pushes the docker image to (see
# bootstrap.sh::private_release). Empty in the public repo, where releases publish normally.
INTERNAL_DOCKER_REGISTRY: ${{ vars.INTERNAL_DOCKER_REGISTRY }}
MERGE_GROUP_BASE_REF: ${{ github.event.merge_group.base_ref }}
PR_BASE_REF: ${{ github.event.pull_request.base.ref }}
PR_HEAD_REF: ${{ github.event.pull_request.head.ref }}
PR_COMMITS: ${{ github.event.pull_request.commits }}
PR_NUMBER: ${{ github.event.pull_request.number }}
GITHUB_REF_NAME: ${{ github.ref_name }}
GITHUB_ACTOR: ${{ github.actor }}
# Forwarded to EC2 so release_compat_e2e's nightly-failure Slack alert can build a real run URL.
RUN_ID: ${{ github.run_id }}
CI3_INSTANCE_PROFILE_NAME: ${{ secrets.CI3_INSTANCE_PROFILE_NAME }}
CI3_SECURITY_GROUP_ID: ${{ secrets.CI3_SECURITY_GROUP_ID }}
AWS_OIDC_ROLE_ARN: ${{ vars.AWS_OIDC_ROLE_ARN || secrets.AWS_OIDC_ROLE_ARN }}
# NOTE: $CI_MODE is set in the Determine CI Mode step.
run: exec ./.github/ci3.sh $CI_MODE
- name: Post-Actions
env:
SHOULD_SQUASH_MERGE: ${{ contains(github.event.pull_request.labels.*.name, 'ci-squash-and-merge') && '1' || '0' }}
GITHUB_TOKEN: ${{ secrets.AZTEC_BOT_GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_HEAD_REF: ${{ github.event.pull_request.head.ref }}
PR_BASE_REF: ${{ github.event.pull_request.base.ref }}
run: ./.github/ci3_success.sh
# Publishes what a release build staged (bootstrap.sh release → the release bundle in the cache):
# the GitHub release in AztecProtocol/barretenberg, the crates and the npm packages. The publishing
# credentials live only in this job, never on the EC2 machine that runs the build; npm uses trusted
# publishing, so this runner's OIDC token is its only credential. Public repo only: the private repo
# publishes to the internal GCP Artifact Registry straight from EC2 (bootstrap.sh private_release).
publish:
needs: ci
if: startsWith(github.ref, 'refs/tags/v') && github.repository == 'AztecProtocol/aztec-packages'
runs-on: ubuntu-latest
# Same environment as the release build above: its AWS_OIDC_ROLE_ARN is the release role, the
# only one that can read the release cache, and it is the environment to name when configuring
# each package's npm trusted publisher.
environment: master
permissions:
id-token: write # AWS OIDC for the cache download, npm OIDC for trusted publishing
contents: read
steps:
- name: Checkout
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
with:
fetch-depth: 1
persist-credentials: false
- name: Check out the ci3 submodule
# Only the ci3 submodule: `submodules: true` would also clone noir-repo and the contract
# libraries. The others are marked update = none in this checkout, so `bootstrap.sh init`, which
# every script that sources ci3 runs, leaves them out too. A no-op on refs from before ci3 became
# a submodule.
run: if [ "$(git ls-files -s ci3 | cut -c1-6)" = 160000 ]; then git submodule update --init --depth 1 ci3 && git config -f .gitmodules --name-only --get-regexp '\.path$' | sed 's/\.path$/.update/' | grep -vx submodule.ci3.update | xargs -I{} git config {} none; fi
- name: Configure AWS credentials (OIDC)
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ vars.AWS_OIDC_ROLE_ARN || secrets.AWS_OIDC_ROLE_ARN }}
aws-region: us-east-2
role-session-name: publish-${{ github.run_id }}
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 22
# Trusted publishing needs npm >= 11.5.1; Node 22 ships an older npm.
- name: Update npm
run: npm install -g npm@^11.5.1 && npm --version
# gh and cargo come with the runner image. The bundle is downloaded through authenticated S3
# with this job's AWS role, not the plain-HTTP cache endpoint, and extracted outside the
# checkout; each channel then refuses anything not at exactly this tag's version.
- name: Publish
env:
S3_BUILD_CACHE_AWS_PARAMS: --region us-east-2
GITHUB_TOKEN: ${{ secrets.AZTEC_BOT_GITHUB_TOKEN }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: ./bootstrap.sh publish