-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip: Do openpilot ci build in a cached ubuntu chroot instead of docker.
- Loading branch information
1 parent
debd71e
commit b706489
Showing
4 changed files
with
197 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: 'build and mount an ubuntu chroot for openpilot ci.' | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
|
||
- name: Calculate Cache Key | ||
id: cache-key | ||
shell: bash | ||
run: echo "CACHE_KEY=chroot-${{ hashFiles('tools/build_ci_chroot.sh') }}" >> $GITHUB_ENV | ||
|
||
- name: Restore cache | ||
id: restore-cache | ||
uses: 'actions/cache/restore@v4' | ||
with: | ||
path: /tmp/chroot.squashfs | ||
key: ${{ env.CACHE_KEY }} | ||
|
||
- name: Rebuild chroot | ||
if: steps.restore-cache.outputs.cache-hit != 'true' | ||
shell: bash | ||
run: | | ||
sudo bash -c "GITHUB_WORKSPACE=$GITHUB_WORKSPACE ./tools/build_ci_chroot.sh" | ||
- name: Cache chroot | ||
if: steps.restore-cache.outputs.cache-hit != 'true' | ||
uses: actions/cache/save@v4 | ||
with: | ||
path: /tmp/chroot.squashfs | ||
key: ${{ env.CACHE_KEY }} | ||
|
||
- name: Mount chroot | ||
shell: bash | ||
run: | | ||
mkdir /tmp/chroot | ||
mkdir /tmp/.chroot_lower | ||
mkdir /tmp/.chroot_upper | ||
mkdir /tmp/.chroot_work | ||
sudo mount -t squashfs /tmp/chroot.squashfs /tmp/.chroot_lower | ||
sudo mount -t overlay overlay -o lowerdir=/tmp/.chroot_lower,upperdir=/tmp/.chroot_upper,workdir=/tmp/.chroot_work /tmp/chroot | ||
sudo mount --bind "$GITHUB_WORKSPACE" /tmp/chroot/tmp/openpilot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
#!/usr/bin/env bash | ||
set -eux | ||
|
||
apt-get update | ||
apt-get install -y debootstrap squashfs-tools | ||
|
||
mkdir /tmp/chroot | ||
|
||
# Install ubuntu into a chroot for us to later install our dependencies into. | ||
debootstrap --variant=minbase noble /tmp/chroot http://archive.ubuntu.com/ubuntu | ||
# The devices cause untar issues and we don't need them. | ||
rm -rf /tmp/chroot/dev/* | ||
|
||
cat <<EOF > /tmp/chroot/etc/apt/sources.list | ||
deb http://archive.ubuntu.com/ubuntu noble main | ||
deb http://archive.ubuntu.com/ubuntu noble universe | ||
deb http://archive.ubuntu.com/ubuntu noble multiverse | ||
deb http://archive.ubuntu.com/ubuntu noble restricted | ||
EOF | ||
|
||
cat <<EOF >> /tmp/chroot/etc/profile | ||
DEBIAN_FRONTEND=noninteractive | ||
NVIDIA_VISIBLE_DEVICES=all | ||
NVIDIA_DRIVER_CAPABILITIES=graphics,utility,compute | ||
QTWEBENGINE_DISABLE_SANDBOX=1 | ||
LANG=en_US.UTF-8 | ||
LANGUAGE=en_US:en | ||
LC_ALL=en_US.UTF-8 | ||
PYTHONUNBUFFERED=1 | ||
EOF | ||
|
||
cat <<EOF > /tmp/chroot/tmp/install-deps.sh | ||
#!/usr/bin/env bash | ||
set -eux | ||
apt-get update | ||
apt-get install -y --no-install-recommends \ | ||
sudo \ | ||
tzdata \ | ||
locales \ | ||
ssh \ | ||
pulseaudio \ | ||
xvfb \ | ||
x11-xserver-utils \ | ||
gnome-screenshot \ | ||
apt-utils \ | ||
alien \ | ||
unzip \ | ||
tar \ | ||
curl \ | ||
xz-utils \ | ||
dbus \ | ||
gcc-arm-none-eabi \ | ||
tmux \ | ||
vim \ | ||
libx11-6 \ | ||
wget | ||
dbus-uuidgen > /etc/machine-id | ||
sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen | ||
locale-gen | ||
cd /tmp/openpilot | ||
./tools/ubuntu_setup.sh | ||
mkdir -p /tmp/opencl-driver-intel | ||
cd /tmp/opencl-driver-intel | ||
wget https://github.com/intel/llvm/releases/download/2024-WW14/oclcpuexp-2024.17.3.0.09_rel.tar.gz | ||
wget https://github.com/oneapi-src/oneTBB/releases/download/v2021.12.0/oneapi-tbb-2021.12.0-lin.tgz | ||
mkdir -p /opt/intel/oclcpuexp_2024.17.3.0.09_rel | ||
cd /opt/intel/oclcpuexp_2024.17.3.0.09_rel | ||
tar -zxvf /tmp/opencl-driver-intel/oclcpuexp-2024.17.3.0.09_rel.tar.gz | ||
mkdir -p /etc/OpenCL/vendors | ||
echo /opt/intel/oclcpuexp_2024.17.3.0.09_rel/x64/libintelocl.so > /etc/OpenCL/vendors/intel_expcpu.icd | ||
cd /opt/intel | ||
tar -zxvf /tmp/opencl-driver-intel/oneapi-tbb-2021.12.0-lin.tgz | ||
ln -s /opt/intel/oneapi-tbb-2021.12.0/lib/intel64/gcc4.8/libtbb.so /opt/intel/oclcpuexp_2024.17.3.0.09_rel/x64 | ||
ln -s /opt/intel/oneapi-tbb-2021.12.0/lib/intel64/gcc4.8/libtbbmalloc.so /opt/intel/oclcpuexp_2024.17.3.0.09_rel/x64 | ||
ln -s /opt/intel/oneapi-tbb-2021.12.0/lib/intel64/gcc4.8/libtbb.so.12 /opt/intel/oclcpuexp_2024.17.3.0.09_rel/x64 | ||
ln -s /opt/intel/oneapi-tbb-2021.12.0/lib/intel64/gcc4.8/libtbbmalloc.so.2 /opt/intel/oclcpuexp_2024.17.3.0.09_rel/x64 | ||
mkdir -p /etc/ld.so.conf.d | ||
echo /opt/intel/oclcpuexp_2024.17.3.0.09_rel/x64 > /etc/ld.so.conf.d/libintelopenclexp.conf | ||
ldconfig -f /etc/ld.so.conf.d/libintelopenclexp.conf | ||
cd / | ||
rm -rf /tmp/opencl-driver-intel | ||
# Remove arm architecture toolchains that we don't want. | ||
cd /usr/lib/gcc/arm-none-eabi/* | ||
rm -rf arm/ thumb/nofp thumb/v6* thumb/v8* thumb/v7+fp thumb/v7-r+fp.sp | ||
git config --global --add safe.directory /tmp/openpilot | ||
# Remove all tmp files except 'openpilot' directory and its contents | ||
find /tmp -mindepth 1 -path '/tmp/openpilot' -prune -o -exec rm -rf {} + | ||
# Remove cached apt archives. | ||
apt clean | ||
EOF | ||
chmod +x /tmp/chroot/tmp/install-deps.sh | ||
|
||
cat <<EOF > /tmp/chroot/run_ci.sh | ||
#!/usr/bin/env bash | ||
set -eux | ||
cd /tmp/openpilot | ||
. ./.venv/bin/activate | ||
ldd ./.venv/bin/python | ||
ldd $(which python) | ||
bash -c "\$1" | ||
EOF | ||
chmod +x /tmp/chroot/run_ci.sh | ||
|
||
cp /etc/resolv.conf /tmp/chroot/resolv.conf | ||
mount --bind /proc /tmp/chroot/proc | ||
mount --bind /sys /tmp/chroot/sys | ||
mount --bind /dev /tmp/chroot/dev | ||
mkdir /tmp/chroot/tmp/openpilot | ||
mount --bind "$GITHUB_WORKSPACE" /tmp/chroot/tmp/openpilot | ||
chroot /tmp/chroot bash /tmp/install-deps.sh | ||
umount /tmp/chroot/tmp/openpilot | ||
umount /tmp/chroot/proc | ||
umount /tmp/chroot/sys | ||
umount /tmp/chroot/dev | ||
cd /tmp/chroot | ||
# A squashfs is faster than docker and we don't need to decompress unused files. | ||
mksquashfs . /tmp/chroot.squashfs -b 256k -comp zstd -Xcompression-level 1 | ||
cd / | ||
rm -rf /tmp/chroot |