@@ -2,109 +2,9 @@
22 supportedPlatforms ? [ "x86_64-linux" "x86_64-darwin" ]
33}:
44let
5− nginxRoot = "/run/nginx";
6− obelisk = import ./default.nix {};
7− # Get NixOS a pre-release 20.03 that contains the python based tests and recursive nix
8− pkgs = import (builtins.fetchTarball https://github.com/nixos/nixpkgs/archive/3de5266.tar.gz) {};
9− sshKeys = import (pkgs.path + /nixos/tests/ssh-keys.nix) pkgs;
10− make-test = import (pkgs.path + /nixos/tests/make-test-python.nix);
115 obelisk-everywhere = (import ./everywhere.nix { cacheBuildSystems = supportedPlatforms; }).metaCache;
12− snakeOilPrivateKey = sshKeys.snakeOilPrivateKey.text;
13− snakeOilPublicKey = sshKeys.snakeOilPublicKey;
6+ obelisk-test = import ./test.nix;
147in {
15− recurseForDerivations = true;
168 build = obelisk-everywhere;
17− test = make-test ({...}: {
18− name = "obelisk";
19− nodes = {
20− githost = {
21− networking.firewall.allowedTCPPorts = [ 22 80 ];
22− services.openssh = {
23− enable = true;
24− };
25− environment.systemPackages = [
26− pkgs.git
27− ];
28− users.users.root.openssh.authorizedKeys.keys = [
29− snakeOilPublicKey
30− ];
31− };
32−
33− client = {
34− imports = [
35− (pkgs.path + /nixos/modules/installer/cd-dvd/channel.nix)
36− ];
37− nix.useSandbox = false;
38− nix.binaryCaches = [];
39− environment.systemPackages = [
40− obelisk.command
41− obelisk.shell
42− obelisk-everywhere
43− pkgs.git
44− ];
45− };
46− };
47−
48− testScript =
49− let
50− privateKeyFile = pkgs.writeText "id_rsa" ''${snakeOilPrivateKey}'';
51− sshConfigFile = pkgs.writeText "ssh_config" ''
52− Host *
53− StrictHostKeyChecking no
54− UserKnownHostsFile=/dev/null
55− ConnectionAttempts=1
56− ConnectTimeout=1
57− IdentityFile=~/.ssh/id_rsa
58− User=root
59− '';
60− in ''
61− start_all()
62− githost.wait_for_open_port("22")
63−
64− with subtest("test obelisk is installed"):
65− client.succeed("ob --help")
66−
67− with subtest("test the client can access the server via ssh"):
68− client.succeed("mkdir -p ~/.ssh/")
69− client.succeed(
70− "cp ${privateKeyFile} ~/.ssh/id_rsa"
71− )
72− client.succeed("chmod 600 ~/.ssh/id_rsa")
73− client.wait_until_succeeds(
74− "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa githost true"
75− )
76− client.succeed(
77− "cp ${sshConfigFile} ~/.ssh/config"
78− )
79− client.wait_until_succeeds("ssh githost true")
80−
81− with subtest("test a remote bare repo can be started"):
82− githost.succeed("mkdir -p ~/myorg/myapp.git")
83− githost.succeed("cd ~/myorg/myapp.git && git init --bare")
84−
85− with subtest("test a git project can be configured with a remote using ssh"):
86− client.succeed("mkdir -p ~/code/myapp")
87− client.succeed("cd ~/code/myapp && git init")
88− client.succeed("cd ~/code/myapp && touch README")
89− client.succeed("cd ~/code/myapp && git add .")
90− client.succeed('git config --global user.email "you@example.com"')
91− client.succeed('git config --global user.name "Your Name"')
92− client.succeed('cd ~/code/myapp && git commit -m "Initial"')
93− client.succeed(
94− "cd ~/code/myapp && git remote add origin root@githost:/root/myorg/myapp.git"
95− )
96−
97− with subtest("test pushing code to the remote"):
98− client.succeed("cd ~/code/myapp && git push -u origin master")
99− client.succeed("cd ~/code/myapp && git status")
100−
101− with subtest("test obelisk can pack"):
102− client.succeed("ob thunk pack ~/code/myapp")
103− client.succeed("grep -qF 'git' ~/code/myapp/default.nix")
104− client.succeed("grep -qF 'myorg' ~/code/myapp/git.json")
105−
106− with subtest("test obelisk can detect private repos"):
107− client.succeed("""grep -qF '"private": false' ~/code/myapp/git.json""")
108− '';
109− }) {};
9+ test = obelisk-test;
11010}