Skip to content

Commit 61f5d22

Browse files
committed
zswatch: Optimize to keep container small to work with Github hosted runners.
1 parent 0917f3b commit 61f5d22

File tree

3 files changed

+63
-218
lines changed

3 files changed

+63
-218
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
1-
name: CI
1+
name: Upstream CI (disabled in fork)
22

33
on:
4-
push:
5-
branches:
6-
- main
7-
- v*-branch
8-
tags:
9-
- v*
10-
pull_request:
11-
branches:
12-
- main
13-
- v*-branch
4+
# Disabled in this fork to avoid relying on Zephyr's
5+
# self-hosted runners and DockerHub credentials.
6+
# Kept only for reference and manual runs.
7+
workflow_dispatch:
148

159
permissions:
1610
packages: write
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Build and publish ZSWatch CI image
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- zswatch_*
8+
paths:
9+
- Dockerfile.base
10+
- Dockerfile.ci
11+
- .github/workflows/zswatch-ci-image.yml
12+
workflow_dispatch:
13+
14+
permissions:
15+
contents: read
16+
packages: write
17+
18+
jobs:
19+
build-and-push-ci:
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
26+
- name: Set up Docker Buildx
27+
uses: docker/setup-buildx-action@v3
28+
29+
- name: Log in to GitHub Container Registry
30+
uses: docker/login-action@v3
31+
with:
32+
registry: ghcr.io
33+
username: ${{ github.actor }}
34+
password: ${{ secrets.GITHUB_TOKEN }}
35+
36+
- name: Build base image (local only)
37+
uses: docker/build-push-action@v5
38+
with:
39+
context: .
40+
file: ./Dockerfile.base
41+
push: false
42+
load: true
43+
tags: ci-base:local
44+
45+
- name: Build and push CI image
46+
uses: docker/build-push-action@v5
47+
with:
48+
context: .
49+
file: ./Dockerfile.ci
50+
push: true
51+
tags: |
52+
ghcr.io/zswatch/zswatch-ci:latest
53+
ghcr.io/zswatch/zswatch-ci:${{ github.ref_name }}
54+
build-args: |
55+
BASE_IMAGE=ci-base:local

Dockerfile.ci

Lines changed: 3 additions & 207 deletions
Original file line numberDiff line numberDiff line change
@@ -11,197 +11,15 @@ ARG UBUNTU_MIRROR_PORTS=ports.ubuntu.com/ubuntu-ports
1111

