Skip to content

Commit 92a5ea5

Browse files
committed
ci: Cache Zephyr workspace installation.
Can save several minutes downloading the Zephyr docker image and/or cloning repo from GitHub. Cache keyed on the Zephyr version, which AFAIK is the only determinant for the workspace contents. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <[email protected]>
1 parent d10cda6 commit 92a5ea5

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

.github/workflows/ports_zephyr.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,22 @@ jobs:
3030
docker-images: false
3131
swap-storage: false
3232
- uses: actions/checkout@v4
33+
- id: versions
34+
name: Read Zephyr version
35+
run: source tools/ci.sh && echo "ZEPHYR=$ZEPHYR_VERSION" | tee "$GITHUB_OUTPUT"
36+
- name: Cached Zephyr Workspace
37+
id: cache_workspace
38+
uses: actions/cache@v4
39+
with:
40+
# note that the Zephyr CI docker image is 15GB. At time of writing
41+
# GitHub caches are limited to 10GB total for a project. So we only
42+
# cache the "workspace"
43+
path: ./zephyrproject
44+
key: zephyr-workspace-${{ steps.versions.outputs.ZEPHYR }}
3345
- name: Install packages
3446
run: source tools/ci.sh && ci_zephyr_setup
3547
- name: Install Zephyr
48+
if: steps.cache_workspace.outputs.cache-hit != 'true'
3649
run: source tools/ci.sh && ci_zephyr_install
3750
- name: Build
3851
run: source tools/ci.sh && ci_zephyr_build

tools/ci.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -747,14 +747,24 @@ ZEPHYR_SDK_VERSION=0.16.8
747747
ZEPHYR_VERSION=v3.7.0
748748

749749
function ci_zephyr_setup {
750-
docker pull zephyrprojectrtos/ci:${ZEPHYR_DOCKER_VERSION}
750+
IMAGE=zephyrprojectrtos/ci:${ZEPHYR_DOCKER_VERSION}
751+
752+
docker pull ${IMAGE}
753+
754+
# Directories cached by GitHub Actions, mounted
755+
# into the container
756+
ZEPHYRPROJECT_DIR="$(pwd)/zephyrproject"
757+
758+
mkdir -p "${ZEPHYRPROJECT_DIR}"
759+
751760
docker run --name zephyr-ci -d -it \
752761
-v "$(pwd)":/micropython \
762+
-v "${ZEPHYRPROJECT_DIR}":/zephyrproject \
753763
-e ZEPHYR_SDK_INSTALL_DIR=/opt/toolchains/zephyr-sdk-${ZEPHYR_SDK_VERSION} \
754764
-e ZEPHYR_TOOLCHAIN_VARIANT=zephyr \
755765
-e ZEPHYR_BASE=/zephyrproject/zephyr \
756766
-w /micropython/ports/zephyr \
757-
zephyrprojectrtos/ci:${ZEPHYR_DOCKER_VERSION}
767+
${IMAGE}
758768
docker ps -a
759769

760770
# qemu-system-arm is needed to run the test suite.

0 commit comments

Comments
 (0)