From e8df83d417a65f84914ee27da98b870c0e7d143c Mon Sep 17 00:00:00 2001 From: Vincent Haupert Date: Sun, 26 Feb 2023 13:50:49 +0100 Subject: [PATCH] nixos/tests/github-runner: init --- nixos/tests/all-tests.nix | 1 + nixos/tests/github-runner.nix | 37 +++++++++++++++++++ .../github-runner/default.nix | 6 ++- 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 nixos/tests/github-runner.nix diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 785a5621f57e..81f5b0cf7fe4 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -243,6 +243,7 @@ in { ghostunnel = handleTest ./ghostunnel.nix {}; gitdaemon = handleTest ./gitdaemon.nix {}; gitea = handleTest ./gitea.nix { giteaPackage = pkgs.gitea; }; + github-runner = handleTest ./github-runner.nix {}; gitlab = handleTest ./gitlab.nix {}; gitolite = handleTest ./gitolite.nix {}; gitolite-fcgiwrap = handleTest ./gitolite-fcgiwrap.nix {}; diff --git a/nixos/tests/github-runner.nix b/nixos/tests/github-runner.nix new file mode 100644 index 000000000000..033365d6925c --- /dev/null +++ b/nixos/tests/github-runner.nix @@ -0,0 +1,37 @@ +import ./make-test-python.nix ({ pkgs, ... }: +{ + name = "github-runner"; + meta = with pkgs.lib.maintainers; { + maintainers = [ veehaitch ]; + }; + nodes.machine = { pkgs, ... }: { + services.github-runners.test = { + enable = true; + url = "https://github.com/yaxitech"; + tokenFile = builtins.toFile "github-runner.token" "not-so-secret"; + }; + + systemd.services.dummy-github-com = { + wantedBy = [ "multi-user.target" ]; + before = [ "github-runner-test.service" ]; + script = "${pkgs.netcat}/bin/nc -Fl 443 | true && touch /tmp/registration-connect"; + }; + networking.hosts."127.0.0.1" = [ "api.github.com" ]; + }; + + testScript = '' + start_all() + + machine.wait_for_unit("dummy-github-com") + + try: + machine.wait_for_unit("github-runner-test") + except Exception: + pass + + out = machine.succeed("journalctl -u github-runner-test") + assert "Self-hosted runner registration" in out, "did not read runner registration header" + + machine.wait_until_succeeds("test -f /tmp/registration-connect") + ''; +}) diff --git a/pkgs/development/tools/continuous-integration/github-runner/default.nix b/pkgs/development/tools/continuous-integration/github-runner/default.nix index 91b593f72943..e6b22a99bd17 100644 --- a/pkgs/development/tools/continuous-integration/github-runner/default.nix +++ b/pkgs/development/tools/continuous-integration/github-runner/default.nix @@ -8,6 +8,7 @@ , glibc , glibcLocales , lib +, nixosTests , nodejs-16_x , stdenv , which @@ -250,7 +251,10 @@ buildDotnetModule rec { runHook postInstallCheck ''; - passthru.updateScript = ./update.sh; + passthru = { + tests.smoke-test = nixosTests.github-runner; + updateScript = ./update.sh; + }; meta = with lib; { changelog = "https://github.com/actions/runner/releases/tag/v${version}";