at master 1.3 kB view raw
1{ pkgs, ... }: 2{ 3 name = "github-runner"; 4 meta = with pkgs.lib.maintainers; { 5 maintainers = [ veehaitch ]; 6 }; 7 nodes.machine = 8 { pkgs, ... }: 9 { 10 services.github-runners.test = { 11 enable = true; 12 url = "https://github.com/yaxitech"; 13 tokenFile = builtins.toFile "github-runner.token" "not-so-secret"; 14 }; 15 16 services.github-runners.test-disabled = { 17 enable = false; 18 url = "https://github.com/yaxitech"; 19 tokenFile = builtins.toFile "github-runner.token" "not-so-secret"; 20 }; 21 22 systemd.services.dummy-github-com = { 23 wantedBy = [ "multi-user.target" ]; 24 before = [ "github-runner-test.service" ]; 25 script = "${pkgs.netcat}/bin/nc -Fl 443 | true && touch /tmp/registration-connect"; 26 }; 27 networking.hosts."127.0.0.1" = [ "api.github.com" ]; 28 }; 29 30 testScript = '' 31 start_all() 32 33 machine.wait_for_unit("dummy-github-com") 34 35 try: 36 machine.wait_for_unit("github-runner-test") 37 except Exception: 38 pass 39 40 out = machine.succeed("journalctl -u github-runner-test") 41 assert "Self-hosted runner registration" in out, "did not read runner registration header" 42 43 machine.wait_until_succeeds("test -f /tmp/registration-connect") 44 45 machine.fail("systemctl list-unit-files | grep test-disabled") 46 ''; 47}