Repository navigation
fix(release): release target and private patch live here; releases use private caches #790
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| #!/usr/bin/env bash | ||
| # Run by ci3/bootstrap_ec2 on the build instance right after checkout, before ci3/source derives | ||
| # COMMIT_HASH from HEAD. Its stdout is printed at the start of the run; its stderr only on failure. | ||
| set -euo pipefail | ||
| if [ "${RELEASE_TARGET:-}" = private ]; then | ||
| exec scripts/apply_private_release_patch | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule ci3
updated
21 files
| +9 −2 | README.md | |
| +40 −64 | bootstrap_ec2 | |
| +2 −1 | cache_delete | |
| +6 −6 | cache_download | |
| +4 −4 | cache_download_stream | |
| +3 −3 | cache_exists | |
| +1 −18 | cache_log | |
| +3 −2 | cache_ls | |
| +4 −4 | cache_upload | |
| +2 −2 | cache_upload_stream | |
| +1 −18 | denoise | |
| +0 −48 | internal/apply_private_release_patch | |
| +1 −1 | internal/aws_request_instance_type | |
| +1 −9 | internal/run_test_cmd | |
| +24 −1 | internal/source_cache | |
| +38 −1 | internal/source_stdlib | |
| +23 −0 | source_cache_bucket | |
| +0 −105 | source_release_target | |
| +116 −0 | tests/cache_bucket_test | |
| +21 −0 | tests/instance_group_test | |
| +29 −0 | tests/runner_log_test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| #!/usr/bin/env bash | ||
| # Downloads this private release's patch, applies it to HEAD and commits it, so the build sees a | ||
| # clean tree. Prints the patch's location and sha256, never the patch or the paths it touches. | ||
| # | ||
| # Run by .github/ci3_post_checkout.sh right after checkout, before ci3/source computes COMMIT_HASH. A | ||
| # missing patch leaves the tree as tagged; any other failure, an empty patch included, fails the | ||
| # release. | ||
| set -euo pipefail | ||
|
|
||
| bucket=aztec-node-ci-private | ||
| key="${REF_NAME:?REF_NAME is required}.patch" | ||
| echo "Private release patch: s3://$bucket/$key" | ||
|
|
||
| patch=$(mktemp) | ||
| trap 'rm -f "$patch"' EXIT | ||
|
|
||
| # Read access comes from the private release's instance profile (CI3_INSTANCE_PROFILE_NAME on the | ||
| # release-private environment). The owner check keeps a bucket of the same name in another account | ||
| # from serving a patch. | ||
| owner=$(aws sts get-caller-identity --region eu-west-2 --query Account --output text) | ||
| if ! err=$(aws s3api get-object --region eu-west-2 --bucket "$bucket" --key "$key" \ | ||
| --expected-bucket-owner "$owner" "$patch" 2>&1 >/dev/null); then | ||
| # Only a missing key means there is no patch: a missing bucket or lost access must fail. | ||
| if [[ "$err" == *"(NoSuchKey)"* ]]; then | ||
| echo "No private release patch at s3://$bucket/$key; building the tagged tree." | ||
| exit 0 | ||
| fi | ||
| echo "$err" >&2 | ||
| echo "Failed to download the private release patch s3://$bucket/$key." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| sha=$(sha256sum "$patch" | cut -d' ' -f1) | ||
| echo "Private release patch sha256: $sha" | ||
|
|
||
| if [ ! -s "$patch" ]; then | ||
| echo "The private release patch s3://$bucket/$key is empty." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| # git apply's warnings and errors quote paths and lines from the patch, so its output is dropped. | ||
| if ! git apply --index "$patch" &>/dev/null; then | ||
| echo "The private release patch (sha256 $sha) does not apply cleanly to $(git rev-parse HEAD)." >&2 | ||
| exit 1 | ||
| fi | ||
| # -q: without it commit prints "create mode <path>" for each new file. | ||
| git -c user.name="Aztec Private Release" -c user.email=tech@aztecprotocol.com \ | ||
| commit -q --no-verify -m "Private release patch sha256:$sha" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| # The release target: where a release reads its packages from, and where it publishes. | ||
| # | ||
| # Sourced by `bootstrap.sh ci-release` before the build and again by `bootstrap.sh release`, so a | ||
| # misconfigured environment fails in seconds instead of after a full build, and by release-image | ||
| # for its registry. RELEASE_TARGET is a | ||
| # literal in the release workflow, never a GitHub variable, so no variable edit can flip a flow; | ||
| # everything else is either supplied by the workflow's environment or derived here. | ||
| # | ||
| # public npmjs + DockerHub, plus the aztec-up and playground assets. release.yml states both | ||
| # URLs as literals rather than GitHub variables, so no variable edit can retarget a | ||
| # public release. | ||
| # private one GCP Artifact Registry for both the @aztec-foundation reads and the @aztec-labs | ||
| # writes, and nothing public. Its credentials and npm URL come from the release-private | ||
| # environment, its docker URL from the repo-level INTERNAL_DOCKER_REGISTRY the deploy | ||
| # workflows also read. | ||
| # | ||
| # The two targets share no credential: an environment that can read private packages holds nothing | ||
| # that can publish publicly, and vice versa. The assertions here are the backstop for the cases | ||
| # GitHub cannot see — a hand-run release, a mis-wired workflow, a half-configured environment. | ||
|
|
||
| export RELEASE_TARGET=${RELEASE_TARGET:-public} | ||
|
|
||
| # Both URLs are required, whatever the target: an unset value is a configuration error, never a | ||
| # silent fall back to a default destination. Exported so ci3/bootstrap_ec2 forwards them to the | ||
| # build container however the caller happened to set them. | ||
| : "${NPM_REGISTRY:?NPM_REGISTRY is required}" | ||
| : "${DOCKER_REGISTRY:?DOCKER_REGISTRY is required}" | ||
| export NPM_REGISTRY DOCKER_REGISTRY | ||
|
|
||
| case "$RELEASE_TARGET" in | ||
| public) | ||
| # The aztec-nr mirror goes first: a failure there aborts the whole release, since a CLI whose | ||
| # scaffold pins an aztec-nr tag that does not exist is worse than no release at all. | ||
| export RELEASE_PROJECTS="noir-projects/aztec-nr yarn-project aztec-up playground release-image" | ||
|
|
||
| # Sanity check the registry. NPM_REGISTRY is both where the build reads our scopes from and | ||
| # where it publishes them, so a public release pointed elsewhere would bake private packages | ||
| # into the images it pushes to DockerHub and the assets it uploads to the public buckets. | ||
| if ! is_npmjs "$NPM_REGISTRY"; then | ||
| echo_stderr "A public release must read and publish npm from npmjs, not $NPM_REGISTRY." | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Never the shared build cache, which any CI build can write. Only ci-release switches to it: | ||
| # the network jobs source this file for the registry, on instances that cannot read it. | ||
| export RELEASE_CACHE_BUCKET=aztec-ci-release-cache | ||
| ;; | ||
| private) | ||
| # What gets published is code, not configuration: the projects that publish public artifacts | ||
| # (aztec-up, playground) are not in the list, so their release functions are never invoked. | ||
| export RELEASE_PROJECTS="yarn-project release-image" | ||
|
|
||
| # Sanity check the registries. Deliberately broader than is_npmjs: this one refuses a | ||
| # destination, so anything that so much as looks like npmjs should fail here. | ||
| if [[ "$NPM_REGISTRY" == *npmjs.org* ]] || [[ "$DOCKER_REGISTRY" == docker.io/* ]]; then | ||
| echo_stderr "A private release must not publish to npmjs or DockerHub ($NPM_REGISTRY, $DOCKER_REGISTRY)." | ||
| exit 1 | ||
| fi | ||
|
|
||
| # The credential is required, not just the URL. ci3/source_npm_auth writes its whole | ||
| # configuration only when a credential is set, so a private release without one routes no | ||
| # scope at all: the build resolves @aztec-foundation from npmjs, succeeds, and fails at the | ||
| # publish. Every reader of the private arm publishes, so there is no case to be lenient for. | ||
| : "${NPM_USERNAME:?NPM_USERNAME is required for a private release (INTERNAL_NPM_USERNAME, on release-private)}" | ||
| : "${NPM_PASSWORD:?NPM_PASSWORD is required for a private release (INTERNAL_NPM_PASSWORD, on release-private)}" | ||
| : "${DOCKER_USERNAME:?DOCKER_USERNAME is required for a private release (INTERNAL_DOCKER_USERNAME, on release-private)}" | ||
| : "${DOCKER_PASSWORD:?DOCKER_PASSWORD is required for a private release (INTERNAL_DOCKER_PASSWORD, on release-private)}" | ||
|
|
||
| # These should not be reachable. | ||
| for var in NPM_TOKEN DOCKERHUB_USERNAME DOCKERHUB_PASSWORD; do | ||
| if [ -n "${!var:-}" ]; then | ||
| echo_stderr "$var must not be set for a $RELEASE_TARGET release; it belongs to the other target." | ||
| exit 1 | ||
| fi | ||
| done | ||
|
|
||
| # A private release always comes from a private/v* tag, so the channel check below is not | ||
| # optional here: an absent version has nothing to publish under, and skipping the check is | ||
| # how a private build would end up on a public channel. | ||
| if ! semver check "${REF_NAME:-}" >/dev/null 2>&1; then | ||
| echo_stderr "A private release needs REF_NAME to be a version; got '${REF_NAME:-}'." | ||
| exit 1 | ||
| fi | ||
|
|
||
| # The private tag carries its own channel, so the version says which flow produced it. | ||
| if semver check "${REF_NAME:-}" >/dev/null 2>&1; then | ||
| release_channel=$(dist_tag) | ||
| if [ "$release_channel" != private ]; then | ||
| echo_stderr "A private release needs a <version>-private.<n> tag; $REF_NAME is '$release_channel'." | ||
| exit 1 | ||
| fi | ||
| unset release_channel | ||
| fi | ||
|
|
||
| # The private cache, which nothing public can read or write. It has to be a cache of its own, | ||
| # not only for privacy: no cache key mentions the registry. node_modules is keyed on yarn.lock | ||
| # plus package.json and the release-image base layer on the Dockerfiles plus yarn.lock, all | ||
| # identical between a public and a private build of the same tree, so a private run reading the | ||
| # public cache would restore a public run's entries and skip both installs, publishing | ||
| # artifacts built against npmjs while reporting success. Its other writer, the | ||
| # aztec-packages-private CI, builds this tree only with its manifests rewritten, so under other | ||
| # keys. | ||
| export RELEASE_CACHE_BUCKET=aztec-ci-private-cache | ||
| ;; | ||
| *) | ||
| echo_stderr "Unknown RELEASE_TARGET '$RELEASE_TARGET' (expected public or private)." | ||
| exit 1 | ||
| ;; | ||
| esac |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
download_chonk_inputs.shnow requiressha256sum. If a macOS developer uses the standard Homebrew setup,coreutilsexposesgsha256sum, notsha256sum. This script runs directly without adding Homebrew's unprefixed commands toPATH, so fresh downloads stop with “command not found,” blocking benchmarks that need them. Useshasum -a 256on macOS or select an available checksum command.