1212
ARG ZSDK_VERSION=0.17.4
1313
ENV ZSDK_VERSION=$ZSDK_VERSION
14-
ARG KITWARE_NINJA_VERSION=1.11.1.g95dee.kitware.jobserver-1
15-
ENV KITWARE_NINJA_VERSION=$KITWARE_NINJA_VERSION
16-
ARG CCACHE_VERSION=4.9.1
17-
ENV CCACHE_VERSION=$CCACHE_VERSION
18-
ARG DOXYGEN_VERSION=1.14.0
19-
ENV DOXYGEN_VERSION=$DOXYGEN_VERSION
20-
ARG RENODE_VERSION=1.15.3
21-
ENV RENODE_VERSION=$RENODE_VERSION
22-
ARG LLVM_VERSION=20
23-
ENV LLVM_VERSION=$LLVM_VERSION
24-
ARG BSIM_VERSION=v2.7
25-
ENV BSIM_VERSION=$BSIM_VERSION
26-
ARG SPARSE_VERSION=9212270048c3bd23f56c20a83d4f89b870b2b26e
27-
ENV SPARSE_VERSION=$SPARSE_VERSION
28-
ARG PROTOC_VERSION=21.7
29-
ENV PROTOC_VERSION=$PROTOC_VERSION
30-
ARG FVP_BASE_REVC_VERSION=11.27_19
31-
ENV FVP_BASE_REVC_VERSION=$FVP_BASE_REVC_VERSION
32-
ARG FVP_BASE_AEMV8R_VERSION=11.27_19
33-
ENV FVP_BASE_AEMV8R_VERSION=$FVP_BASE_AEMV8R_VERSION
34-
ARG FVP_CORSTONE300_VERSION=11.27_42
35-
ENV FVP_CORSTONE300_VERSION=$FVP_CORSTONE300_VERSION
36-
ARG FVP_CORSTONE310_VERSION=11.27_42
37-
ENV FVP_CORSTONE310_VERSION=$FVP_CORSTONE310_VERSION
38-
ARG FVP_CORSTONE315_VERSION=11.27_42
39-
ENV FVP_CORSTONE315_VERSION=$FVP_CORSTONE315_VERSION
40-
ARG FVP_CORSTONE320_VERSION=11.27_25
41-
ENV FVP_CORSTONE320_VERSION=$FVP_CORSTONE320_VERSION
42-
43-
# Install APT packages
14+
# Install minimal extra APT packages required for ZSWatch CI
4415
RUN <<EOF
45-
# Set up custom Ubuntu APT mirrors
46-
pushd /etc/apt/sources.list.d
47-
cp ubuntu.sources ubuntu.sources.bak
48-
sed -i "s#archive.ubuntu.com/ubuntu#${UBUNTU_MIRROR_ARCHIVE}#" ubuntu.sources
49-
sed -i "s#security.ubuntu.com/ubuntu#${UBUNTU_MIRROR_SECURITY}#" ubuntu.sources
50-
sed -i "s#ports.ubuntu.com/ubuntu-ports#${UBUNTU_MIRROR_PORTS}#" ubuntu.sources
51-
popd
52-
53-
# Install LLVM and Clang
54-
wget ${WGET_ARGS} https://apt.llvm.org/llvm.sh
55-
chmod +x llvm.sh
56-
./llvm.sh ${LLVM_VERSION} all
57-
rm -f llvm.sh
58-
59-
# Install Python 3.9 for FVP
60-
add-apt-repository -y ppa:deadsnakes/ppa
6116
apt-get update -y
62-
apt-get install -y python3.9-dev
63-
64-
# Clean up stale packages
65-
apt-get autoremove --purge -y
17+
apt-get install --no-install-recommends -y \
18+
clang-format
6619

