2023-08-06 18:41:37 +02:00
|
|
|
{
|
2025-03-24 18:38:09 +01:00
|
|
|
runTest,
|
|
|
|
forgejoPackage,
|
2023-08-06 18:41:37 +02:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
## gpg --faked-system-time='20230301T010000!' --quick-generate-key snakeoil ed25519 sign
|
|
|
|
signingPrivateKey = ''
|
|
|
|
-----BEGIN PGP PRIVATE KEY BLOCK-----
|
|
|
|
|
|
|
|
lFgEY/6jkBYJKwYBBAHaRw8BAQdADXiZRV8RJUyC9g0LH04wLMaJL9WTc+szbMi7
|
|
|
|
5fw4yP8AAQCl8EwGfzSLm/P6fCBfA3I9znFb3MEHGCCJhJ6VtKYyRw7ktAhzbmFr
|
|
|
|
ZW9pbIiUBBMWCgA8FiEE+wUM6VW/NLtAdSixTWQt6LZ4x50FAmP+o5ACGwMFCQPC
|
|
|
|
ZwAECwkIBwQVCgkIBRYCAwEAAh4FAheAAAoJEE1kLei2eMedFTgBAKQs1oGFZrCI
|
|
|
|
TZP42hmBTKxGAI1wg7VSdDEWTZxut/2JAQDGgo2sa4VHMfj0aqYGxrIwfP2B7JHO
|
|
|
|
GCqGCRf9O/hzBA==
|
|
|
|
=9Uy3
|
|
|
|
-----END PGP PRIVATE KEY BLOCK-----
|
|
|
|
'';
|
|
|
|
signingPrivateKeyId = "4D642DE8B678C79D";
|
|
|
|
|
2024-05-17 23:24:26 +02:00
|
|
|
metricSecret = "fakesecret";
|
|
|
|
|
2025-03-24 18:38:09 +01:00
|
|
|
base =
|
|
|
|
{
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
type,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
|
|
|
|
{
|
2023-08-06 18:41:37 +02:00
|
|
|
name = "forgejo-${type}";
|
2025-03-24 18:38:09 +01:00
|
|
|
meta.maintainers = with lib.maintainers; [
|
2024-04-10 17:52:51 +02:00
|
|
|
bendlas
|
|
|
|
emilylange
|
|
|
|
];
|
2024-12-10 20:26:33 +01:00
|
|
|
|
2024-04-10 17:52:51 +02:00
|
|
|
nodes = {
|
2024-12-10 20:26:33 +01:00
|
|
|
server =
|
2024-04-10 17:52:51 +02:00
|
|
|
{ config, pkgs, ... }:
|
2024-12-10 20:26:33 +01:00
|
|
|
{
|
2024-04-10 17:52:51 +02:00
|
|
|
virtualisation.memorySize = 2047;
|
|
|
|
services.forgejo = {
|
|
|
|
enable = true;
|
2024-07-31 03:59:13 +02:00
|
|
|
package = forgejoPackage;
|
2023-08-06 18:41:37 +02:00
|
|
|
database = { inherit type; };
|
|
|
|
settings.service.DISABLE_REGISTRATION = true;
|
|
|
|
settings."repository.signing".SIGNING_KEY = signingPrivateKeyId;
|
|
|
|
settings.actions.ENABLED = true;
|
2024-04-10 17:52:51 +02:00
|
|
|
settings.repository = {
|
|
|
|
ENABLE_PUSH_CREATE_USER = true;
|
|
|
|
DEFAULT_PUSH_CREATE_PRIVATE = false;
|
2024-12-10 20:26:33 +01:00
|
|
|
};
|
2024-05-17 23:24:26 +02:00
|
|
|
settings.metrics.ENABLED = true;
|
|
|
|
secrets.metrics.TOKEN = pkgs.writeText "metrics_secret" metricSecret;
|
2024-12-10 20:26:33 +01:00
|
|
|
};
|
2024-04-10 17:52:51 +02:00
|
|
|
environment.systemPackages = [
|
nixosTests.forgejo: test backup/dump service
This should allow us to catch issues regarding that in the future.
nixos/gitea had an issue with the dump service recently, which didn't
affect us, fortunately.
But to be fair, it only affected non-default-y setups.
Not something we are able to catch in the current, rather simple, config
of our test.
Still, I see a lot of value adding this new subtest to our test suite.
Anyhow, this patch also exposes the resulting tarball as test (build)
output, which is a nice addition IMHO, as it allows some sort of
external sanity-check, if needed, without running the test interactive.
2023-10-24 02:32:56 +02:00
|
|
|
config.services.forgejo.package
|
2024-04-10 17:52:51 +02:00
|
|
|
pkgs.gnupg
|
2024-12-10 20:26:33 +01:00
|
|
|
pkgs.jq
|
|
|
|
pkgs.file
|
|
|
|
];
|
2023-08-06 18:41:37 +02:00
|
|
|
services.openssh.enable = true;
|
2024-12-10 20:26:33 +01:00
|
|
|
|
2023-08-06 18:41:37 +02:00
|
|
|
specialisation.runner = {
|
nixosTests.forgejo: test backup/dump service
This should allow us to catch issues regarding that in the future.
nixos/gitea had an issue with the dump service recently, which didn't
affect us, fortunately.
But to be fair, it only affected non-default-y setups.
Not something we are able to catch in the current, rather simple, config
of our test.
Still, I see a lot of value adding this new subtest to our test suite.
Anyhow, this patch also exposes the resulting tarball as test (build)
output, which is a nice addition IMHO, as it allows some sort of
external sanity-check, if needed, without running the test interactive.
2023-10-24 02:32:56 +02:00
|
|
|
inheritParentConfig = true;
|
2024-04-10 17:52:51 +02:00
|
|
|
configuration.services.gitea-actions-runner = {
|
|
|
|
package = pkgs.forgejo-runner;
|
|
|
|
instances."test" = {
|
2024-04-10 17:52:30 +02:00
|
|
|
enable = true;
|
2024-04-10 17:52:51 +02:00
|
|
|
name = "ci";
|
|
|
|
url = "http://localhost:3000";
|
|
|
|
labels = [
|
|
|
|
# type ":host" does not depend on docker/podman/lxc
|
|
|
|
"native:host"
|
|
|
|
];
|
|
|
|
tokenFile = "/var/lib/forgejo/runner_token";
|
2024-12-10 20:26:33 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
nixosTests.forgejo: test backup/dump service
This should allow us to catch issues regarding that in the future.
nixos/gitea had an issue with the dump service recently, which didn't
affect us, fortunately.
But to be fair, it only affected non-default-y setups.
Not something we are able to catch in the current, rather simple, config
of our test.
Still, I see a lot of value adding this new subtest to our test suite.
Anyhow, this patch also exposes the resulting tarball as test (build)
output, which is a nice addition IMHO, as it allows some sort of
external sanity-check, if needed, without running the test interactive.
2023-10-24 02:32:56 +02:00
|
|
|
specialisation.dump = {
|
|
|
|
inheritParentConfig = true;
|
|
|
|
configuration.services.forgejo.dump = {
|
2024-04-10 17:52:30 +02:00
|
|
|
enable = true;
|
nixosTests.forgejo: test backup/dump service
This should allow us to catch issues regarding that in the future.
nixos/gitea had an issue with the dump service recently, which didn't
affect us, fortunately.
But to be fair, it only affected non-default-y setups.
Not something we are able to catch in the current, rather simple, config
of our test.
Still, I see a lot of value adding this new subtest to our test suite.
Anyhow, this patch also exposes the resulting tarball as test (build)
output, which is a nice addition IMHO, as it allows some sort of
external sanity-check, if needed, without running the test interactive.
2023-10-24 02:32:56 +02:00
|
|
|
type = "tar.zst";
|
|
|
|
file = "dump.tar.zst";
|
2024-12-10 20:26:33 +01:00
|
|
|
};
|
2024-04-10 17:52:51 +02:00
|
|
|
};
|
2023-08-06 18:41:37 +02:00
|
|
|
};
|
nixosTests.forgejo: test backup/dump service
This should allow us to catch issues regarding that in the future.
nixos/gitea had an issue with the dump service recently, which didn't
affect us, fortunately.
But to be fair, it only affected non-default-y setups.
Not something we are able to catch in the current, rather simple, config
of our test.
Still, I see a lot of value adding this new subtest to our test suite.
Anyhow, this patch also exposes the resulting tarball as test (build)
output, which is a nice addition IMHO, as it allows some sort of
external sanity-check, if needed, without running the test interactive.
2023-10-24 02:32:56 +02:00
|
|
|
client =
|
2024-12-10 20:26:33 +01:00
|
|
|
{ ... }:
|
|
|
|
{
|
nixosTests.forgejo: test backup/dump service
This should allow us to catch issues regarding that in the future.
nixos/gitea had an issue with the dump service recently, which didn't
affect us, fortunately.
But to be fair, it only affected non-default-y setups.
Not something we are able to catch in the current, rather simple, config
of our test.
Still, I see a lot of value adding this new subtest to our test suite.
Anyhow, this patch also exposes the resulting tarball as test (build)
output, which is a nice addition IMHO, as it allows some sort of
external sanity-check, if needed, without running the test interactive.
2023-10-24 02:32:56 +02:00
|
|
|
programs.git = {
|
|
|
|
enable = true;
|
2024-04-10 17:52:30 +02:00
|
|
|
config = {
|
|
|
|
user.email = "test@localhost";
|
nixosTests.forgejo: test backup/dump service
This should allow us to catch issues regarding that in the future.
nixos/gitea had an issue with the dump service recently, which didn't
affect us, fortunately.
But to be fair, it only affected non-default-y setups.
Not something we are able to catch in the current, rather simple, config
of our test.
Still, I see a lot of value adding this new subtest to our test suite.
Anyhow, this patch also exposes the resulting tarball as test (build)
output, which is a nice addition IMHO, as it allows some sort of
external sanity-check, if needed, without running the test interactive.
2023-10-24 02:32:56 +02:00
|
|
|
user.name = "test";
|
|
|
|
init.defaultBranch = "main";
|
2024-12-10 20:26:33 +01:00
|
|
|
};
|
|
|
|
};
|
2024-04-10 17:52:30 +02:00
|
|
|
programs.ssh.extraConfig = ''
|
nixosTests.forgejo: test backup/dump service
This should allow us to catch issues regarding that in the future.
nixos/gitea had an issue with the dump service recently, which didn't
affect us, fortunately.
But to be fair, it only affected non-default-y setups.
Not something we are able to catch in the current, rather simple, config
of our test.
Still, I see a lot of value adding this new subtest to our test suite.
Anyhow, this patch also exposes the resulting tarball as test (build)
output, which is a nice addition IMHO, as it allows some sort of
external sanity-check, if needed, without running the test interactive.
2023-10-24 02:32:56 +02:00
|
|
|
Host *
|
2024-04-10 17:52:30 +02:00
|
|
|
StrictHostKeyChecking no
|
nixosTests.forgejo: test backup/dump service
This should allow us to catch issues regarding that in the future.
nixos/gitea had an issue with the dump service recently, which didn't
affect us, fortunately.
But to be fair, it only affected non-default-y setups.
Not something we are able to catch in the current, rather simple, config
of our test.
Still, I see a lot of value adding this new subtest to our test suite.
Anyhow, this patch also exposes the resulting tarball as test (build)
output, which is a nice addition IMHO, as it allows some sort of
external sanity-check, if needed, without running the test interactive.
2023-10-24 02:32:56 +02:00
|
|
|
IdentityFile ~/.ssh/privk
|
2024-12-10 20:26:33 +01:00
|
|
|
'';
|
nixosTests.forgejo: test backup/dump service
This should allow us to catch issues regarding that in the future.
nixos/gitea had an issue with the dump service recently, which didn't
affect us, fortunately.
But to be fair, it only affected non-default-y setups.
Not something we are able to catch in the current, rather simple, config
of our test.
Still, I see a lot of value adding this new subtest to our test suite.
Anyhow, this patch also exposes the resulting tarball as test (build)
output, which is a nice addition IMHO, as it allows some sort of
external sanity-check, if needed, without running the test interactive.
2023-10-24 02:32:56 +02:00
|
|
|
};
|
2023-08-06 18:41:37 +02:00
|
|
|
};
|
2024-12-10 20:26:33 +01:00
|
|
|
|
2024-04-10 17:52:30 +02:00
|
|
|
testScript =
|
|
|
|
{ nodes, ... }:
|
2024-12-10 20:26:33 +01:00
|
|
|
let
|
2023-08-06 18:41:37 +02:00
|
|
|
inherit (import ./ssh-keys.nix pkgs) snakeOilPrivateKey snakeOilPublicKey;
|
|
|
|
serverSystem = nodes.server.system.build.toplevel;
|
nixosTests.forgejo: test backup/dump service
This should allow us to catch issues regarding that in the future.
nixos/gitea had an issue with the dump service recently, which didn't
affect us, fortunately.
But to be fair, it only affected non-default-y setups.
Not something we are able to catch in the current, rather simple, config
of our test.
Still, I see a lot of value adding this new subtest to our test suite.
Anyhow, this patch also exposes the resulting tarball as test (build)
output, which is a nice addition IMHO, as it allows some sort of
external sanity-check, if needed, without running the test interactive.
2023-10-24 02:32:56 +02:00
|
|
|
dumpFile =
|
|
|
|
with nodes.server.specialisation.dump.configuration.services.forgejo.dump;
|
|
|
|
"${backupDir}/${file}";
|
2024-04-10 17:52:30 +02:00
|
|
|
remoteUri = "forgejo@server:test/repo";
|
2024-04-10 17:52:51 +02:00
|
|
|
remoteUriCheckoutAction = "forgejo@server:test/checkout";
|
2025-03-24 18:38:09 +01:00
|
|
|
|
|
|
|
actionsWorkflowYaml = ''
|
|
|
|
run-name: dummy workflow
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
jobs:
|
|
|
|
cat:
|
|
|
|
runs-on: native
|
|
|
|
steps:
|
|
|
|
- uses: http://localhost:3000/test/checkout@main
|
|
|
|
- run: cat testfile
|
|
|
|
'';
|
|
|
|
# https://github.com/actions/checkout/releases
|
|
|
|
checkoutActionSource = pkgs.fetchFromGitHub {
|
|
|
|
owner = "actions";
|
|
|
|
repo = "checkout";
|
|
|
|
rev = "v4.1.1";
|
|
|
|
hash = "sha256-h2/UIp8IjPo3eE4Gzx52Fb7pcgG/Ww7u31w5fdKVMos=";
|
|
|
|
};
|
2024-12-10 20:26:33 +01:00
|
|
|
in
|
|
|
|
''
|
2023-10-24 03:29:08 +02:00
|
|
|
import json
|
2024-12-10 20:26:33 +01:00
|
|
|
|
2023-08-06 18:41:37 +02:00
|
|
|
start_all()
|
2024-12-10 20:26:33 +01:00
|
|
|
|
2024-04-10 17:52:30 +02:00
|
|
|
client.succeed("mkdir -p ~/.ssh")
|
|
|
|
client.succeed("(umask 0077; cat ${snakeOilPrivateKey} > ~/.ssh/privk)")
|
2024-12-10 20:26:33 +01:00
|
|
|
|
2024-04-10 17:52:30 +02:00
|
|
|
client.succeed("mkdir /tmp/repo")
|
|
|
|
client.succeed("git -C /tmp/repo init")
|
|
|
|
client.succeed("echo 'hello world' > /tmp/repo/testfile")
|
|
|
|
client.succeed("git -C /tmp/repo add .")
|
|
|
|
client.succeed("git -C /tmp/repo commit -m 'Initial import'")
|
|
|
|
client.succeed("git -C /tmp/repo remote add origin ${remoteUri}")
|
2024-12-10 20:26:33 +01:00
|
|
|
|
2023-08-06 18:41:37 +02:00
|
|
|
server.wait_for_unit("forgejo.service")
|
|
|
|
server.wait_for_open_port(3000)
|
|
|
|
server.wait_for_open_port(22)
|
|
|
|
server.succeed("curl --fail http://localhost:3000/")
|
2024-12-10 20:26:33 +01:00
|
|
|
|
2023-08-06 18:41:37 +02:00
|
|
|
server.succeed(
|
|
|
|
"su -l forgejo -c 'gpg --homedir /var/lib/forgejo/data/home/.gnupg "
|
2024-04-10 17:52:30 +02:00
|
|
|
+ "--import ${toString (pkgs.writeText "forgejo.key" signingPrivateKey)}'"
|
2024-12-10 20:26:33 +01:00
|
|
|
)
|
|
|
|
|
2024-04-10 17:52:30 +02:00
|
|
|
assert "BEGIN PGP PUBLIC KEY BLOCK" in server.succeed("curl http://localhost:3000/api/v1/signing-key.gpg")
|
2024-12-10 20:26:33 +01:00
|
|
|
|
2024-04-10 17:52:30 +02:00
|
|
|
api_version = json.loads(server.succeed("curl http://localhost:3000/api/forgejo/v1/version")).get("version")
|
|
|
|
assert "development" != api_version and "${forgejoPackage.version}+gitea-" in api_version, (
|
2024-04-02 17:04:29 +02:00
|
|
|
"/api/forgejo/v1/version should not return 'development' "
|
2024-04-23 18:35:34 -04:00
|
|
|
+ f"but should contain a forgejo+gitea compatibility version string. Got '{api_version}' instead."
|
2024-12-10 20:26:33 +01:00
|
|
|
)
|
|
|
|
|
2023-08-06 18:41:37 +02:00
|
|
|
server.succeed(
|
2024-04-10 17:52:30 +02:00
|
|
|
"curl --fail http://localhost:3000/user/sign_up | grep 'Registration is disabled. "
|
|
|
|
+ "Please contact your site administrator.'"
|
2024-12-10 20:26:33 +01:00
|
|
|
)
|
2024-04-10 17:52:30 +02:00
|
|
|
server.succeed(
|
|
|
|
"su -l forgejo -c 'GITEA_WORK_DIR=/var/lib/forgejo gitea admin user create "
|
|
|
|
+ "--username test --password totallysafe --email test@localhost --must-change-password=false'"
|
2024-12-10 20:26:33 +01:00
|
|
|
)
|
|
|
|
|
2024-04-10 17:52:30 +02:00
|
|
|
api_token = server.succeed(
|
2023-08-06 18:41:37 +02:00
|
|
|
"curl --fail -X POST http://test:totallysafe@localhost:3000/api/v1/users/test/tokens "
|
|
|
|
+ "-H 'Accept: application/json' -H 'Content-Type: application/json' -d "
|
2024-04-10 17:52:30 +02:00
|
|
|
+ "'{\"name\":\"token\",\"scopes\":[\"all\"]}' | jq '.sha1' | xargs echo -n"
|
2024-12-10 20:26:33 +01:00
|
|
|
)
|
|
|
|
|
2023-08-06 18:41:37 +02:00
|
|
|
server.succeed(
|
2024-04-10 17:52:30 +02:00
|
|
|
"curl --fail -X POST http://localhost:3000/api/v1/user/repos "
|
2023-08-06 18:41:37 +02:00
|
|
|
+ "-H 'Accept: application/json' -H 'Content-Type: application/json' "
|
|
|
|
+ f"-H 'Authorization: token {api_token}'"
|
2024-04-10 17:52:30 +02:00
|
|
|
+ ' -d \'{"auto_init":false, "description":"string", "license":"mit", "name":"repo", "private":false}\'''
|
2024-12-10 20:26:33 +01:00
|
|
|
)
|
|
|
|
|
2023-08-06 18:41:37 +02:00
|
|
|
server.succeed(
|
2024-04-10 17:52:30 +02:00
|
|
|
"curl --fail -X POST http://localhost:3000/api/v1/user/keys "
|
2024-04-10 17:52:51 +02:00
|
|
|
+ "-H 'Accept: application/json' -H 'Content-Type: application/json' "
|
2024-04-10 17:52:30 +02:00
|
|
|
+ f"-H 'Authorization: token {api_token}'"
|
2023-08-06 18:41:37 +02:00
|
|
|
+ ' -d \'{"key":"${snakeOilPublicKey}","read_only":true,"title":"SSH"}\'''
|
2024-12-10 20:26:33 +01:00
|
|
|
)
|
|
|
|
|
2024-04-10 17:52:30 +02:00
|
|
|
client.succeed("git -C /tmp/repo push origin main")
|
2024-12-10 20:26:33 +01:00
|
|
|
|
2024-04-10 17:52:30 +02:00
|
|
|
client.succeed("git clone ${remoteUri} /tmp/repo-clone")
|
|
|
|
print(client.succeed("ls -lash /tmp/repo-clone"))
|
|
|
|
assert "hello world" == client.succeed("cat /tmp/repo-clone/testfile").strip()
|
2024-12-10 20:26:33 +01:00
|
|
|
|
2024-04-10 17:52:30 +02:00
|
|
|
with subtest("Testing git protocol version=2 over ssh"):
|
|
|
|
git_protocol = client.succeed("GIT_TRACE2_EVENT=true GIT_TRACE2_EVENT_NESTING=3 git -C /tmp/repo-clone fetch |& grep negotiated-version")
|
2023-10-24 03:29:08 +02:00
|
|
|
version = json.loads(git_protocol).get("value")
|
|
|
|
assert version == "2", f"git did not negotiate protocol version 2, but version {version} instead."
|
2024-12-10 20:26:33 +01:00
|
|
|
|
2023-08-06 18:41:37 +02:00
|
|
|
server.wait_until_succeeds(
|
2024-04-10 17:52:30 +02:00
|
|
|
'test "$(curl http://localhost:3000/api/v1/repos/test/repo/commits '
|
2023-08-06 18:41:37 +02:00
|
|
|
+ '-H "Accept: application/json" | jq length)" = "1"',
|
|
|
|
timeout=10
|
2024-12-10 20:26:33 +01:00
|
|
|
)
|
|
|
|
|
2024-04-10 17:52:30 +02:00
|
|
|
with subtest("Testing /metrics endpoint with token from cfg.secrets"):
|
2024-05-17 23:24:26 +02:00
|
|
|
server.fail("curl --fail http://localhost:3000/metrics")
|
|
|
|
server.succeed('curl --fail http://localhost:3000/metrics -H "Authorization: Bearer ${metricSecret}"')
|
2024-12-10 20:26:33 +01:00
|
|
|
|
2024-04-10 17:52:51 +02:00
|
|
|
with subtest("Testing runner registration and action workflow"):
|
|
|
|
server.succeed(
|
2023-08-06 18:41:37 +02:00
|
|
|
"su -l forgejo -c 'GITEA_WORK_DIR=/var/lib/forgejo gitea actions generate-runner-token' | sed 's/^/TOKEN=/' | tee /var/lib/forgejo/runner_token"
|
2024-12-10 20:26:33 +01:00
|
|
|
)
|
2023-08-06 18:41:37 +02:00
|
|
|
server.succeed("${serverSystem}/specialisation/runner/bin/switch-to-configuration test")
|
|
|
|
server.wait_for_unit("gitea-runner-test.service")
|
|
|
|
server.succeed("journalctl -o cat -u gitea-runner-test.service | grep -q 'Runner registered successfully'")
|
2024-12-10 20:26:33 +01:00
|
|
|
|
2024-04-10 17:52:51 +02:00
|
|
|
# enable actions feature for this repository, defaults to disabled
|
|
|
|
server.succeed(
|
2024-04-10 17:52:30 +02:00
|
|
|
"curl --fail -X PATCH http://localhost:3000/api/v1/repos/test/repo "
|
2024-04-10 17:52:51 +02:00
|
|
|
+ "-H 'Accept: application/json' -H 'Content-Type: application/json' "
|
|
|
|
+ f"-H 'Authorization: token {api_token}'"
|
|
|
|
+ ' -d \'{"has_actions":true}\'''
|
2024-12-10 20:26:33 +01:00
|
|
|
)
|
|
|
|
|
2024-04-10 17:52:30 +02:00
|
|
|
# mirror "actions/checkout" action
|
2024-04-10 17:52:51 +02:00
|
|
|
client.succeed("cp -R ${checkoutActionSource}/ /tmp/checkout")
|
|
|
|
client.succeed("git -C /tmp/checkout init")
|
|
|
|
client.succeed("git -C /tmp/checkout add .")
|
|
|
|
client.succeed("git -C /tmp/checkout commit -m 'Initial import'")
|
|
|
|
client.succeed("git -C /tmp/checkout remote add origin ${remoteUriCheckoutAction}")
|
|
|
|
client.succeed("git -C /tmp/checkout push origin main")
|
2024-12-10 20:26:33 +01:00
|
|
|
|
2024-04-10 17:52:30 +02:00
|
|
|
# push workflow to initial repo
|
2024-04-10 17:52:51 +02:00
|
|
|
client.succeed("mkdir -p /tmp/repo/.forgejo/workflows")
|
2024-04-10 17:52:30 +02:00
|
|
|
client.succeed("cp ${pkgs.writeText "dummy-workflow.yml" actionsWorkflowYaml} /tmp/repo/.forgejo/workflows/")
|
2024-04-10 17:52:51 +02:00
|
|
|
client.succeed("git -C /tmp/repo add .")
|
|
|
|
client.succeed("git -C /tmp/repo commit -m 'Add dummy workflow'")
|
|
|
|
client.succeed("git -C /tmp/repo push origin main")
|
2024-12-10 20:26:33 +01:00
|
|
|
|
2024-04-10 17:52:51 +02:00
|
|
|
def poll_workflow_action_status(_) -> bool:
|
2025-04-12 23:07:12 +02:00
|
|
|
try:
|
|
|
|
response = server.succeed("curl --fail http://localhost:3000/api/v1/repos/test/repo/actions/tasks")
|
|
|
|
status = json.loads(response).get("workflow_runs")[0].get("status")
|
2024-12-10 20:26:33 +01:00
|
|
|
|
2025-04-12 23:07:12 +02:00
|
|
|
except IndexError:
|
|
|
|
status = "???"
|
2024-12-10 20:26:33 +01:00
|
|
|
|
2025-04-12 23:07:12 +02:00
|
|
|
server.log(f"Workflow status: {status}")
|
2024-12-10 20:26:33 +01:00
|
|
|
|
2025-04-12 23:07:12 +02:00
|
|
|
if status == "failure":
|
|
|
|
raise Exception("Workflow failed")
|
2024-12-10 20:26:33 +01:00
|
|
|
|
2025-04-12 23:07:12 +02:00
|
|
|
return status == "success"
|
2024-12-10 20:26:33 +01:00
|
|
|
|
2024-04-10 17:52:51 +02:00
|
|
|
with server.nested("Waiting for the workflow run to be successful"):
|
2025-04-12 23:07:12 +02:00
|
|
|
retry(poll_workflow_action_status, 60)
|
2024-12-10 20:26:33 +01:00
|
|
|
|
nixosTests.forgejo: test backup/dump service
This should allow us to catch issues regarding that in the future.
nixos/gitea had an issue with the dump service recently, which didn't
affect us, fortunately.
But to be fair, it only affected non-default-y setups.
Not something we are able to catch in the current, rather simple, config
of our test.
Still, I see a lot of value adding this new subtest to our test suite.
Anyhow, this patch also exposes the resulting tarball as test (build)
output, which is a nice addition IMHO, as it allows some sort of
external sanity-check, if needed, without running the test interactive.
2023-10-24 02:32:56 +02:00
|
|
|
with subtest("Testing backup service"):
|
|
|
|
server.succeed("${serverSystem}/specialisation/dump/bin/switch-to-configuration test")
|
|
|
|
server.systemctl("start forgejo-dump")
|
2024-04-10 17:52:30 +02:00
|
|
|
assert "Zstandard compressed data" in server.succeed("file ${dumpFile}")
|
nixosTests.forgejo: test backup/dump service
This should allow us to catch issues regarding that in the future.
nixos/gitea had an issue with the dump service recently, which didn't
affect us, fortunately.
But to be fair, it only affected non-default-y setups.
Not something we are able to catch in the current, rather simple, config
of our test.
Still, I see a lot of value adding this new subtest to our test suite.
Anyhow, this patch also exposes the resulting tarball as test (build)
output, which is a nice addition IMHO, as it allows some sort of
external sanity-check, if needed, without running the test interactive.
2023-10-24 02:32:56 +02:00
|
|
|
server.copy_from_vm("${dumpFile}")
|
2024-04-10 17:52:30 +02:00
|
|
|
'';
|
2025-03-24 18:38:09 +01:00
|
|
|
};
|
2023-08-06 18:41:37 +02:00
|
|
|
in
|
2025-03-24 18:38:09 +01:00
|
|
|
{
|
|
|
|
mysql = runTest {
|
|
|
|
imports = [ base ];
|
|
|
|
_module.args.type = "mysql";
|
|
|
|
};
|
|
|
|
sqlite3 = runTest {
|
|
|
|
imports = [ base ];
|
|
|
|
_module.args.type = "sqlite3";
|
|
|
|
};
|
|
|
|
postgres = runTest {
|
|
|
|
imports = [ base ];
|
|
|
|
_module.args.type = "postgres";
|
|
|
|
};
|
|
|
|
}
|