fix: tests with podman runner

This commit is contained in:
Gabriel Nützi
2025-11-21 16:42:55 +01:00
parent 9440e4d915
commit 44631a4ce2
16 changed files with 22 additions and 14 deletions
+16 -8
View File
@@ -2,8 +2,8 @@
# two machines `gitlab` and `gitlab-runner`:
# - Create runners in the `gitlab` machine for all runners in `./runner`.
# - Inject the runner tokens into the `gitlab-runner.service` (machine `gitlab-runner`)
# which runs all executors:
# - Shell Executor in `./runner/shell-executor`.
# which runs all runners:
# - Shell runner in `./runner/shell-runner`.
# - Start the `gitlab-runner.service`.
# - Check that all runners in `gitlab` are `active`.
#
@@ -24,19 +24,19 @@ let
runnerConfigs = {
# The Gitlab runner where each job runs
# on the host (not containerized and very insecure).
"shell" = {
desc = "Shell Executor (host NixOS shell, host Nix store)";
shell = {
desc = "Shell runner (host NixOS shell, host Nix store)";
name = "shell";
tokenFile = "${runnerTokenDir}/token-shell.env";
};
# The Gitlab runner which uses the Docker executor (we use podman).
# The Gitlab runner which uses the Docker runner (we use podman).
# Features:
# - Daemonizes the Nix store into a container.
# - All jobs run in an unprivileged container, e.g. with image
# (`local/nix`, `local/alpine`, `local/ubuntu`)
"podman" = {
desc = "Podman Executor (containers, shared containerized Nix store)";
podman = {
desc = "Podman runner (containers, shared containerized Nix store)";
name = "podman";
tokenFile = "${runnerTokenDir}/token-podman.env";
};
@@ -53,7 +53,13 @@ in
{ ... }:
{
imports = [
(import ./runner/shell-executor.nix { inherit runnerConfigs; })
../common/user-account.nix
(import ./runner/shell-runner.nix {
runnerConfig = runnerConfigs.shell;
})
(import ./runner/podman-runner {
runnerConfig = runnerConfigs.shell;
})
];
# Define the Gitlab Runner.
@@ -156,7 +162,9 @@ in
# Run all tests.
test_connection()
test_register_runner(name="shell", tokenFile="${runnerConfigs.shell.tokenFile}")
test_register_runner(name="podman", tokenFile="${runnerConfigs.podman.tokenFile}")
restart_gitlab_runner_service()
test_runner_registered(runnerConfigs["shell"])
test_runner_registered(runnerConfigs["podman"])
'';
}
@@ -46,7 +46,6 @@
# to set `.execConfig.User = 'ci'`
# and see if we can start it with out requiring root.
{
config,
lib,
pkgs,
...
@@ -58,7 +57,7 @@ let
owner = "NixOS";
repo = "nix";
rev = "2.32.4";
hash = "sha256-7D4m+saJjbSFP5hOwpQq2FGR2rr+psQMTcyb1ZvtXsQ=";
hash = "sha256-8QYnRyGOTm3h/Dp8I6HCmQzlO7C009Odqyp28pTWgcY=";
};
# Either we use a Nix as the base image or Alpine.
@@ -71,7 +70,7 @@ let
all = with imageNames; [
alpine
nixRepo
nix
ubuntu
];
};
@@ -85,7 +84,7 @@ let
# derivation will be symlinked in `/`.
auxRootFiles = fs.toSource {
root = ./root;
fileset = fs.gitTracked ./root/etc;
fileset = ./root/etc;
};
preBuildScript = pkgs.callPackage ./scripts/prebuild.nix { };
@@ -356,6 +355,7 @@ let
in
{
imports = [ ./virtualization.nix ];
virtualisation.oci-containers = {
backend = "podman";
@@ -381,7 +381,7 @@ in
inherit registrationFlags;
authenticationTokenConfigFile = config.age.secrets.gitlab-runner-token-config.path;
authenticationTokenConfigFile = runnerConfig.tokenFile;
executor = "docker";
dockerImage = imageNames.default;
@@ -3,7 +3,7 @@
}:
# This is the runner config for the `nixosConfiguration.services.gitlab-runner.services.X`
{
services.gitlab-runner.services = {
services.gitlab-runner.services.shell-runner = {
description = runnerConfig.desc;
authenticationTokenConfigFile = runnerConfig.tokenFile;