Skip to content

Commit e9d5b28

Browse files
committed
ci: stage the site with write_source_files instead of shell
Replaces the cp -RL plus two chmod passes with 'bazel run //:stage_site', using write_source_files from aspect_bazel_lib -- already a dependency, so no new module. It is used here as a directory-copy primitive rather than for its usual round-tripping purpose, so diff_test and the destination-exists check are off: out/ is build output, not something checked in. Three measured improvements over the shell it replaces: - Writes 644/755 directly, so the post-hoc chmod normalisation is gone. The deploy job commits this tree, and Bazel's own outputs are 555, so that compensation was load-bearing -- now it is simply not needed. - Does not reach into bazel-bin, a convenience symlink that --symlink_prefix can move or suppress. - Removes files that are no longer part of the site. cp left them; verified by planting a stale file and re-running. Considered rules_pkg's pkg_install for the same job. write_source_files wins on handling directory outputs natively -- both bundles are tree artifacts, which is the fiddly part of pkg_files -- and on adding no dependency. Verified end to end: the staged artifact is 38 files, content and modes identical to the pre-migration CI output.
1 parent eeee8cd commit e9d5b28

3 files changed

Lines changed: 22 additions & 8 deletions

File tree

.github/workflows/actions.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,11 @@ jobs:
2222
run: bazel test //...
2323
- name: Build site
2424
run: bazel build //:site
25-
# bazel-bin is a symlink into the output base, and the artifact upload does
26-
# not follow it, so stage the tree. Bazel's outputs are mode 555; the deploy
27-
# job commits this tree to gh-pages, so normalise to 644/755 or every file
28-
# would land marked executable.
25+
# Materializes //:site into out/. Writes 644/755 directly, so the deploy job
26+
# does not commit a tree of executables, and does not depend on the bazel-bin
27+
# convenience symlink.
2928
- name: Stage site
30-
run: |
31-
mkdir -p out && cp -RL bazel-bin/site/. out/
32-
find out -type d -exec chmod 755 {} +
33-
find out -type f -exec chmod 644 {} +
29+
run: bazel run //:stage_site
3430
- uses: actions/upload-artifact@v4
3531
with:
3632
name: out

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
# Bazel convenience symlinks into the output base.
22
/bazel-*
3+
4+
# Staged site output from `bazel run //:stage_site`.
5+
/out/

BUILD.bazel

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,18 @@ copy_to_directory(
2525
root_paths = ["src"],
2626
visibility = ["//visibility:public"],
2727
)
28+
29+
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files")
30+
31+
# Materializes //:site into out/ for the CI artifact upload: `bazel run //:stage_site`.
32+
# Used as a directory-copy primitive rather than for its usual round-tripping
33+
# purpose, so the staleness test and the destination-exists check are off -- out/
34+
# is build output, not something checked in. Unlike a shell copy this writes
35+
# 644/755 without post-hoc chmod, does not reach into the bazel-bin symlink, and
36+
# removes files that are no longer part of the site.
37+
write_source_files(
38+
name = "stage_site",
39+
files = {"out": "//:site"},
40+
check_that_out_file_exists = False,
41+
diff_test = False,
42+
)

0 commit comments

Comments
 (0)