-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #646 from obsidiansystems/v0.5
v0.5
- Loading branch information
Showing
34 changed files
with
1,078 additions
and
605 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
Copyright (c) 2020 Obsidian Systems | ||
|
||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
|
||
* Redistributions in binary form must reproduce the above | ||
copyright notice, this list of conditions and the following | ||
disclaimer in the documentation and/or other materials provided | ||
with the distribution. | ||
|
||
* Neither the name of Elliot Cameron nor the names of other | ||
contributors may be used to endorse or promote products derived | ||
from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
supportedSystems ? [ builtins.currentSystem ] | ||
}: | ||
let | ||
let | ||
nginxRoot = "/run/nginx"; | ||
obelisk = import ./default.nix {}; | ||
# Get NixOS a pre-release 20.03 that contains the python based tests and recursive nix | ||
|
@@ -21,7 +21,7 @@ in | |
enable = true; | ||
}; | ||
environment.systemPackages = [ | ||
pkgs.git | ||
pkgs.git | ||
]; | ||
users.users.root.openssh.authorizedKeys.keys = [ | ||
snakeOilPublicKey | ||
|
@@ -38,14 +38,20 @@ in | |
obelisk.command | ||
obelisk.shell | ||
obelisk-everywhere | ||
pkgs.git | ||
pkgs.git | ||
]; | ||
}; | ||
}; | ||
|
||
testScript = | ||
let | ||
privateKeyFile = pkgs.writeText "id_rsa" ''${snakeOilPrivateKey}''; | ||
thunkableSample = pkgs.writeText "default.nix" '' | ||
let pkgs = import <nixpkgs> {}; in pkgs.git | ||
''; | ||
invalidThunkableSample = pkgs.writeText "default.nix" '' | ||
let pkgs = import <nixpkgs> {}; in pkgtypo.git | ||
''; | ||
sshConfigFile = pkgs.writeText "ssh_config" '' | ||
Host * | ||
StrictHostKeyChecking no | ||
|
@@ -58,10 +64,10 @@ in | |
in '' | ||
start_all() | ||
githost.wait_for_open_port("22") | ||
with subtest("test obelisk is installed"): | ||
client.succeed("ob --help") | ||
with subtest("test the client can access the server via ssh"): | ||
client.succeed("mkdir -p ~/.ssh/") | ||
client.succeed( | ||
|
@@ -75,33 +81,65 @@ in | |
"cp ${sshConfigFile} ~/.ssh/config" | ||
) | ||
client.wait_until_succeeds("ssh githost true") | ||
with subtest("test a remote bare repo can be started"): | ||
githost.succeed("mkdir -p ~/myorg/myapp.git") | ||
githost.succeed("cd ~/myorg/myapp.git && git init --bare") | ||
with subtest("test a git project can be configured with a remote using ssh"): | ||
client.succeed("mkdir -p ~/code/myapp") | ||
client.succeed("cd ~/code/myapp && git init") | ||
client.succeed("cd ~/code/myapp && touch README") | ||
client.succeed( | ||
"cp ${thunkableSample} ~/code/myapp/default.nix" | ||
) | ||
client.succeed("cd ~/code/myapp && git add .") | ||
client.succeed('git config --global user.email "[email protected]"') | ||
client.succeed('git config --global user.name "Your Name"') | ||
client.succeed('cd ~/code/myapp && git commit -m "Initial"') | ||
client.succeed( | ||
"cd ~/code/myapp && git remote add origin root@githost:/root/myorg/myapp.git" | ||
) | ||
with subtest("test pushing code to the remote"): | ||
client.succeed("cd ~/code/myapp && git push -u origin master") | ||
client.succeed("cd ~/code/myapp && git status") | ||
with subtest("test obelisk can pack"): | ||
client.succeed("ob thunk pack ~/code/myapp") | ||
client.succeed("ob -v thunk pack ~/code/myapp") | ||
client.succeed("grep -qF 'git' ~/code/myapp/default.nix") | ||
client.succeed("grep -qF 'myorg' ~/code/myapp/git.json") | ||
with subtest("test obelisk can detect private repos"): | ||
client.succeed("ob -v thunk unpack ~/code/myapp") | ||
with subtest("test obelisk can set the public / private flag"): | ||
client.succeed("ob -v thunk pack ~/code/myapp --private") | ||
client.fail("""grep -qF '"private": practice' ~/code/myapp/git.json""") | ||
client.succeed("""grep -qF '"private": true' ~/code/myapp/git.json""") | ||
client.succeed("nix-build ~/code/myapp") | ||
client.succeed("ob -v thunk unpack ~/code/myapp") | ||
client.succeed("ob -v thunk pack ~/code/myapp --public") | ||
client.succeed("""grep -qF '"private": false' ~/code/myapp/git.json""") | ||
''; | ||
client.succeed("nix-build ~/code/myapp") | ||
client.succeed("ob -v thunk unpack ~/code/myapp") | ||
with subtest("test building an invalid thunk fails"): | ||
client.succeed("cd ~/code/myapp && git checkout -b bad") | ||
client.succeed( | ||
"cp ${invalidThunkableSample} ~/code/myapp/default.nix" | ||
) | ||
client.succeed("cd ~/code/myapp && git add .") | ||
client.succeed('git config --global user.email "[email protected]"') | ||
client.succeed('git config --global user.name "Your Name"') | ||
client.succeed('cd ~/code/myapp && git commit -m "Bad commit"') | ||
client.succeed("cd ~/code/myapp && git push -u origin bad") | ||
client.succeed("ob -v thunk pack ~/code/myapp --public") | ||
client.fail("nix-build ~/code/myapp") | ||
client.succeed("ob -v thunk unpack ~/code/myapp") | ||
client.succeed("cd ~/code/myapp && git checkout master") | ||
with subtest("test obelisk can detect private repos"): | ||
client.succeed("ob -v thunk pack ~/code/myapp") | ||
client.succeed("""grep -qF '"private": true' ~/code/myapp/git.json""") | ||
client.succeed("ob -v thunk unpack ~/code/myapp") | ||
''; | ||
}) {} |
Oops, something went wrong.