2014-11-30 00:56:22 +01:00
|
|
|
# This test runs gitlab and checks if it works
|
|
|
|
|
2019-03-10 23:03:15 +01:00
|
|
|
let
|
|
|
|
initialRootPassword = "notproduction";
|
|
|
|
in
|
2018-11-02 21:22:51 +01:00
|
|
|
import ./make-test.nix ({ pkgs, lib, ...} : with lib; {
|
2014-11-30 00:56:22 +01:00
|
|
|
name = "gitlab";
|
2015-07-12 12:09:40 +02:00
|
|
|
meta = with pkgs.stdenv.lib.maintainers; {
|
2018-11-02 21:22:51 +01:00
|
|
|
maintainers = [ globin ];
|
2015-07-12 12:09:40 +02:00
|
|
|
};
|
2014-11-30 00:56:22 +01:00
|
|
|
|
|
|
|
nodes = {
|
2018-07-20 22:56:59 +02:00
|
|
|
gitlab = { ... }: {
|
2018-12-16 17:03:57 +01:00
|
|
|
virtualisation.memorySize = if pkgs.stdenv.is64bit then 4096 else 2047;
|
2018-11-02 21:22:51 +01:00
|
|
|
systemd.services.gitlab.serviceConfig.Restart = mkForce "no";
|
|
|
|
systemd.services.gitlab-workhorse.serviceConfig.Restart = mkForce "no";
|
|
|
|
systemd.services.gitaly.serviceConfig.Restart = mkForce "no";
|
|
|
|
systemd.services.gitlab-sidekiq.serviceConfig.Restart = mkForce "no";
|
2017-11-06 13:55:56 +01:00
|
|
|
|
|
|
|
services.nginx = {
|
|
|
|
enable = true;
|
2018-11-23 19:36:14 +01:00
|
|
|
recommendedProxySettings = true;
|
2017-11-06 13:55:56 +01:00
|
|
|
virtualHosts = {
|
2019-08-13 23:52:01 +02:00
|
|
|
localhost = {
|
2017-11-06 13:55:56 +01:00
|
|
|
locations."/".proxyPass = "http://unix:/run/gitlab/gitlab-workhorse.socket";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
services.gitlab = {
|
|
|
|
enable = true;
|
2019-07-31 18:09:27 +02:00
|
|
|
databasePasswordFile = pkgs.writeText "dbPassword" "xo0daiF4";
|
|
|
|
initialRootPasswordFile = pkgs.writeText "rootPassword" initialRootPassword;
|
2018-11-14 18:38:55 +01:00
|
|
|
smtp.enable = true;
|
2017-11-06 13:55:56 +01:00
|
|
|
secrets = {
|
2019-07-31 18:09:27 +02:00
|
|
|
secretFile = pkgs.writeText "secret" "Aig5zaic";
|
|
|
|
otpFile = pkgs.writeText "otpsecret" "Riew9mue";
|
|
|
|
dbFile = pkgs.writeText "dbsecret" "we2quaeZ";
|
|
|
|
jwsFile = pkgs.runCommand "oidcKeyBase" {} "${pkgs.openssl}/bin/openssl genrsa 2048 > $out";
|
2017-11-06 13:55:56 +01:00
|
|
|
};
|
|
|
|
};
|
2014-11-30 00:56:22 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2019-03-10 23:03:15 +01:00
|
|
|
testScript =
|
|
|
|
let
|
|
|
|
auth = pkgs.writeText "auth.json" (builtins.toJSON {
|
|
|
|
grant_type = "password";
|
|
|
|
username = "root";
|
|
|
|
password = initialRootPassword;
|
|
|
|
});
|
|
|
|
|
|
|
|
createProject = pkgs.writeText "create-project.json" (builtins.toJSON {
|
|
|
|
name = "test";
|
|
|
|
});
|
|
|
|
|
|
|
|
putFile = pkgs.writeText "put-file.json" (builtins.toJSON {
|
|
|
|
branch = "master";
|
|
|
|
author_email = "author@example.com";
|
|
|
|
author_name = "Firstname Lastname";
|
|
|
|
content = "some content";
|
|
|
|
commit_message = "create a new file";
|
|
|
|
});
|
|
|
|
in
|
|
|
|
''
|
2014-11-30 00:56:22 +01:00
|
|
|
$gitlab->start();
|
2018-11-02 21:22:51 +01:00
|
|
|
$gitlab->waitForUnit("gitaly.service");
|
|
|
|
$gitlab->waitForUnit("gitlab-workhorse.service");
|
2014-11-30 00:56:22 +01:00
|
|
|
$gitlab->waitForUnit("gitlab.service");
|
2014-12-14 02:30:13 +01:00
|
|
|
$gitlab->waitForUnit("gitlab-sidekiq.service");
|
2018-11-02 21:22:51 +01:00
|
|
|
$gitlab->waitForFile("/var/gitlab/state/tmp/sockets/gitlab.socket");
|
2018-11-23 19:36:14 +01:00
|
|
|
$gitlab->waitUntilSucceeds("curl -sSf http://gitlab/users/sign_in");
|
|
|
|
$gitlab->succeed("curl -isSf http://gitlab | grep -i location | grep -q http://gitlab/users/sign_in");
|
2019-03-10 23:03:15 +01:00
|
|
|
$gitlab->succeed("${pkgs.sudo}/bin/sudo -u gitlab -H gitlab-rake gitlab:check 1>&2");
|
|
|
|
$gitlab->succeed("echo \"Authorization: Bearer \$(curl -X POST -H 'Content-Type: application/json' -d @${auth} http://gitlab/oauth/token | ${pkgs.jq}/bin/jq -r '.access_token')\" >/tmp/headers");
|
|
|
|
$gitlab->succeed("curl -X POST -H 'Content-Type: application/json' -H @/tmp/headers -d @${createProject} http://gitlab/api/v4/projects");
|
|
|
|
$gitlab->succeed("curl -X POST -H 'Content-Type: application/json' -H @/tmp/headers -d @${putFile} http://gitlab/api/v4/projects/1/repository/files/some-file.txt");
|
|
|
|
$gitlab->succeed("curl -H @/tmp/headers http://gitlab/api/v4/projects/1/repository/archive.tar.gz > /tmp/archive.tar.gz");
|
|
|
|
$gitlab->succeed("curl -H @/tmp/headers http://gitlab/api/v4/projects/1/repository/archive.tar.bz2 > /tmp/archive.tar.bz2");
|
|
|
|
$gitlab->succeed("test -s /tmp/archive.tar.gz");
|
|
|
|
$gitlab->succeed("test -s /tmp/archive.tar.bz2");
|
2014-11-30 00:56:22 +01:00
|
|
|
'';
|
2015-07-12 12:09:40 +02:00
|
|
|
})
|