6720
# Clean up local repository
6821
apt-get clean -y
6922
rm -rf /var/lib/apt/lists/*
70-
71-
# Restore original Ubuntu mirrors
72-
pushd /etc/apt/sources.list.d
73-
mv -f ubuntu.sources.bak ubuntu.sources
74-
popd
75-
EOF
76-
77-
# Install Kitware ninja
78-
# NOTE: Pre-built Kitware ninja binaries are only available for x86_64 host.
79-
RUN <<EOF
80-
if [ "${HOSTTYPE}" = "x86_64" ]; then
81-
wget ${WGET_ARGS} https://github.com/Kitware/ninja/releases/download/v${KITWARE_NINJA_VERSION}/ninja-${KITWARE_NINJA_VERSION}_x86_64-linux-gnu.tar.gz
82-
tar xf ninja-${KITWARE_NINJA_VERSION}_x86_64-linux-gnu.tar.gz -C /opt
83-
ln -s /opt/ninja-${KITWARE_NINJA_VERSION}_x86_64-linux-gnu/ninja /usr/local/bin
84-
rm ninja-${KITWARE_NINJA_VERSION}_x86_64-linux-gnu.tar.gz
85-
fi
86-
EOF
87-
88-
# Install ccache
89-
# NOTE: Pre-built ccache binaries are only available for x86_64 host.
90-
RUN <<EOF
91-
if [ "${HOSTTYPE}" = "x86_64" ]; then
92-
wget ${WGET_ARGS} https://github.com/ccache/ccache/releases/download/v${CCACHE_VERSION}/ccache-${CCACHE_VERSION}-linux-x86_64.tar.xz
93-
tar xf ccache-${CCACHE_VERSION}-linux-x86_64.tar.xz -C /opt
94-
ln -s /opt/ccache-${CCACHE_VERSION}-linux-x86_64/ccache /usr/local/bin
95-
rm ccache-${CCACHE_VERSION}-linux-x86_64.tar.xz
96-
fi
97-
EOF
98-
99-
# Install Doxygen (x86 only)
100-
# NOTE: Pre-built Doxygen binaries are only available for x86_64 host.
101-
RUN <<EOF
102-
if [ "${HOSTTYPE}" = "x86_64" ]; then
103-
wget ${WGET_ARGS} "https://github.com/doxygen/doxygen/releases/download/Release_${DOXYGEN_VERSION//./_}/doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz"
104-
tar xf doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz -C /opt
105-
ln -s /opt/doxygen-${DOXYGEN_VERSION}/bin/doxygen /usr/local/bin
106-
rm doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz
107-
fi
108-
EOF
109-
110-
# Install BSIM
111-
# Note: west needs an extra folder level, so we create a link to the old location to be backwards compatible
112-
RUN <<EOF
113-
mkdir -p /opt/bsim_west
114-
cd /opt/
115-
west init -m https://github.com/zephyrproject-rtos/babblesim-manifest.git --mr ${BSIM_VERSION} bsim_west
116-
cd bsim_west/bsim
117-
west update
118-
make everything -j 8
119-
echo ${BSIM_VERSION} > ./version
120-
chmod ag+w . -R
121-
ln -s /opt/bsim_west/bsim /opt/bsim
122-
EOF
123-
124-
# Install sparse package for static analysis
125-
RUN <<EOF
126-
mkdir -p /opt/sparse
127-
cd /opt/sparse
128-
git clone https://git.kernel.org/pub/scm/devel/sparse/sparse.git
129-
cd sparse
130-
git checkout ${SPARSE_VERSION}
131-
make -j8
132-
PREFIX=/opt/sparse make install
133-
rm -rf /opt/sparse/sparse
134-
EOF
135-
136-
# Install protobuf-compiler
137-
RUN <<EOF
138-
mkdir -p /opt/protoc
139-
cd /opt/protoc
140-
PROTOC_HOSTTYPE=$(case $HOSTTYPE in x86_64) echo "x86_64";; aarch64) echo "aarch_64";; esac)
141-
wget ${WGET_ARGS} https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-${PROTOC_HOSTTYPE}.zip
142-
unzip protoc-${PROTOC_VERSION}-linux-${PROTOC_HOSTTYPE}.zip
143-
ln -s /opt/protoc/bin/protoc /usr/local/bin
144-
rm -f protoc-${PROTOC_VERSION}-linux-${PROTOC_HOSTTYPE}.zip
145-
EOF
146-
147-
# Install renode (x86 only)
148-
# NOTE: Renode is currently only available for x86_64 host.
149-
# We're using the portable version of Renode, which is self-contained and includes dotnet
150-
RUN <<EOF
151-
if [ "${HOSTTYPE}" = "x86_64" ]; then
152-
RENODE_FILE=renode-${RENODE_VERSION}.linux-portable-dotnet.tar.gz
153-
wget ${WGET_ARGS} https://github.com/renode/renode/releases/download/v${RENODE_VERSION}/${RENODE_FILE}
154-
mkdir -p /opt/renode
155-
tar xf ${RENODE_FILE} -C /opt/renode --strip-components=1
156-
rm ${RENODE_FILE}
157-
pip3 install -r /opt/renode/tests/requirements.txt --no-cache-dir
158-
fi
159-
EOF
160-
161-
# Add renode to path, make sure not to use the host's path,
162-
# see https://stackoverflow.com/a/65119275
163-
ENV PATH="/opt/renode:$PATH"
164-
165-
# Install FVP
166-
#
167-
# Ecosystem FVP License permits redistribution (refer to the relevant license available in the container).
168-
RUN <<EOF
169-
mkdir -p /opt/fvps
170-
cd /opt/fvps
171-
172-
if [ "${HOSTTYPE}" = "x86_64" ]; then
173-
SUFFIX=""
174-
else
175-
SUFFIX="_armv8l"
176-
fi
177-
178-
declare -A FVP_INSTALLABLE=(
179-
["300"]="${FVP_CORSTONE300_VERSION}"
180-
["310"]="${FVP_CORSTONE310_VERSION}"
181-
["315"]="${FVP_CORSTONE315_VERSION}"
182-
["320"]="${FVP_CORSTONE320_VERSION}"
183-
)
184-
for corstone in ${!FVP_INSTALLABLE[@]}; do
185-
version_build="${FVP_INSTALLABLE[$corstone]}"
186-
echo "Downloading Corstone-${corstone} ${version_build}"
187-
wget ${WGET_ARGS} -O- https://developer.arm.com/-/cdn-downloads/permalink/FVPs-Corstone-IoT/Corstone-${corstone}/FVP_Corstone_SSE-${corstone}_${version_build}_Linux64${SUFFIX}.tgz | tar xz
188-
./FVP_Corstone_SSE-${corstone}.sh --no-interactive --i-agree-to-the-contained-eula -d /opt/fvps/Corstone-${corstone}
189-
rm FVP_Corstone_SSE-${corstone}.sh
190-
ln -s /opt/fvps/Corstone-${corstone}/models/*/FVP_* /usr/local/bin
191-
done
192-
193-
declare -A FVP_EXTRACTABLE=(
194-
["RevC-2xAEMvA"]="${FVP_BASE_REVC_VERSION}"
195-
["AEMv8R"]="${FVP_BASE_AEMV8R_VERSION}"
196-
)
197-
for base in ${!FVP_EXTRACTABLE[@]}; do
198-
version_build="${FVP_EXTRACTABLE[$base]}"
199-
echo "Downloading Base-${base} ${FVP_EXTRACTABLE[$base]}"
200-
IFS="_" read version build <<< "${version_build}"
201-
wget ${WGET_ARGS} -O- https://developer.arm.com/-/cdn-downloads/permalink/FVPs-Architecture/FM-${version}/FVP_Base_${base}_${version_build}_Linux64${SUFFIX}.tgz | tar xz
202-
done
203-
204-
ln -s /opt/fvps/*_pkg/models/*/FVP_* /usr/local/bin
20523
EOF
20624

