on master help sign in
Sidestep CI limitations to run other files
commitc8e71d404fedbffaf6120cbe343df8376400895f authorAriel Nunez <ingenieroariel@gmail.com> dateWed 8 Jan 2020, 17:20 (7 years ago) parentf8b926f
3 files changed+195−193
everywhere.nix+96 release.nix+99−91 test.nix−102
everywhere.nixnew file+96
@@ -0,0 +1,96 @@
1+{ self-args ? {
2+ config.android_sdk.accept_license = true;
3+ iosSdkVersion = "10.2";
4+ }
5+, local-self ? import ./. self-args
6+, cacheBuildSystems ? [ "x86_64-linux" "x86_64-darwin" ]
7+}:
8+
9+let
10+ inherit (local-self.nixpkgs) lib runCommand nix;
11+
12+ obeliskPackagesCommon = [
13+ "obelisk-frontend"
14+ "obelisk-route"
15+ "obelisk-executable-config-lookup"
16+ ];
17+
18+ obeliskPackagesBackend = obeliskPackagesCommon ++ [
19+ "obelisk-asset-manifest"
20+ "obelisk-asset-serve-snap"
21+ "obelisk-backend"
22+ "obelisk-cliapp"
23+ "obelisk-command"
24+ "obelisk-executable-config-inject"
25+ "obelisk-frontend"
26+ "obelisk-run"
27+ "obelisk-route"
28+ "obelisk-selftest"
29+ "obelisk-snap-extras"
30+ ];
31+
32+ pnameToAttrs = pkgsSet: pnames:
33+ lib.listToAttrs (map
34+ (name: { inherit name; value = pkgsSet.${name}; })
35+ pnames);
36+
37+ concatDepends = let
38+ extractDeps = x: (x.override {
39+ mkDerivation = drv: {
40+ out = builtins.concatLists [
41+ (drv.buildDepends or [])
42+ (drv.libraryHaskellDepends or [])
43+ (drv.executableHaskellDepends or [])
44+ ];
45+ };
46+ }).out;
47+ in pkgAttrs: builtins.concatLists (map extractDeps (builtins.attrValues pkgAttrs));
48+
49+ perPlatform = lib.genAttrs cacheBuildSystems (system: let
50+ obelisk = import ./. (self-args // { inherit system; });
51+ reflex-platform = obelisk.reflex-platform;
52+ ghc = pnameToAttrs
53+ obelisk.haskellPackageSets.ghc
54+ obeliskPackagesBackend;
55+ ghcjs = pnameToAttrs
56+ obelisk.haskellPackageSets.ghcjs
57+ obeliskPackagesCommon;
58+ cachePackages = builtins.concatLists [
59+ (builtins.attrValues ghc)
60+ (builtins.attrValues ghcjs)
61+ (concatDepends ghc)
62+ (concatDepends ghcjs)
63+ (lib.optional reflex-platform.androidSupport androidSkeleton)
64+ (lib.optional reflex-platform.iosSupport iosSkeleton)
65+ [ command serverSkeletonExe serverSkeletonShell ]
66+ ];
67+ command = obelisk.command;
68+ skeleton = import ./skeleton { inherit obelisk; };
69+ serverSkeletonExe = skeleton.exe;
70+ # TODO fix nixpkgs so it doesn't try to run the result of haskell shells as setup hooks.
71+ serverSkeletonShell = local-self.nixpkgs.runCommand "shell-safe-for-dep" {} ''
72+ touch "$out"
73+ echo "return" >> "$out"
74+ cat "${skeleton.shells.ghc}" >> "$out"
75+ '';
76+ androidSkeleton = (import ./skeleton { inherit obelisk; }).android.frontend;
77+ iosSkeleton = (import ./skeleton { inherit obelisk; }).ios.frontend;
78+ in {
79+ inherit
80+ command
81+ ghc ghcjs
82+ serverSkeletonExe
83+ serverSkeletonShell
84+ ;
85+ cache = reflex-platform.pinBuildInputs "obelisk-${system}" cachePackages;
86+ } // lib.optionalAttrs reflex-platform.androidSupport {
87+ inherit androidSkeleton;
88+ } // lib.optionalAttrs reflex-platform.iosSupport {
89+ inherit iosSkeleton;
90+ });
91+
92+ metaCache = local-self.reflex-platform.pinBuildInputs
93+ "obelisk-everywhere"
94+ (map (a: a.cache) (builtins.attrValues perPlatform));
95+
96+in perPlatform // { inherit metaCache; }
release.nix+99−91
@@ -1,96 +1,104 @@
1−{ self-args ? {
2− config.android_sdk.accept_license = true;
3− iosSdkVersion = "10.2";
4− }
5−, local-self ? import ./. self-args
6−, cacheBuildSystems ? [ "x86_64-linux" "x86_64-darwin" ]
7−}:
8−
9−let
10− inherit (local-self.nixpkgs) lib runCommand nix;
11−
12− obeliskPackagesCommon = [
13− "obelisk-frontend"
14− "obelisk-route"
15− "obelisk-executable-config-lookup"
16− ];
17−
18− obeliskPackagesBackend = obeliskPackagesCommon ++ [
19− "obelisk-asset-manifest"
20− "obelisk-asset-serve-snap"
21− "obelisk-backend"
22− "obelisk-cliapp"
23− "obelisk-command"
24− "obelisk-executable-config-inject"
25− "obelisk-frontend"
26− "obelisk-run"
27− "obelisk-route"
28− "obelisk-selftest"
29− "obelisk-snap-extras"
30− ];
31−
32− pnameToAttrs = pkgsSet: pnames:
33− lib.listToAttrs (map
34− (name: { inherit name; value = pkgsSet.${name}; })
35− pnames);
1+let
2+ nginxRoot = "/run/nginx";
3+ obelisk = import ./default.nix {};
4+ # Get NixOS a pre-release 20.03 that contains the python based tests and recursive nix
5+ pkgs = import (builtins.fetchTarball https://github.com/nixos/nixpkgs/archive/3de5266.tar.gz) {};
6+ sshKeys = import (pkgs.path + /nixos/tests/ssh-keys.nix) pkgs;
7+ make-test = import (pkgs.path + /nixos/tests/make-test-python.nix);
8+ supportedPlatforms = [ "x86_64-linux" "x86_64-darwin" ];
9+ obelisk-everywhere = (import ./everywhere.nix { cacheBuildSystems = supportedPlatforms; }).metaCache;
10+ snakeOilPrivateKey = sshKeys.snakeOilPrivateKey.text;
11+ snakeOilPublicKey = sshKeys.snakeOilPublicKey;
12+in
13+ make-test ({...}: {
14+ name = "obelisk";
15+ nodes = {
16+ githost = {
17+ networking.firewall.allowedTCPPorts = [ 22 80 ];
18+ services.openssh = {
19+ enable = true;
20+ };
21+ environment.systemPackages = [
22+ pkgs.git
23+ ];
24+ users.users.root.openssh.authorizedKeys.keys = [
25+ snakeOilPublicKey
26+ ];
27+ };
3628
37− concatDepends = let
38− extractDeps = x: (x.override {
39− mkDerivation = drv: {
40− out = builtins.concatLists [
41− (drv.buildDepends or [])
42− (drv.libraryHaskellDepends or [])
43− (drv.executableHaskellDepends or [])
29+ client = {
30+ imports = [
31+ (pkgs.path + /nixos/modules/installer/cd-dvd/channel.nix)
32+ ];
33+ nix.useSandbox = false;
34+ nix.binaryCaches = [];
35+ environment.systemPackages = [
36+ obelisk.command
37+ obelisk.shell
38+ obelisk-everywhere
39+ pkgs.git
40+ pkgs.jq
4441 ];
4542 };
46− }).out;
47− in pkgAttrs: builtins.concatLists (map extractDeps (builtins.attrValues pkgAttrs));
43+ };
4844
49− perPlatform = lib.genAttrs cacheBuildSystems (system: let
50− obelisk = import ./. (self-args // { inherit system; });
51− reflex-platform = obelisk.reflex-platform;
52− ghc = pnameToAttrs
53− obelisk.haskellPackageSets.ghc
54− obeliskPackagesBackend;
55− ghcjs = pnameToAttrs
56− obelisk.haskellPackageSets.ghcjs
57− obeliskPackagesCommon;
58− cachePackages = builtins.concatLists [
59− (builtins.attrValues ghc)
60− (builtins.attrValues ghcjs)
61− (concatDepends ghc)
62− (concatDepends ghcjs)
63− (lib.optional reflex-platform.androidSupport androidSkeleton)
64− (lib.optional reflex-platform.iosSupport iosSkeleton)
65− [ command serverSkeletonExe serverSkeletonShell ]
66− ];
67− command = obelisk.command;
68− skeleton = import ./skeleton { inherit obelisk; };
69− serverSkeletonExe = skeleton.exe;
70− # TODO fix nixpkgs so it doesn't try to run the result of haskell shells as setup hooks.
71− serverSkeletonShell = local-self.nixpkgs.runCommand "shell-safe-for-dep" {} ''
72− touch "$out"
73− echo "return" >> "$out"
74− cat "${skeleton.shells.ghc}" >> "$out"
45+ testScript =
46+ let
47+ privateKeyFile = pkgs.writeText "id_rsa" ''${snakeOilPrivateKey}'';
48+ sshConfigFile = pkgs.writeText "ssh_config" ''
49+ Host *
50+ StrictHostKeyChecking no
51+ UserKnownHostsFile=/dev/null
52+ ConnectionAttempts=1
53+ ConnectTimeout=1
54+ IdentityFile=~/.ssh/id_rsa
55+ User=root
56+ '';
57+ in ''
58+ start_all()
59+ githost.wait_for_open_port("22")
60+
61+ with subtest("test obelisk is installed"):
62+ client.succeed("ob --help")
63+
64+ with subtest("test the client can access the server via ssh"):
65+ client.succeed("mkdir -p ~/.ssh/")
66+ client.succeed(
67+ "cp ${privateKeyFile} ~/.ssh/id_rsa"
68+ )
69+ client.succeed("chmod 600 ~/.ssh/id_rsa")
70+ client.wait_until_succeeds(
71+ "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa githost true"
72+ )
73+ client.succeed(
74+ "cp ${sshConfigFile} ~/.ssh/config"
75+ )
76+ client.wait_until_succeeds("ssh githost true")
77+
78+ with subtest("test a remote bare repo can be started"):
79+ githost.succeed("mkdir -p ~/myorg/myapp.git")
80+ githost.succeed("cd ~/myorg/myapp.git && git init --bare")
81+
82+ with subtest("test a git project can be configured with a remote using ssh"):
83+ client.succeed("mkdir -p ~/code/myapp")
84+ client.succeed("cd ~/code/myapp && git init")
85+ client.succeed("cd ~/code/myapp && touch README")
86+ client.succeed("cd ~/code/myapp && git add .")
87+ client.succeed('git config --global user.email "you@example.com"')
88+ client.succeed('git config --global user.name "Your Name"')
89+ client.succeed('cd ~/code/myapp && git commit -m "Initial"')
90+ client.succeed(
91+ "cd ~/code/myapp && git remote add origin root@githost:/root/myorg/myapp.git"
92+ )
93+
94+ with subtest("test pushing code to the remote"):
95+ client.succeed("cd ~/code/myapp && git push -u origin master")
96+ client.succeed("cd ~/code/myapp && git status")
97+
98+ with subtest("test obelisk can pack"):
99+ client.succeed("ob thunk pack ~/code/myapp")
100+ client.succeed("grep -qF 'git' ~/code/myapp/default.nix")
101+ client.succeed("grep -qF 'myorg' ~/code/myapp/git.json")
102+ client.succeed('[ "$(jq .private < ~/code/myapp/git.json)" == "false" ] ')
75103 '';
76− androidSkeleton = (import ./skeleton { inherit obelisk; }).android.frontend;
77− iosSkeleton = (import ./skeleton { inherit obelisk; }).ios.frontend;
78− in {
79− inherit
80− command
81− ghc ghcjs
82− serverSkeletonExe
83− serverSkeletonShell
84− ;
85− cache = reflex-platform.pinBuildInputs "obelisk-${system}" cachePackages;
86− } // lib.optionalAttrs reflex-platform.androidSupport {
87− inherit androidSkeleton;
88− } // lib.optionalAttrs reflex-platform.iosSupport {
89− inherit iosSkeleton;
90− });
91−
92− metaCache = local-self.reflex-platform.pinBuildInputs
93− "obelisk-everywhere"
94− (map (a: a.cache) (builtins.attrValues perPlatform));
95−
96−in perPlatform // { inherit metaCache; }
104+ })
test.nixdeleted−102
@@ -1,102 +0,0 @@
1−let
2− nginxRoot = "/run/nginx";
3− pkgs = import (builtins.fetchTarball https://github.com/nixos/nixpkgs/archive/3de5266.tar.gz) {};
4− obelisk = import ./default.nix {};
5− # Get NixOS a pre-release 20.03 that contains the python based tests and recursive nix
6− sshKeys = import (pkgs.path + /nixos/tests/ssh-keys.nix) pkgs;
7− make-test = import (pkgs.path + /nixos/tests/make-test-python.nix);
8− supportedPlatforms = [ "x86_64-linux" "x86_64-darwin" ];
9− obelisk-everything = (import ./release.nix { cacheBuildSystems = supportedPlatforms; }).metaCache;
10− snakeOilPrivateKey = sshKeys.snakeOilPrivateKey.text;
11− snakeOilPublicKey = sshKeys.snakeOilPublicKey;
12−in
13− make-test ({...}: {
14− name = "obelisk";
15− nodes = {
16− githost = {
17− networking.firewall.allowedTCPPorts = [ 22 80 ];
18− services.openssh = {
19− enable = true;
20− };
21− environment.systemPackages = [
22− pkgs.git
23− ];
24− users.users.root.openssh.authorizedKeys.keys = [
25− snakeOilPublicKey
26− ];
27− };
28−
29− client = {
30− imports = [
31− (pkgs.path + /nixos/modules/installer/cd-dvd/channel.nix)
32− ];
33− nix.useSandbox = false;
34− nix.binaryCaches = [];
35− environment.systemPackages = [
36− obelisk.command
37− obelisk.shell
38− obelisk-everything
39− pkgs.git
40− ];
41− };
42− };
43−
44− testScript =
45− let
46− privateKeyFile = pkgs.writeText "id_rsa" ''${snakeOilPrivateKey}'';
47− sshConfigFile = pkgs.writeText "ssh_config" ''
48− Host *
49− StrictHostKeyChecking no
50− UserKnownHostsFile=/dev/null
51− ConnectionAttempts=1
52− ConnectTimeout=1
53− IdentityFile=~/.ssh/id_rsa
54− User=root
55− '';
56− in ''
57− start_all()
58− githost.wait_for_open_port("22")
59−
60− with subtest("test the client can access the server via ssh"):
61− client.succeed("mkdir -p ~/.ssh/")
62− client.succeed(
63− "cp ${privateKeyFile} ~/.ssh/id_rsa"
64− )
65− client.succeed("chmod 600 ~/.ssh/id_rsa")
66− client.wait_until_succeeds(
67− "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa githost true"
68− )
69− client.succeed(
70− "cp ${sshConfigFile} ~/.ssh/config"
71− )
72− client.wait_until_succeeds("ssh githost true")
73−
74− with subtest("test a remote bare repo can be started"):
75− githost.succeed("mkdir -p ~/myorg/myapp.git")
76− githost.succeed("cd ~/myorg/myapp.git && git init --bare")
77−
78− with subtest("test a git project can be configured with a remote using ssh"):
79− client.succeed("mkdir -p ~/code/myapp")
80− client.succeed("cd ~/code/myapp && git init")
81− client.succeed("cd ~/code/myapp && touch README")
82− client.succeed("cd ~/code/myapp && git add .")
83− client.succeed('git config --global user.email "you@example.com"')
84− client.succeed('git config --global user.name "Your Name"')
85− client.succeed('cd ~/code/myapp && git commit -m "Initial"')
86− client.succeed(
87− "cd ~/code/myapp && git remote add origin root@githost:/root/myorg/myapp.git"
88− )
89−
90− with subtest("test pushing code to the remote"):
91− client.succeed("cd ~/code/myapp && git push -u origin master")
92− client.succeed("cd ~/code/myapp && git status")
93−
94− with subtest("test obelisk is installed"):
95− client.succeed("ob --help")
96−
97− with subtest("test obelisk can pack"):
98− client.succeed("ob thunk pack ~/code/myapp")
99− client.succeed("grep -qF 'git' ~/code/myapp/default.nix")
100− client.succeed("grep -qF 'myorg' ~/code/myapp/git.json")
101− '';
102− })