Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • privatestorage/PrivateStorageio
  • tomprince/PrivateStorageio
2 results
Show changes
{ callPackage, fetchFromGitLab, lib }:
let
repo-data = lib.importJSON ./repo.json;
repo = fetchFromGitLab (builtins.removeAttrs repo-data [ "branch" ]);
in
# We want to check the revision the service reports against the revsion
# that we install. The upsream derivation doesn't currently know its own
# version, but we do have it here. Thus, we add it as a meta attribute
# to the derviation provided from upstream.
lib.addMetaAttrs { inherit (repo-data) rev; }
(callPackage repo {})
{
"owner": "privatestorage",
"repo": "zkap-spending-service",
"rev": "e0d63b79213d16f2de6629167ea8f1236ba22e14",
"branch": "main",
"domain": "whetstone.privatestorage.io",
"outputHash": "30abb0g9xxn4lp493kj5wmz8kj5q2iqvw40m8llqvb3zamx60gd8cy451ii7z15qbrbx9xmjdfw0k4gviij46fkx1s8nbich5c8qx57",
"outputHashAlgo": "sha512"
}
......@@ -3,5 +3,6 @@ let
pkgs = import ../nixpkgs-2105.nix { };
in {
private-storage = pkgs.nixosTest ./tests/private-storage.nix;
spending = pkgs.nixosTest ./tests/spending.nix;
tahoe = pkgs.nixosTest ./tests/tahoe.nix;
}
{ pkgs, lib, ... }:
{
name = "zkap-spending-service";
nodes = {
spending = { config, pkgs, ourpkgs, modulesPath, ... }: {
imports = [
../modules/packages.nix
../modules/spending.nix
];
services.private-storage-spending.enable = true;
services.private-storage-spending.domain = "localhost";
};
};
testScript = { nodes }: let
revision = nodes.spending.config.passthru.ourpkgs.zkap-spending-service.meta.rev;
curl = "${pkgs.curl}/bin/curl -sSf";
in
''
import json
start_all()
spending.wait_for_open_port(80)
with subtest("Ensure we can ping the spending service"):
output = spending.succeed("${curl} http://localhost/v1/_ping")
assert json.loads(output)["status"] == "ok", "Could not ping spending service."
with subtest("Ensure that the spending service version matches the expected version"):
output = spending.succeed("${curl} http://localhost/v1/_version")
assert json.loads(output)["revision"] == "${revision}", "Spending service revision does not match."
'';
}
{
"name": "release2105",
"url": "https://releases.nixos.org/nixos/21.05/nixos-21.05.3065.b3083bc6933/nixexprs.tar.xz",
"sha256": "186vni8rij8bhd6n5n9h55jf2x78v9zdy2gn9v4cpjhajp4pvzm0"
}
{
"name": "release2105",
"url": "https://releases.nixos.org/nixos/21.05/nixos-21.05.3367.fd8a7fd07da/nixexprs.tar.xz",
"sha256": "12p7v805xj5as2fbdh30i0b9iwy8y24sk256rgqfqylxj1784mn8"
}
......@@ -15,6 +15,7 @@ let
};
python-commands = [
./update-nixpkgs
./update-gitlab-repo
];
in
# This derivation creates a package that wraps our tools to setup an environment
......
#!/usr/bin/env python
"""
Update a pinned gitlab repository.
Pass this path to a JSON file and it will update it to the latest
version of the branch it specifies. You can also pass a different
branch or repository owner, which will update the file to point at
the new branch/repository, and update to the latest version.
"""
import argparse
import json
from pathlib import Path
import httpx
from ps_tools import get_url_hash
HASH_TYPE = "sha512"
ARCHIVE_TEMPLATE = "https://{domain}/api/v4/projects/{owner}%2F{repo}/repository/archive.tar.gz?sha={rev}"
BRANCH_TEMPLATE = (
"https://{domain}/api/v4/projects/{owner}%2F{repo}/repository/branches/{branch}"
)
def get_gitlab_commit(config):
response = httpx.get(BRANCH_TEMPLATE.format(**config))
response.raise_for_status()
return response.json()["commit"]["id"]
def get_gitlab_archive_url(config):
return ARCHIVE_TEMPLATE.format(**config)
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument(
"repo_file",
metavar="repo-file",
type=Path,
help="JSON file with pinned configuration.",
)
parser.add_argument(
"--branch",
type=str,
help="Branch to update to.",
)
parser.add_argument(
"--owner",
type=str,
help="Repository owner to update to.",
)
parser.add_argument(
"--rev",
type=str,
help="Revision to pin.",
)
parser.add_argument(
"--dry-run",
action="store_true",
)
args = parser.parse_args()
repo_file = args.repo_file
config = json.loads(repo_file.read_text())
for key in ["owner", "branch"]:
if getattr(args, key) is not None:
config[key] = getattr(args, key)
if args.rev is not None:
config["rev"] = args.rev
else:
config["rev"] = get_gitlab_commit(config)
archive_url = get_gitlab_archive_url(config)
config.update(get_url_hash(HASH_TYPE, "source", archive_url))
output = json.dumps(config, indent=2)
if args.dry_run:
print(output)
else:
repo_file.write_text(output)
if __name__ == "__main__":
main()