Skip to content

Commit

Permalink
Combine host and trampoline OS images into one CI job (#4273)
Browse files Browse the repository at this point in the history
There are two OS build jobs that each check out and build many
repositories in order to build a host image. By combining them
into one job, we only pay the cost of this checkout and build
phase once. It doesn't actually save a lot of wall time because
the two jobs run in parallel, but it saves starting a VM and
about 20 minutes of compute time.
  • Loading branch information
citrus-it authored Oct 23, 2023
1 parent 1cd3314 commit 51b6b16
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 81 deletions.
48 changes: 42 additions & 6 deletions .github/buildomat/jobs/host-image.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#!/bin/bash
#:
#: name = "helios / build OS image"
#: name = "helios / build OS images"
#: variety = "basic"
#: target = "helios-2.0"
#: rust_toolchain = "1.72.1"
#: output_rules = [
#: "=/work/helios/image/output/os.tar.gz",
#: "=/work/helios/upload/os-host.tar.gz",
#: "=/work/helios/upload/os-trampoline.tar.gz",
#: ]
#: access_repos = [
#: "oxidecomputer/amd-apcb",
Expand Down Expand Up @@ -44,14 +45,49 @@ TOP=$PWD

source "$TOP/tools/include/force-git-over-https.sh"

# Checkout helios at a pinned commit into /work/helios
git clone https://github.com/oxidecomputer/helios.git /work/helios
cd /work/helios
# Check out helios into /work/helios
HELIOSDIR=/work/helios
git clone https://github.com/oxidecomputer/helios.git "$HELIOSDIR"
cd "$HELIOSDIR"
# Record the branch and commit in the output
git status --branch --porcelain=2
# Setting BUILD_OS to no makes setup skip repositories we don't need for
# building the OS itself (we are just building an image from already built OS).
BUILD_OS=no gmake setup

# Commands that "helios-build" would ask us to run (either explicitly or
# implicitly, to avoid an error).
rc=0
pfexec pkg install -q /system/zones/brand/omicron1/tools || rc=$?
case $rc in
# `man pkg` notes that exit code 4 means no changes were made because
# there is nothing to do; that's fine. Any other exit code is an error.
0 | 4) ;;
*) exit $rc ;;
esac

pfexec zfs create -p "rpool/images/$USER"


# TODO: Consider importing zones here too?

cd "$TOP"
OUTPUTDIR="$HELIOSDIR/upload"
mkdir "$OUTPUTDIR"

banner OS
./tools/build-host-image.sh -B \
-S /input/package/work/zones/switch-asic.tar.gz \
/work/helios \
"$HELIOSDIR" \
/input/package/work/global-zone-packages.tar.gz

mv "$HELIOSDIR/image/output/os.tar.gz" "$OUTPUTDIR/os-host.tar.gz"

banner Trampoline

./tools/build-host-image.sh -R \
"$HELIOSDIR" \
/input/package/work/trampoline-global-zone-packages.tar.gz

mv "$HELIOSDIR/image/output/os.tar.gz" "$OUTPUTDIR/os-trampoline.tar.gz"

54 changes: 0 additions & 54 deletions .github/buildomat/jobs/trampoline-image.sh

This file was deleted.

7 changes: 2 additions & 5 deletions .github/buildomat/jobs/tuf-repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@
#: job = "helios / package"
#:
#: [dependencies.host]
#: job = "helios / build OS image"
#:
#: [dependencies.trampoline]
#: job = "helios / build trampoline OS image"
#: job = "helios / build OS images"
#:
#: [[publish]]
#: series = "rot-all"
Expand Down Expand Up @@ -139,7 +136,7 @@ name = "$kind"
version = "$VERSION"
[artifact.$kind.source]
kind = "file"
path = "/input/$kind/work/helios/image/output/os.tar.gz"
path = "/input/host/work/helios/upload/os-$kind.tar.gz"
EOF
done

Expand Down
16 changes: 0 additions & 16 deletions tools/build-host-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,22 +92,6 @@ function main
# Move to the helios checkout
cd "$HELIOS_PATH"

# Create the "./helios-build" command, which lets us build images
gmake setup

# Commands that "./helios-build" would ask us to run (either explicitly
# or implicitly, to avoid an error).
rc=0
pfexec pkg install -q /system/zones/brand/omicron1/tools || rc=$?
case $rc in
# `man pkg` notes that exit code 4 means no changes were made because
# there is nothing to do; that's fine. Any other exit code is an error.
0 | 4) ;;
*) exit $rc ;;
esac

pfexec zfs create -p rpool/images/"$USER"

HELIOS_REPO=https://pkg.oxide.computer/helios/2/dev/

# Build an image name that includes the omicron and host OS hashes
Expand Down

0 comments on commit 51b6b16

Please sign in to comment.