Repository navigation
142 lines (126 loc) · 5.57 KB
/
Copy pathci.yml
File metadata and controls
142 lines (126 loc) · 5.57 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
name: CI
# Tests run on every push and pull request. The full build (guest kernel,
# one rootfs per playground version, server), the KVM smoke test of every
# example, and the optional release are started by hand from the Actions tab.
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
inputs:
release:
description: "Publish a GitHub release with the built bundle"
type: boolean
default: false
versions:
description: "Version ids to build, space separated (empty: all in guest/versions.json)"
type: string
default: ""
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: true
jobs:
test:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v7
- uses: actions/setup-go@v7
with:
go-version-file: server/go.mod
cache-dependency-path: server/go.sum
- name: Go vet + unit tests (queue, sessions, versions, HTTP)
run: make test
- name: Static checks
run: |
node --check server/static/app.js
python3 -m py_compile guest/rootfs/agent.py guest/rootfs/pg_ir_capture.py tools/vm_smoke.py tools/release-notes.py
for f in guest/kernel/build-kernel.sh guest/rootfs/build-rootfs.sh guest/rootfs/pg-init \
deploy/install.sh deploy/deploy.sh deploy/cloudflared-route.sh; do bash -n "$f"; done
python3 -c 'import json; v = json.load(open("guest/versions.json")); assert sum(bool(x.get("default")) for x in v) == 1'
build:
if: github.event_name == 'workflow_dispatch'
needs: test
runs-on: ubuntu-24.04
timeout-minutes: 120
permissions:
contents: write # the release step
packages: write # push images + build cache to ghcr.io
env:
# build-rootfs.sh reads these: reuse layers from the registry (no slow
# LLVM download when nothing changed) and push images + cache back.
ROOTFS_REGISTRY: ghcr.io/${{ github.repository_owner }}/pythonbpf-playground-rootfs
ROOTFS_PUSH: "1"
steps:
- uses: actions/checkout@v7
- uses: actions/setup-go@v7
with:
go-version-file: server/go.mod
cache-dependency-path: server/go.sum
- uses: docker/setup-buildx-action@v4
- uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Free disk space
run: sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL && df -h /
# Restore/save separately so the kernel is cached as soon as it is built,
# even if a later step fails (actions/cache only saves on job success).
- name: Restore guest kernel
id: kernel-cache
uses: actions/cache/restore@v6
with:
path: guest/out/vmlinux*
key: kernel-x86_64-${{ hashFiles('guest/kernel/**') }}
- name: Build guest kernel
if: steps.kernel-cache.outputs.cache-hit != 'true'
run: make kernel
- name: Save guest kernel
if: steps.kernel-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v6
with:
path: guest/out/vmlinux*
key: ${{ steps.kernel-cache.outputs.cache-primary-key }}
- name: Build rootfs images
run: |
ids="${{ inputs.versions }}"
[ -n "$ids" ] || ids=$(python3 -c 'import json; print(" ".join(v["id"] for v in json.load(open("guest/versions.json"))))')
for id in $ids; do guest/rootfs/build-rootfs.sh "$id"; done
for m in guest/out/images/*/meta.json; do echo "$m"; cat "$m"; done
- name: Build pgd
run: make pgd
- name: Smoke test every example in a Firecracker VM (KVM)
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules && sudo udevadm trigger --name-match=kvm
tag=$(curl -fsSL https://api.github.com/repos/firecracker-microvm/firecracker/releases/latest | jq -r .tag_name)
mkdir -p dist && curl -fsSL "https://github.com/firecracker-microvm/firecracker/releases/download/$tag/firecracker-$tag-x86_64.tgz" | tar -xz -C dist
export FIRECRACKER="$PWD/dist/release-$tag-x86_64/firecracker-$tag-x86_64"
for d in guest/out/images/*/; do
echo "::group::smoke $(basename "$d")"
python3 tools/vm_smoke.py "$(basename "$d")"
echo "::endgroup::"
done
- name: Assemble bundle
run: |
b=dist/bundle && mkdir -p "$b/images"
cp server/pgd guest/out/vmlinux deploy/install.sh deploy/pgd.service deploy/pg-launcher.service deploy/pg-netns.service "$b/"
cp -r guest/out/images/* "$b/images/"
tar -C "$b" -I 'zstd -19 -T0' -cf dist/pythonbpf-playground-x86_64.tar.zst .
ls -la dist/*.tar.zst
- uses: actions/upload-artifact@v7
with:
name: pythonbpf-playground-x86_64
path: dist/pythonbpf-playground-x86_64.tar.zst
retention-days: 14
compression-level: 0
- name: Publish release
if: inputs.release
env:
GH_TOKEN: ${{ github.token }}
run: |
tag="v$(date -u +%Y.%m.%d)-${{ github.run_number }}"
python3 tools/release-notes.py "$tag" guest/out/images/*/meta.json > notes.md
gh release create "$tag" dist/pythonbpf-playground-x86_64.tar.zst --title "$tag" --notes-file notes.md --target "$GITHUB_SHA"