Skip to content

fix(ci): upload CDN artifacts under their bundle (intended) name - #10672

Merged
basvandijk merged 1 commit into
masterfrom
basvandijk/fix-cdn-upload-artifact-names
Jul 7, 2026
Merged

basvandijk merged 1 commit into
masterfrom
basvandijk/fix-cdn-upload-artifact-names

Conversation

@basvandijk

Copy link
Copy Markdown
Collaborator

What

Upload each CDN artifact under its bundle entry (intended) name instead of the resolved symlink target's basename.

Why

ci/src/artifacts/upload.sh resolved each bundle entry with readlink -f and named the uploaded S3 object after the resolved basename. For bundles whose entries are symlinks with a different (intended) name than their target, this produced the wrong CDN filename — e.g. governance-canister-test.wasm.gz instead of governance-canister_test.wasm.gz.

How

  • Loop: stop resolving with readlink -f; pass the bundle entry $fullrelpath (a symlink whose own name is already the intended CDN name) directly to upload(), and hash it with sha256sum (which follows symlinks, so the bytes are unchanged).
  • upload(): add --copy-links to both the AWS and Cloudflare rclone copy invocations, so rclone follows the symlink and uploads the target's bytes under the --files-from (bundle entry) name.
  • Keep the directory + --files-from + --immutable pattern (the rclone#4921 immutable workaround). copyto is intentionally avoided because --immutable is silently ignored for single-file transfers, which would reintroduce the risk of overwriting published artifacts.

This is defense-in-depth that fixes the latent symlink-rename issue for all bundles, not just canisters.

Testing

Dry run in the dev container against a synthetic bundle (symlink with intended name → real file with wrong name) confirms:

  • --copy-links present in both AWS + Cloudflare rclone copy calls;
  • --files-from resolves to the intended name (governance-canister_test.wasm.gz, SHA256SUMS);
  • the wrong resolved names never appear;
  • --immutable / --no-traverse / directory-source preserved;
  • checksum line uses symlink-followed bytes and the intended-name URL.

The uploader resolved each bundle entry with `readlink -f` and named the
uploaded S3 object after the *resolved* basename, producing wrong CDN
filenames (e.g. `governance-canister-test.wasm.gz` instead of
`governance-canister_test.wasm.gz`).

Instead, pass the bundle entry (a symlink whose own name is already the
intended CDN name) directly to `upload()`, and add `--copy-links` to both
the AWS and Cloudflare `rclone copy` invocations so rclone follows the
symlink and uploads the target's bytes under the `--files-from` (bundle
entry) name. `sha256sum` already follows symlinks, so the checksum is
unchanged.

