diff --git a/pkgs/by-name/ra/radicle-ci-broker/package.nix b/pkgs/by-name/ra/radicle-ci-broker/package.nix new file mode 100644 index 000000000000..a25b9d43276a --- /dev/null +++ b/pkgs/by-name/ra/radicle-ci-broker/package.nix @@ -0,0 +1,72 @@ +{ + lib, + rustPlatform, + fetchFromRadicle, + stdenv, + jq, + gitMinimal, + sqlite, + radicle-node, + versionCheckHook, +}: + +rustPlatform.buildRustPackage (finalAttrs: { + pname = "radicle-ci-broker"; + version = "0.21.0"; + + src = fetchFromRadicle { + seed = "seed.radicle.xyz"; + repo = "zwTxygwuz5LDGBq255RA2CbNGrz8"; + node = "z6MkgEMYod7Hxfy9qCvDv5hYHkZ4ciWmLFgfvm3Wn1b2w2FV"; + tag = "v${finalAttrs.version}"; + hash = "sha256-c0Qo6dnR9rP4mLXODkNZp+AnhKS0tqJeh1KgzfHBRV4="; + leaveDotGit = true; + postFetch = '' + git -C $out rev-parse --short HEAD > $out/.git_head + rm -rf $out/.git + ''; + }; + + cargoHash = "sha256-9MkZh1hlHgLC9rGmLx5ehtLtZfhXsCqrJrCJNr1edBU="; + + postPatch = '' + substituteInPlace build.rs \ + --replace-fail "let hash = " "let hash = \"$(<$src/.git_head)\"; " + ''; + + preCheck = '' + ln -s "$PWD/target/${stdenv.hostPlatform.rust.rustcTarget}/$cargoBuildType" target/debug + ''; + + nativeCheckInputs = [ + jq + gitMinimal + sqlite + radicle-node + ]; + + checkFlags = [ + "--skip=acceptance_criteria_for_upgrades" + "--skip=logs_adapter_stderr_output" + "--skip=process_queued_events" + "--skip=runs_adapter_with_configuration" + ]; + + nativeInstallCheckInputs = [ versionCheckHook ]; + versionCheckProgramArg = "--version"; + doInstallCheck = true; + + passthru.updateScript = ./update.sh; + + meta = { + description = "Radicle CI broker"; + homepage = "https://app.radicle.xyz/nodes/seed.radicle.xyz/rad:zwTxygwuz5LDGBq255RA2CbNGrz8"; + changelog = "https://app.radicle.xyz/nodes/seed.radicle.xyz/rad:zwTxygwuz5LDGBq255RA2CbNGrz8/tree/NEWS.md"; + license = with lib.licenses; [ + mit + asl20 + ]; + maintainers = with lib.maintainers; [ defelo ]; + mainProgram = "cib"; + }; +}) diff --git a/pkgs/by-name/ra/radicle-ci-broker/update.sh b/pkgs/by-name/ra/radicle-ci-broker/update.sh new file mode 100755 index 000000000000..1438e6cd9a70 --- /dev/null +++ b/pkgs/by-name/ra/radicle-ci-broker/update.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p coreutils gnused gitMinimal nix-update + +set -euo pipefail + +dirname="$(dirname "${BASH_SOURCE[0]}")" + +url=$(nix-instantiate --eval --raw -A radicle-ci-broker.src.url) +old_node=$(nix-instantiate --eval --raw -A radicle-ci-broker.src.node) + +ref=$(git ls-remote "$url" 'refs/namespaces/*/refs/tags/v*' \ + | cut -f2 | grep -Ev '\^\{\}$' | sort -t/ -k6rV | head -1) +[[ "$ref" =~ ^refs/namespaces/([^/]+)/refs/tags/v([^/]+)$ ]] +new_node="${BASH_REMATCH[1]}" +version="${BASH_REMATCH[2]}" + +sed -i "s/${old_node}/${new_node}/g" "${dirname}/package.nix" +nix-update --version="$version" radicle-ci-broker