Skip to content

Commit df570ea

Browse files
committed
fix(ci): compute runtime cache key in shell, satisfy yamlfix
hashFiles() in the cache key is re-evaluated by the actions/cache post step; by then create_disk_image.sh has debootstrapped a full rootfs tree into the globbed directory and hashing it times out after 120s. Compute the key once in a shell step from the build input files instead. Also apply yamlfix formatting to both workflow files, which 'hatch run linting:style' enforces.
1 parent bc0a9eb commit df570ea

2 files changed

Lines changed: 23 additions & 13 deletions

File tree

.github/workflows/build-deb-package-and-integration-tests.yml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ concurrency:
1818
group: ${{ github.workflow }}-${{ github.ref }}
1919
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
2020

21+
2122
jobs:
2223
build_deb:
2324
name: "Build ${{ matrix.os }} Package"
@@ -59,7 +60,8 @@ jobs:
5960
uses: actions/cache@v4
6061
with:
6162
path: packaging/target/bin
62-
key: sevctl-${{ matrix.os }}-${{ hashFiles('packaging/Makefile', format('packaging/{0}.dockerfile', matrix.os)) }}
63+
key: sevctl-${{ matrix.os }}-${{ hashFiles('packaging/Makefile', format('packaging/{0}.dockerfile',
64+
matrix.os)) }}
6365

6466
- run: |
6567
cd packaging && make ${{ matrix.make_target }} && cd ..
@@ -94,18 +96,23 @@ jobs:
9496
run: sudo echo RESET grub-efi/install_devices | sudo debconf-communicate grub-pc
9597

9698
# The runtime takes ~2 minutes to debootstrap and rarely changes. Cache it on
97-
# the content of its build scripts, with a monthly stamp so the packages
99+
# the content of its build inputs, with a monthly stamp so the packages
98100
# pulled by debootstrap and pip do not become indefinitely stale.
99-
- name: Compute monthly cache stamp
100-
id: stamp
101-
run: echo "month=$(date +%Y-%m)" >> "$GITHUB_OUTPUT"
101+
# The key is computed in shell because hashFiles() is re-evaluated in the
102+
# cache post step, after the build filled the directory with the
103+
# debootstrapped tree (hashing it times out).
104+
- name: Compute runtime cache key
105+
id: cache-key
106+
run: |
107+
input_hash=$(cat runtimes/aleph-${{ matrix.os }}-python/*.sh runtimes/aleph-${{ matrix.os }}-python/*.py runtimes/aleph-${{ matrix.os }}-python/*.html | sha256sum | cut -c -16)
108+
echo "key=runtime-aleph-${{ matrix.os }}-python-$(date +%Y-%m)-${input_hash}" >> "$GITHUB_OUTPUT"
102109
103110
- name: Cache the built runtime
104111
id: cache-runtime
105112
uses: actions/cache@v4
106113
with:
107114
path: runtimes/aleph-${{ matrix.os }}-python/rootfs.squashfs
108-
key: runtime-aleph-${{ matrix.os }}-python-${{ steps.stamp.outputs.month }}-${{ hashFiles(format('runtimes/aleph-{0}-python/**', matrix.os)) }}
115+
key: ${{ steps.cache-key.outputs.key }}
109116

110117
- name: Install dep and build
111118
if: steps.cache-runtime.outputs.cache-hit != 'true'

.github/workflows/test-using-pytest.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ on:
99
# The branches below must be a subset of the branches above
1010
branches: [main]
1111

12-
1312
# Cancel superseded runs when new commits are pushed to a PR branch.
1413
concurrency:
1514
group: ${{ github.workflow }}-${{ github.ref }}
@@ -71,20 +70,24 @@ jobs:
7170
# find /opt
7271
7372
# The aleph-debian-12-python runtime takes ~2 minutes to debootstrap and
74-
# rarely changes. Cache it on the content of its build scripts, with a
73+
# rarely changes. Cache it on the content of its build inputs, with a
7574
# monthly stamp so the packages pulled by debootstrap and pip do not
7675
# become indefinitely stale. The key is shared with the build_rootfs job
77-
# of the droplet test workflow.
78-
- name: Compute monthly cache stamp
79-
id: stamp
80-
run: echo "month=$(date +%Y-%m)" >> "$GITHUB_OUTPUT"
76+
# of the droplet test workflow and computed in shell because hashFiles()
77+
# is re-evaluated in the cache post step, after the build filled the
78+
# directory with the debootstrapped tree (hashing it times out).
79+
- name: Compute runtime cache key
80+
id: cache-key
81+
run: |
82+
input_hash=$(cat runtimes/aleph-debian-12-python/*.sh runtimes/aleph-debian-12-python/*.py runtimes/aleph-debian-12-python/*.html | sha256sum | cut -c -16)
83+
echo "key=runtime-aleph-debian-12-python-$(date +%Y-%m)-${input_hash}" >> "$GITHUB_OUTPUT"
8184
8285
- name: Cache the aleph-debian-12-python runtime
8386
id: cache-runtime
8487
uses: actions/cache@v4
8588
with:
8689
path: runtimes/aleph-debian-12-python/rootfs.squashfs
87-
key: runtime-aleph-debian-12-python-${{ steps.stamp.outputs.month }}-${{ hashFiles('runtimes/aleph-debian-12-python/**') }}
90+
key: ${{ steps.cache-key.outputs.key }}
8891

8992
- name: "Build custom runtimes"
9093
run: |

0 commit comments

Comments
 (0)