This keeps the directory + `--files-from` + `--immutable` pattern (the
rclone#4921 immutable workaround); `copyto` is intentionally avoided since
`--immutable` is silently ignored for single-file transfers.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes how CDN artifacts are named when uploaded by ensuring each artifact is uploaded under its bundle entry name (the symlink name) rather than the resolved symlink target’s basename. This aligns uploaded object names with the intended public download filenames.

Changes:

  • Add --copy-links to both AWS S3 and Cloudflare R2 rclone copy invocations so symlink targets’ bytes are uploaded under the --files-from (bundle entry) name.
  • Stop resolving bundle entries with readlink -f; pass the bundle entry path directly to upload() and compute checksums from that path.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@basvandijk
basvandijk marked this pull request as ready for review July 7, 2026 10:46
@basvandijk
basvandijk requested a review from a team as a code owner July 7, 2026 10:46
@github-actions github-actions Bot added the @idx label Jul 7, 2026
@basvandijk
basvandijk merged commit e293044 into master Jul 7, 2026
44 checks passed
@basvandijk
basvandijk deleted the basvandijk/fix-cdn-upload-artifact-names branch July 7, 2026 10:59
AleDema pushed a commit to AleDema/ic that referenced this pull request Nov 18, 2026
Upgrades `bazel_skylib` from 1.9.0 to
[1.9.2](https://github.com/bazelbuild/bazel-skylib/releases/tag/1.9.2),
its latest release. 1.9.1 was tagged but its release CI failed, so it
was never released or published to the BCR (see the
[CHANGELOG](https://github.com/bazelbuild/bazel-skylib/blob/1.9.2/CHANGELOG.md)).

The unstamped release artifacts are byte-identical to master.

## Changes

- **`MODULE.bazel`**: version bump. BCR's `bazel_skylib/1.9.2` has no
patches or overlays, and its `MODULE.bazel` declares the same
dependencies as 1.9.0 (`platforms` 0.0.10, `rules_license` 1.0.0). Apart
from skylib's own version, the full `bazel mod graph` is identical to
master.
- **`publish/canisters/BUILD.bazel`**: sets `allow_symlink = True` on
its two `copy_file` calls, which copy the canister `.wasm.gz` files and
their `.did` files. This keeps those copies as symlinks (see below).

dfinity#12159 (rules_foreign_cc 0.17.0) also bumps `bazel_skylib` to 1.9.2,
because rules_foreign_cc 0.17.0 requires it. It carries the same two
`allow_symlink = True` lines, which are needed whichever of the two PRs
lands first.

## Upstream changes that touch our setup

Between the 1.9.0 and 1.9.2 release archives, only `copy_file`,
`selects`, the `common_settings` rules and the version strings change.
`write_file`, `run_binary`, `unittest`, `paths` and the rest of what we
use are unchanged.

- **`copy_file` copies by default again.** 1.9.0 made `allow_symlink`
default to `True` for non-executable files
([bazelbuild/bazel-skylib#565](bazelbuild/bazel-skylib#565)).
1.9.2 reverts that default to `False`
([bazelbuild/bazel-skylib#605](bazelbuild/bazel-skylib#605),
fixing
[bazelbuild/bazel-skylib#604](bazelbuild/bazel-skylib#604)),
so such a `copy_file` now runs `cp` instead of creating a symlink.
- The `copy_file`s in `ic-os/defs.bzl` and `ic-os/setupos/defs.bzl`
already set `allow_symlink = True`, so they don't change.
- The two in `publish/canisters/BUILD.bazel` relied on the 1.9.0
default. dfinity#10679 removed the `.did` copies' `allow_symlink = False` so
they would be symlinked, after dfinity#10672 made `ci/src/artifacts/upload.sh`
upload symlinked bundle entries under their own names. With
`allow_symlink = True` set explicitly, those 87 copies (44 `.wasm.gz`,
43 `.did`) stay symlinks; otherwise they would turn into `cp` actions.
- Outside the release artifacts' graph, the revert turns 18 external
`copy_file`s in the `//...` graph from symlinks into copies, because
they use the default: rules_python's namespace-package `__init__.py`
files for the numpy (11), pulp (4) and protobuf (2) wheels, and gawk's
`config.h` (gawk comes in through rules_distroless). Their content
doesn't change, and the tests that import those packages pass (see
Verification).
- **`selects.config_setting_group` with `//conditions:default`** now
aliases a new `@bazel_skylib//lib:always_true` target instead of
generating two `config_setting`s on `--stamp`
([bazelbuild/bazel-skylib#611](bazelbuild/bazel-skylib#611),
[bazelbuild/bazel-skylib#629](bazelbuild/bazel-skylib#629)).
We don't load `selects`, and no target in the configured `//...` graph
depends on a `@bazel_skylib//lib` target.
- **The `scope` attribute of the `common_settings` rules defaults to
`"target"` instead of `"universal"`**
([bazelbuild/bazel-skylib#608](bazelbuild/bazel-skylib#608)).
Our flags are defined with these rules (`//bazel:enable_fuzzing_code`,
`//bazel:enable_malicious_code`, `//bazel:hermetic_cc`,
`//:pocket-ic-server-variant`, ...), and none of them sets `scope`.
- Bazel 9.3.2 only reads a flag's `scope` when it is set explicitly.
That applies both to flags set on the command line
([`StarlarkOptionsParser`](https://github.com/bazelbuild/bazel/blob/9.3.2/src/main/java/com/google/devtools/build/lib/runtime/StarlarkOptionsParser.java#L256-L260))
and to flags set by transitions
([`BuildOptionsScopeFunction`](https://github.com/bazelbuild/bazel/blob/9.3.2/src/main/java/com/google/devtools/build/lib/skyframe/BuildOptionsScopeFunction.java#L181-L189)).
- `--incompatible_exclude_starlark_flags_from_exec_config` is off by
default in 9.3.2, and we don't set it. With it off, a flag without an
explicit scope still propagates to the exec configuration
([`FunctionTransitionUtil`](https://github.com/bazelbuild/bazel/blob/9.3.2/src/main/java/com/google/devtools/build/lib/analysis/starlark/FunctionTransitionUtil.java#L239-L251)).
- Checked with both versions: `--//bazel:enable_fuzzing_code=True` on
the command line and `//bazel:enable_malicious_code` set by the
`malicious_binary` transition both reach the exec configurations. The
configuration hashes are the same as on master.

## Verification

All in the dev container:

- **Module graph:** `bazel mod graph` is identical to master apart from
skylib's own version. `bazel mod explain bazel_skylib` shows every
dependent resolving 1.9.2. There are no new warnings; the only one is
the existing `rules_qemu` `use_repo()` warning.
- **Analysis:** `bazel build //... --nobuild` analyzes all 3387 targets.
- **Lint:** the CI Linter checks (`shfmt-check`, `ruff-check`,
`buf-check`, `DFINITY-capitalization-check`, `do-not-merge-check`,
`buildifier-check`, `gazelle-check`, `buf-breaking-check`) pass.
`buildifier-fix`, `shfmt-fix`, `ruff-fix` and `gazelle` change nothing.
- **`copy_file` actions:** in the release artifacts' graph there are 227
(215 symlinks, 12 copies). `bazel aquery` prints identical output for
them with 1.9.0 and 1.9.2, action keys included. In the `//...` graph,
the only differences are the 18 external symlink-to-copy switches listed
above.
- **Release artifacts are byte-identical to master** (133 files): the
unstamped IC-OS bundles that `ci/container/build-ic.sh --icos` builds
(GuestOS prod disk and update, GuestOS recovery update, HostOS update,
SetupOS), `//publish/binaries:bundle` and `//publish/canisters:bundle`.
No sandboxed actions ran: everything was a disk-cache hit apart from 26
uncacheable local actions.
- **Tests:** these 33 pass:
- `//bazel/mainnet_artifact_refs_tests:mainnet_artifact_refs_test`: 10
analysis tests built on skylib's `unittest`.
- The 20 `file_size_check` tests in `//publish/canisters`, which read
the symlinked canisters.
- `//rs/recovery/subnet_splitting/split_finder:split_finder_test`,
`//ci/githubstats:query_test` and `//ci/githubstats:query_help_test`.
They import pandas (and with it numpy), pulp and protobuf, whose
namespace `__init__.py` files are now copies.
- **Builds:**
- `//rs/rosetta-api/icp:version` and `//rs/rosetta-api/icrc1:version`
(`write_file`) contain `2.1.10` and `1.2.10`.
  - `@@gawk+//:gawk` compiles with its `config.h` now a copied file.
- **Not run locally:** the full build and test suite, the system tests
and the macOS builds. CI covers those.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants