From 151c8d7c6b6ee8c14a1ea939cf2ea182acab1be8 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sat, 23 Nov 2024 16:11:13 +0100 Subject: [PATCH 1/7] ci: add scripts to auto pin latest hyprland release --- scripts/ci/latest-hyprland-tag | 9 ++++++ scripts/ci/pin-latest-hyprland | 50 ++++++++++++++++++++++++++++++++++ scripts/{ => ci}/test-pin.sh | 0 3 files changed, 59 insertions(+) create mode 100755 scripts/ci/latest-hyprland-tag create mode 100755 scripts/ci/pin-latest-hyprland rename scripts/{ => ci}/test-pin.sh (100%) diff --git a/scripts/ci/latest-hyprland-tag b/scripts/ci/latest-hyprland-tag new file mode 100755 index 0000000..6bd1c91 --- /dev/null +++ b/scripts/ci/latest-hyprland-tag @@ -0,0 +1,9 @@ +#!/bin/sh + +## Usage +## ----- +## Prints the tag name of the latest Hyprland release + +# if anyone knows jq help me rewrite this +gh release list --repo hyprwm/Hyprland --json tagName,isLatest | \ + nix eval --impure --raw --expr 'with builtins; (head (filter (x: x.isLatest) (fromJSON (readFile /dev/stdin)))).tagName' diff --git a/scripts/ci/pin-latest-hyprland b/scripts/ci/pin-latest-hyprland new file mode 100755 index 0000000..3f6f978 --- /dev/null +++ b/scripts/ci/pin-latest-hyprland @@ -0,0 +1,50 @@ +#!/bin/sh + +set -eu + +## Usage: +## Pins the latest hyprland release to the current HEAD in hyprpm.toml. +## Does nothing if the pin already exists. + +echoerr() { + echo $@ >&2 +} + +findHyprpmPin() { + local hlCommit="$1" + nix eval --raw --impure --expr ' + with builtins; let + hyprpm = fromTOML (readFile ./hyprpm.toml); + hlCommits = map head hyprpm.repository.commit_pins; + in + concatStringsSep "\n" hlCommits + ' | grep "$hlCommit" > /dev/null +} + +getHyprlandCommitFromRev() { + git ls-remote https://github.com/hyprwm/Hyprland.git "$1" \ + | cut -f 1 +} + +SCRIPT_DIR="$(dirname "$0")" + +hlTag="$("$SCRIPT_DIR/latest-hyprland-tag")" +echoerr "found latest Hyprland release: $hlTag" + +hlCommit="$(getHyprlandCommitFromRev "$hlTag")" +echoerr "-> commit: $hlCommit" + +if findHyprpmPin "$hlCommit"; then + echoerr "pin for tag $hlTag already found in hyprpm.toml" + exit 0 +fi + +echoerr "building and testing..." +commitPin="$("$SCRIPT_DIR/test-pin.sh" "$hlTag" HEAD)" + +echoerr "pin tests passed: $commitPin" +echoerr 'updating hyprpm.toml' + +sed -i "/## DO NOT EDIT THIS LINE: for auto pin script ##/i $commitPin" \ + hyrpm.toml + diff --git a/scripts/test-pin.sh b/scripts/ci/test-pin.sh similarity index 100% rename from scripts/test-pin.sh rename to scripts/ci/test-pin.sh From 015757257660746fee7062b0d3282f5c69e8fe5f Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sat, 23 Nov 2024 16:40:47 +0100 Subject: [PATCH 2/7] ci: allow custom hyprgrass rev in pin script --- scripts/ci/pin-latest-hyprland | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/scripts/ci/pin-latest-hyprland b/scripts/ci/pin-latest-hyprland index 3f6f978..0213df5 100755 --- a/scripts/ci/pin-latest-hyprland +++ b/scripts/ci/pin-latest-hyprland @@ -2,9 +2,16 @@ set -eu -## Usage: -## Pins the latest hyprland release to the current HEAD in hyprpm.toml. -## Does nothing if the pin already exists. +usage() { + echoerr "Usage:" + echoerr "" + echoerr " pin-latest-hyprland [HYPRGRASS_REV]" + echoerr "" + echoerr "Pins the latest hyprland release to HYPRGRASS_REV (default HEAD) in hyprpm.toml." + echoerr "Does nothing if a pin on the hyprland release already exists." +} + +HYPRGRASS_REV=${1:-HEAD} echoerr() { echo $@ >&2 @@ -40,7 +47,7 @@ if findHyprpmPin "$hlCommit"; then fi echoerr "building and testing..." -commitPin="$("$SCRIPT_DIR/test-pin.sh" "$hlTag" HEAD)" +commitPin="$("$SCRIPT_DIR/test-pin.sh" "$hlTag" "$HYPRGRASS_REV")" echoerr "pin tests passed: $commitPin" echoerr 'updating hyprpm.toml' From fd8079cf7fedb8fb3466c22c9a986231b4ae32da Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sat, 23 Nov 2024 16:54:58 +0100 Subject: [PATCH 3/7] hyprpm: add script hints for auto-pin --- hyprpm.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/hyprpm.toml b/hyprpm.toml index 6441551..78e1c02 100644 --- a/hyprpm.toml +++ b/hyprpm.toml @@ -16,6 +16,7 @@ commit_pins = [ ["a425fbebe4cf4238e48a42f724ef2208959d66cf", "a86ed5581498186ed31241c0c246629ef771d1e6"], # v0.45.0 ["500d2a3580388afc8b620b0a3624147faa34f98b", "cb929099477407116031010905ce439db771dd62"], # v0.45.1 ["12f9a0d0b93f691d4d9923716557154d74777b0a", "47f6fea6d297dbee8a9c5dea905783bde506fe79"], # v0.45.2 + ## DO NOT EDIT THIS LINE: for auto pin script ## ] [hyprgrass] From 6a4c3c17247d1aacab3b604b8a65ea5235d4cdda Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sat, 23 Nov 2024 16:55:31 +0100 Subject: [PATCH 4/7] ci/test-pin.sh: restore git working tree --- scripts/ci/test-pin.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/ci/test-pin.sh b/scripts/ci/test-pin.sh index 844f527..f01d0a3 100755 --- a/scripts/ci/test-pin.sh +++ b/scripts/ci/test-pin.sh @@ -23,9 +23,14 @@ hyprgrassRev=${2:-main} hyprlandCommit="$(git ls-remote https://github.com/hyprwm/Hyprland.git "${hyprlandRev}" | cut -f 1)" hyprgrassCommit="$(git rev-parse "${hyprgrassRev}")" -git stash +git stash push +origCommit="$(git rev-parse HEAD)" git checkout "${hyprgrassRev}" + nix build --no-link .#hyprgrassWithTests \ --override-input hyprland "github:hyprwm/Hyprland/${hyprlandRev}" \ +git checkout "$origCommit" +git stash pop + echo "[\"${hyprlandCommit}\", \"${hyprgrassCommit}\"], # ${hyprlandRev}" From d82328cae3c7c76ae09a38f10965e9234186b211 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sat, 23 Nov 2024 17:02:30 +0100 Subject: [PATCH 5/7] script: don't checkout in test-pin --- scripts/ci/test-pin.sh | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/scripts/ci/test-pin.sh b/scripts/ci/test-pin.sh index f01d0a3..d1f3933 100755 --- a/scripts/ci/test-pin.sh +++ b/scripts/ci/test-pin.sh @@ -23,14 +23,7 @@ hyprgrassRev=${2:-main} hyprlandCommit="$(git ls-remote https://github.com/hyprwm/Hyprland.git "${hyprlandRev}" | cut -f 1)" hyprgrassCommit="$(git rev-parse "${hyprgrassRev}")" -git stash push -origCommit="$(git rev-parse HEAD)" -git checkout "${hyprgrassRev}" - -nix build --no-link .#hyprgrassWithTests \ +nix build --no-link "git+file://$(pwd)?rev=${hyprgrassRev}#hyprgrassWithTests" \ --override-input hyprland "github:hyprwm/Hyprland/${hyprlandRev}" \ -git checkout "$origCommit" -git stash pop - echo "[\"${hyprlandCommit}\", \"${hyprgrassCommit}\"], # ${hyprlandRev}" From fef6c3b12a03c4d816d916a1c419da948fd877d5 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sat, 23 Nov 2024 17:06:13 +0100 Subject: [PATCH 6/7] ci: fix file name typo --- scripts/ci/pin-latest-hyprland | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/ci/pin-latest-hyprland b/scripts/ci/pin-latest-hyprland index 0213df5..8da91d8 100755 --- a/scripts/ci/pin-latest-hyprland +++ b/scripts/ci/pin-latest-hyprland @@ -52,6 +52,6 @@ commitPin="$("$SCRIPT_DIR/test-pin.sh" "$hlTag" "$HYPRGRASS_REV")" echoerr "pin tests passed: $commitPin" echoerr 'updating hyprpm.toml' -sed -i "/## DO NOT EDIT THIS LINE: for auto pin script ##/i $commitPin" \ - hyrpm.toml +sed -i "/## DO NOT EDIT THIS LINE: for auto pin script ##/ i $commitPin" \ + hyprpm.toml From 5ac878a2a58bbb420d10bfa68ae6a83d649f4f77 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sat, 23 Nov 2024 17:06:26 +0100 Subject: [PATCH 7/7] fix: bad commit pin on hl-v0.45.2 --- hyprpm.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hyprpm.toml b/hyprpm.toml index 78e1c02..e1ce9df 100644 --- a/hyprpm.toml +++ b/hyprpm.toml @@ -15,7 +15,7 @@ commit_pins = [ ["f044e4c9514ec89c4c1fc8a523ca90b8cb907fb7", "070ca398300bf5b9e1a636ca057882c0312c228d"], # CMonitor* -> PHLMONITOR ["a425fbebe4cf4238e48a42f724ef2208959d66cf", "a86ed5581498186ed31241c0c246629ef771d1e6"], # v0.45.0 ["500d2a3580388afc8b620b0a3624147faa34f98b", "cb929099477407116031010905ce439db771dd62"], # v0.45.1 - ["12f9a0d0b93f691d4d9923716557154d74777b0a", "47f6fea6d297dbee8a9c5dea905783bde506fe79"], # v0.45.2 +["12f9a0d0b93f691d4d9923716557154d74777b0a", "cb929099477407116031010905ce439db771dd62"], # v0.45.2 ## DO NOT EDIT THIS LINE: for auto pin script ## ]