20725
# Install Zephyr SDK
@@ -228,29 +46,7 @@ EOF
22846

22947
USER root
23048

231-
# Set up Rust
232-
RUN <<EOF
233-
# Install Cargo package manager
234-
wget -q -O- "https://sh.rustup.rs" | sh -s -- -y --default-toolchain 1.86
235-
236-
# Make Cargo globally available for subsequent steps
237-
PATH=~/.cargo/bin:$PATH
238-
239-
# Install uefi-run utility
240-
cargo install uefi-run --root /usr
241-
242-
# Install Rust target support required by Zephyr
243-
rustup target install riscv32i-unknown-none-elf
244-
rustup target install riscv64imac-unknown-none-elf
245-
rustup target install thumbv6m-none-eabi
246-
rustup target install thumbv7em-none-eabi
247-
rustup target install thumbv7m-none-eabi
248-
rustup target install thumbv8m.main-none-eabi
249-
rustup target install x86_64-unknown-none
250-
EOF
251-
25249
# Set build environment variables
25350
ENV ZEPHYR_TOOLCHAIN_VARIANT=zephyr
25451
ENV PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu/pkgconfig
25552
ENV OVMF_FD_PATH=/usr/share/ovmf/OVMF.fd
256-
ENV ARMFVP_BIN_PATH=/usr/local/bin

0 commit comments

Comments
 (0)