Skip to content

ci(aie image): tag hash that ignores comments; never rebuild a published tag - #1089

Merged
zaneni6 merged 5 commits into
mainfrom
ci/aie-image-hash-ignore-comments
Nov 21, 2026
Merged

zaneni6 merged 5 commits into
mainfrom
ci/aie-image-hash-ignore-comments

Conversation

@zaneni6

@zaneni6 zaneni6 commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

The aie-build image tag was cat toolchain.lock Dockerfile | sha256sum | cut -c1-16, computed inline in three places. A comment-only edit (like the one in #1086) produced a new tag, so a functionally identical image was rebuilt (~25 min) and republished.

  • New .github/script/ci/aie_image_hash.py (standard library only) hashes normalised inputs:
    • CRLF/CR → LF, BOM dropped, trailing whitespace stripped
    • blank lines and # comment lines dropped
    • Dockerfile parser directives at the top of the file (# syntax=, # escape=, # check=) are kept, since they change the build
    • a Dockerfile that contains a heredoc (RUN <<EOF, COPY <<EOF ...) is hashed as written, with only line endings normalised, because a # line inside a heredoc is content, not a comment
    • toolchain.lock only accepts strict KEY=VALUE lines besides comments
  • devkit-aie-image.yml and devkit-xclbins.yml use the script in all three places. The script is in the image workflow's path filters, so a formula change republishes.
  • devkit-aie-image.yml no longer rebuilds or moves a published tag (except on workflow_dispatch, which always rebuilds and republishes):
    • build looks aie-build:<hash> up; if it is published, it skips the image build and runs docker/aie-build-check.sh in the published image, so a change to the check or the PDI list (not covered by the hash) is still tested;
    • publish, on a push, does nothing when the tag already exists, so a published tag is never moved to a new digest.
  • toolchain.lock's header comment now names the script.

Effect after merge

The tag formula changes, so the tag for the current files becomes 578bf8ecdf2b1be0. The first push to main after merge builds and publishes that tag once (the PDI check runs as usual). Until it finishes, devkit-xclbins builds the image in-run from the layer cache, as it does today for an unpublished tag.

Testing

  • test_aie_image_hash.py: comment, blank-line, whitespace, line-ending and BOM edits keep the hash; value, instruction, indentation, directive and heredoc edits change it; CLI and real-file tests. All pass on Windows.
  • Full .github/script/ci suite: only the known Windows-environment failures (read-only .git rmtree, symlink privilege, path separators).
  • devkit_check.py and check_internal_refs.py pass.
  • actionlint was not run locally (not installed); both workflows parse. This PR's CI is the first real run.

🤖 Generated with Claude Code

zaneni6 and others added 5 commits November 20, 2026 13:02
aie_image_hash.py prints the aie-build image tag: the first 16 hex digits
of sha256(toolchain.lock + Dockerfile) after dropping blank and comment
lines, stripping trailing whitespace and normalising line endings. The
Dockerfile's parser directives at the top (# syntax=, # escape=,
# check=) are kept, as they change the build.

Co-Authored-By: Claude <noreply@anthropic.com>
devkit-aie-image.yml (build and publish) and devkit-xclbins.yml (image
lookup) compute the toolchain hash with the script instead of hashing the
raw files, so a comment-only edit of toolchain.lock or the Dockerfile
keeps the tag. devkit-aie-image.yml also runs when the script changes.

The formula changes, so the current files get a new tag (4d79b217e7000169,
was 22fa5e0b8888953d): merging this rebuilds and publishes the image once.

Co-Authored-By: Claude <noreply@anthropic.com>
A Dockerfile with a heredoc (RUN <<EOF, COPY <<EOF /path) is hashed with
only its line endings normalised: in a heredoc body a "#" line, a blank
line or trailing whitespace is content, so dropping it could keep the tag
for a different image. toolchain.lock must hold only column-0 comments,
blank lines and KEY=VALUE lines with no whitespace in the value (exit 1
otherwise), so every byte the hash ignores there is one no build arg
reads; devkit-xclbins.yml, which does not run the image workflow's lock
check, gets it too. Each file is now hashed on its own and the tag is the
hash of the two digests, so a line moved between the files is a new tag.

The current files hash to 578bf8ecdf2b1be0 (was 4d79b217e7000169 on this
branch, 22fa5e0b8888953d with the inline formula on main).

Co-Authored-By: Claude <noreply@anthropic.com>
…n hash

A comment-only edit kept the tag but still rebuilt the image, reran the
kernel check and republished, and the publish moved the existing
:<toolchain hash> tag to the new digest. Now:

- build looks :<toolchain hash> up anonymously (not on workflow_dispatch);
  if it is published, it skips the image build and runs
  docker/aie-build-check.sh in the published image, so a change to the
  check or the PDI list, which the hash does not cover, is still tested.
- publish, on a push, looks the tag up after logging in; if it exists it
  pushes, checks and tags nothing, so a published tag is never moved.
  workflow_dispatch still republishes.

Header comments and the script's docstring now say so.

Co-Authored-By: Claude <noreply@anthropic.com>
Each "Read toolchain.lock" step (two in devkit-aie-image.yml, one in
devkit-xclbins.yml) must call aie_image_hash.py "$LOCK" "$DOCKERFILE" and
must not hash with sha256sum, and LOCK and DOCKERFILE must be the script's
defaults: an inline hash in one of them would make the published tag and
the looked-up tag differ without an error.

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Security scan found no critical or high findings on lines changed by this pull request

View the security scan run for complete reports.

“New” means the finding is located in a changed file on an added or modified line; it is not a base-versus-head findings delta.

@zaneni6
zaneni6 marked this pull request as ready for review November 21, 2026 01:30
@zaneni6
zaneni6 merged commit 3dc4d62 into main Nov 21, 2026
90 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant