forked from the-distro/infra
fix(ows): per-job runtime directories + proper local refspec
The local refspec was weird and exploiting a edge case for the nixpkgs jobs where local and from were the same. We are more explicit now, which fixes the sandbox jobs. Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
This commit is contained in:
parent
d84a43b781
commit
62ccc0282b
|
@ -51,7 +51,7 @@
|
|||
name = "nixpkgs-${branchName}";
|
||||
fromUri = "https://github.com/NixOS/nixpkgs";
|
||||
fromRefspec = branchName;
|
||||
localRefspec = "refs/remotes/origin/${branchName}";
|
||||
localRefspec = branchName;
|
||||
inherit timer;
|
||||
};
|
||||
in
|
||||
|
@ -81,7 +81,7 @@
|
|||
name = "raito-unstable-sync";
|
||||
fromUri = "https://github.com/NixOS/nixpkgs";
|
||||
fromRefspec = "nixos-unstable-small";
|
||||
localRefspec = "refs/remotes/origin/sandbox/raito/raito-unstable-small";
|
||||
localRefspec = "sandbox/raito/raito-unstable-small";
|
||||
timer = "*-*-* 12:00:00";
|
||||
};
|
||||
|
||||
|
@ -89,7 +89,7 @@
|
|||
name = "raito-release-sync";
|
||||
fromUri = "https://github.com/NixOS/nixpkgs";
|
||||
fromRefspec = "nixos-24.05";
|
||||
localRefspec = "refs/remotes/origin/sandbox/raito/raito-nixos-24.05";
|
||||
localRefspec = "sandbox/raito/raito-nixos-24.05";
|
||||
timer = "daily";
|
||||
};
|
||||
};
|
||||
|
|
|
@ -16,7 +16,8 @@ let
|
|||
path = [ pkgs.gitFull pkgs.openssh pkgs.lix ];
|
||||
script = ''
|
||||
set -xe
|
||||
trap "git worktree prune && git worktree remove -f ${name}" EXIT
|
||||
RUNTIME_DIRECTORY="/run/onewaysync-${name}"
|
||||
trap "git worktree remove -f "$RUNTIME_DIRECTORY"/${name}" EXIT
|
||||
|
||||
if [ ! -d "/var/lib/onewaysync/nixpkgs" ]; then
|
||||
echo "First run, synchronizing nixpkgs..."
|
||||
|
@ -26,19 +27,19 @@ let
|
|||
cd /var/lib/onewaysync/nixpkgs
|
||||
echo "Syncing ${fromUri}:${fromRefspec} to /var/lib/onewaysync/nixpkgs:${targetRef}"
|
||||
echo "Current ref: $EXPECTED_REF"
|
||||
git worktree add -f ${cfg.workingDir}/${name} ${localRefspec}
|
||||
cd ${cfg.workingDir}/${name}
|
||||
git pull origin ${fromRefspec}
|
||||
EXPECTED_REF=$(git rev-list ${localRefspec} | head -1)
|
||||
git worktree add -f "$RUNTIME_DIRECTORY"/${name} refs/remotes/origin/${localRefspec}
|
||||
cd "$RUNTIME_DIRECTORY"/${name}
|
||||
git pull origin ${localRefspec}
|
||||
EXPECTED_REF=$(git rev-list refs/remotes/origin/${localRefspec} | head -1)
|
||||
git config user.name Fork-o-Tron
|
||||
git config user.email noreply@forkos.org
|
||||
git fetch ${fromUri} ${fromRefspec}
|
||||
'' + lib.optionalString (!(lib.hasInfix "staging" localRefspec)) ''
|
||||
OLD_STDENV=$(nix eval -f . stdenv.outPath --store /run/onewaysync)
|
||||
OLD_STDENV=$(nix eval -f . stdenv.outPath --store "$RUNTIME_DIRECTORY")
|
||||
'' + ''
|
||||
git merge FETCH_HEAD
|
||||
'' + lib.optionalString (!(lib.hasInfix "staging" localRefspec)) ''
|
||||
NEW_STDENV=$(nix eval -f . stdenv.outPath --store /run/onewaysync)
|
||||
NEW_STDENV=$(nix eval -f . stdenv.outPath --store "$RUNTIME_DIRECTORY")
|
||||
# Do not allow auto-merging a staging iteration
|
||||
test "$OLD_STDENV" = "$NEW_STDENV"
|
||||
'' + ''
|
||||
|
@ -48,8 +49,8 @@ let
|
|||
User = "git";
|
||||
Group = "git";
|
||||
Type = "oneshot";
|
||||
RuntimeDirectory = "onewaysync";
|
||||
WorkingDirectory = cfg.workingDir;
|
||||
RuntimeDirectory = "onewaysync-${name}";
|
||||
WorkingDirectory = "/run/onewaysync-${name}";
|
||||
StateDirectory = "onewaysync";
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue