Skip to content

Commit 72532a5

Browse files
committed
ci: Implement 4-way hash sharding for integration tests
Our integration tests are getting slower, and it's a bit hard to avoid because we really do want to do some medium-expensive thing like disk image generation across multiple base images. Split integration tests across 4 parallel GHA runners using nextest's really cool hash-based sharding. Assisted-by: Claude Code (Sonnet 4.5) Signed-off-by: Colin Walters <walters@verbum.org>
1 parent 5411258 commit 72532a5

1 file changed

Lines changed: 114 additions & 20 deletions

File tree

.github/workflows/main.yml

Lines changed: 114 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ env:
1414

1515

1616
jobs:
17-
build-and-test:
17+
build:
1818
runs-on: ubuntu-24.04
1919

2020
steps:
@@ -30,44 +30,56 @@ jobs:
3030
sudo apt update
3131
sudo apt install -y crun/testing podman/testing just
3232
33-
- name: Enable KVM group perms
34-
run: |
35-
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
36-
sudo udevadm control --reload-rules
37-
sudo udevadm trigger --name-match=kvm
38-
ls -l /dev/kvm
39-
4033
- uses: actions/checkout@v4
4134

35+
- name: Extract image lists from Justfile
36+
run: |
37+
echo "PRIMARY_IMAGE=$(just --evaluate PRIMARY_IMAGE)" >> $GITHUB_ENV
38+
echo "ALL_BASE_IMAGES=$(just --evaluate ALL_BASE_IMAGES)" >> $GITHUB_ENV
39+
4240
- name: Setup Rust
4341
uses: dtolnay/rust-toolchain@stable
44-
42+
4543
- uses: taiki-e/install-action@nextest
4644

4745
- name: Cache build artifacts
4846
uses: Swatinem/rust-cache@v2
4947

5048
- name: Build
5149
run: just validate && just build
52-
50+
5351
- name: Run unit tests
5452
run: just unit
55-
56-
- name: Run integration tests
57-
run: just test-integration
5853

59-
- name: Upload junit XML
60-
if: always()
54+
- name: Pull test images
55+
run: just pull-test-images
56+
57+
- name: Create nextest archive
58+
run: |
59+
cargo nextest archive --release -p integration-tests --archive-file nextest-archive.tar.zst
60+
env:
61+
BCVK_PATH: ${{ github.workspace }}/target/release/bcvk
62+
BCVK_PRIMARY_IMAGE: ${{ env.PRIMARY_IMAGE }}
63+
BCVK_ALL_IMAGES: ${{ env.ALL_BASE_IMAGES }}
64+
65+
- name: Upload nextest archive
6166
uses: actions/upload-artifact@v4
6267
with:
63-
name: integration-junit-xml
64-
path: target/nextest/integration/junit.xml
68+
name: nextest-archive
69+
path: nextest-archive.tar.zst
6570
retention-days: 7
6671

67-
- name: Create archive
72+
- name: Upload bcvk binary for tests
73+
uses: actions/upload-artifact@v4
74+
with:
75+
name: bcvk-binary-tests
76+
path: target/release/bcvk
77+
retention-days: 7
78+
79+
- name: Create bcvk archive
6880
run: just archive
69-
70-
- name: Upload artifacts
81+
82+
- name: Upload bcvk binary artifacts
7183
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
7284
uses: actions/upload-artifact@v4
7385
with:
@@ -76,3 +88,85 @@ jobs:
7688
target/bcvk-*.tar.gz
7789
target/bcvk-*.tar.gz.sha256
7890
retention-days: 7
91+
92+
integration-tests:
93+
runs-on: ubuntu-24.04
94+
needs: build
95+
strategy:
96+
fail-fast: false
97+
matrix:
98+
partition: [1, 2, 3, 4]
99+
100+
steps:
101+
- name: Install dependencies
102+
run: |
103+
sudo apt update
104+
sudo apt install -y just pkg-config go-md2man libvirt-daemon libvirt-clients qemu-kvm qemu-system qemu-utils virtiofsd
105+
106+
- name: Install podman for heredoc support
107+
run: |
108+
set -eux
109+
echo 'deb [trusted=yes] https://ftp.debian.org/debian/ testing main' | sudo tee /etc/apt/sources.list.d/testing.list
110+
sudo apt update
111+
sudo apt install -y crun/testing podman/testing just
112+
113+
- name: Enable KVM group perms
114+
run: |
115+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
116+
sudo udevadm control --reload-rules
117+
sudo udevadm trigger --name-match=kvm
118+
ls -l /dev/kvm
119+
120+
- uses: actions/checkout@v4
121+
122+
- name: Extract image lists from Justfile
123+
run: |
124+
echo "PRIMARY_IMAGE=$(just --evaluate PRIMARY_IMAGE)" >> $GITHUB_ENV
125+
echo "ALL_BASE_IMAGES=$(just --evaluate ALL_BASE_IMAGES)" >> $GITHUB_ENV
126+
127+
- name: Setup Rust
128+
uses: dtolnay/rust-toolchain@stable
129+
130+
- uses: taiki-e/install-action@nextest
131+
132+
- name: Pull test images
133+
run: just pull-test-images
134+
135+
- name: Download nextest archive
136+
uses: actions/download-artifact@v4
137+
with:
138+
name: nextest-archive
139+
140+
- name: Download bcvk binary
141+
uses: actions/download-artifact@v4
142+
with:
143+
name: bcvk-binary-tests
144+
path: target/release
145+
146+
- name: Make bcvk executable
147+
run: chmod +x target/release/bcvk
148+
149+
- name: Run integration tests (partition ${{ matrix.partition }}/4)
150+
run: |
151+
# Clean up any leftover containers before starting
152+
cargo run --release --bin test-cleanup -p integration-tests 2>/dev/null || true
153+
154+
# Run the partitioned tests
155+
cargo nextest run --archive-file nextest-archive.tar.zst \
156+
--profile integration \
157+
--partition hash:${{ matrix.partition }}/4
158+
159+
# Clean up containers after tests complete
160+
cargo run --release --bin test-cleanup -p integration-tests 2>/dev/null || true
161+
env:
162+
BCVK_PATH: ${{ github.workspace }}/target/release/bcvk
163+
BCVK_PRIMARY_IMAGE: ${{ env.PRIMARY_IMAGE }}
164+
BCVK_ALL_IMAGES: ${{ env.ALL_BASE_IMAGES }}
165+
166+
- name: Upload junit XML
167+
if: always()
168+
uses: actions/upload-artifact@v4
169+
with:
170+
name: integration-junit-xml-${{ matrix.partition }}
171+
path: target/nextest/integration/junit.xml
172+
retention-days: 7

0 commit comments

Comments
 (0)