GitHub Actions: run tests in nix-shell, not Docker

This commit is contained in:
Michael Stapelberg
2025-07-20 22:50:54 +02:00
parent 2e5277d689
commit 29b8fbd4f8
4 changed files with 16 additions and 47 deletions

View File

@@ -41,10 +41,9 @@ jobs:
with:
go-version: 'stable'
- name: Build Docker container with the tools our tests require
run: |
docker build --pull --no-cache --rm -t=router7 -f travis/Dockerfile .
- uses: cachix/install-nix-action@v31
with:
nix_path: nixpkgs=channel:nixos-25.05
- name: Run tests in Docker container
run: |
exit=0; for pkg in $(go list ./integration/...); do go test -c $pkg && docker run --privileged --net=host -v $PWD:/usr/src:ro router7 /bin/sh -c "./$(basename $pkg).test -test.v" || exit=1; done; [ $exit = 0 ]
- name: Run tests in nix-shell
run: nix-shell --command 'make test'

11
shell.nix Normal file
View File

@@ -0,0 +1,11 @@
{
pkgs ? import <nixpkgs> { },
}:
pkgs.mkShell {
packages = with pkgs; [
dnsmasq
dig
ndisc6
nftables
];
}

View File

@@ -1,18 +0,0 @@
# vim:ft=Dockerfile
FROM debian:sid
RUN echo force-unsafe-io > /etc/dpkg/dpkg.cfg.d/docker-apt-speedup
# Paper over occasional network flakiness of some mirrors.
RUN echo 'APT::Acquire::Retries "5";' > /etc/apt/apt.conf.d/80retry
# NOTE: I tried exclusively using gce_debian_mirror.storage.googleapis.com
# instead of httpredir.debian.org, but the results (Fetched 123 MB in 36s (3357
# kB/s)) are not any better than httpredir.debian.org (Fetched 123 MB in 34s
# (3608 kB/s)). Hence, lets stick with httpredir.debian.org (default) for now.
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
dnsmasq ndisc6 nftables bind9-dnsutils strace wireguard iproute2 && \
rm -rf /var/lib/apt/lists/*
WORKDIR /usr/src

View File

@@ -1,23 +0,0 @@
#!/bin/bash
loopdev=$(sudo losetup -Pf --show /tmp/router7-qemu/disk.img)
sudo mkfs.ext4 -m 1 "${loopdev}p4"
sudo mount "${loopdev}p4" /mnt
# TODO: make github.com/gokrazy/serial-busybox work with GOARCH=amd64
sudo cp ~/src/busybox-1.22.0-amd64/busybox /mnt/sh || true
cat <<'EOT' | sudo tee /mnt/interfaces.json
{
"interfaces": [
{
"hardware_addr": "52:55:00:d1:55:03",
"name": "uplink0"
},
{
"hardware_addr": "52:55:00:d1:55:04",
"name": "lan0",
"addr": "10.254.0.1/24"
}
]
}
EOT
sudo umount /mnt
sudo losetup -d "${loopdev}"