Repository navigation
94 lines (92 loc) · 4.11 KB
/
Copy pathbuild-glbx.yml
File metadata and controls
94 lines (92 loc) · 4.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: build-glbx
# Reusable: compile glbx and the sandbox stub from a glbx ref for every shipped
# architecture and share each pair of binaries with the jobs that need them as
# run-scoped artifacts (glbx-bin-amd64, glbx-bin-arm64). glbx is pure Go, so one
# runner cross-compiles both arches via `make cross`; only the native per-node
# image build runs on its own architecture (handled by the node runner map).
#
# The build happens inside glbx's own devcontainer (.devcontainer/Containerfile)
# via rootless podman, mirroring how glbx's own CI builds it — so the build-time
# toolchain (Go, protoc, protoc-gen-go, …) is exactly the pinned, well-defined set
# the devcontainer ships, not whatever the runner happens to have. The downstream
# jobs run the resulting binary directly on the host (no container layer).
#
# Across runs the compiled binaries are cached in the GitHub Actions cache, keyed
# by the exact glbx commit the input ref resolves to (glbx-build@<sha>, both
# arches in one entry). The input ref is a branch/tag that can point at a
# different commit each run, so the key is the resolved SHA, not the ref name. On
# a cache hit the devcontainer build AND the cross-compile are both skipped — the
# restored bin-<arch>/ dirs are re-emitted as the run-scoped artifacts exactly as a
# fresh build would. On a miss we build, upload, and the cache is saved post-job.
on:
workflow_call:
inputs:
glbx-ref:
description: glbx ref (branch, tag, or full SHA) to build the executor from
default: main
type: string
jobs:
build-glbx:
runs-on: ubuntu-latest
steps:
- name: Check out glbx
uses: actions/checkout@v5
with:
repository: gardenlinux/glbx
ref: ${{ inputs.glbx-ref || 'main' }}
- name: Resolve the glbx commit for the cache key
id: rev
# The input ref is a moving branch/tag; key the cache on the commit it
# resolves to so a branch that advanced rebuilds while an unchanged commit
# hits regardless of which ref name reached it.
run: echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
- name: Restore cached glbx binaries
id: cache
uses: actions/cache@v4
with:
path: |
bin-amd64
bin-arm64
key: glbx-build@${{ steps.rev.outputs.sha }}
- name: Prepare rootless podman (unprivileged userns + subid ranges)
if: steps.cache.outputs.cache-hit != 'true'
run: |
sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
user="$(id -un)"
start=$(awk -F: '
NF == 3 { end = $2 + $3; if (end > max) max = end }
END { print int((max + 99999) / 100000) * 100000 }
' /etc/subuid /etc/subgid)
sudo sed -i "/^${user}:/d" /etc/subuid /etc/subgid
echo "${user}:${start}:1000000" | sudo tee -a /etc/subuid /etc/subgid
podman system migrate
- name: Build the glbx devcontainer
if: steps.cache.outputs.cache-hit != 'true'
# NODOC=1 skips the Rust/mdbook layer — staging only needs `make cross`,
# never `make doc`, and compiling mdbook dominates the image build.
run: podman build --build-arg NODOC=1 -t glbx-dev .devcontainer
- name: Cross-compile glbx and the sandbox stub for every arch
if: steps.cache.outputs.cache-hit != 'true'
run: >
podman run --rm
--tmpfs /tmp
--security-opt 'unmask=/proc/*'
--security-opt seccomp=unconfined
--security-opt label=disable
--security-opt apparmor=unconfined
--userns keep-id:uid=1000,gid=1000
-v "$GITHUB_WORKSPACE:/home/dev/workspace"
-w /home/dev/workspace
glbx-dev make cross
- name: Share the amd64 binaries with the node jobs
uses: actions/upload-artifact@v6
with:
name: glbx-bin-amd64
path: bin-amd64/
retention-days: 1
- name: Share the arm64 binaries with the node jobs
uses: actions/upload-artifact@v6
with:
name: glbx-bin-arm64
path: bin-arm64/
retention-days: 1