-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pre-push hook, set up in activate.sh
- Loading branch information
Showing
3 changed files
with
61 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/usr/bin/env nix | ||
#! nix env shell nixpkgs#bash nixpkgs#gh nixpkgs#jq nixpkgs#gh --command bash | ||
# check if the dependent `nixpkgs-config` is successfully built with github actions | ||
# shellcheck shell=bash | ||
|
||
# This hook is called with the following parameters: | ||
# | ||
# $1 -- Name of the remote to which the push is being done | ||
# $2 -- URL to which the push is being done | ||
# | ||
# If pushing without using a named remote those arguments will be equal. | ||
# | ||
# Information about the commits which are being pushed is supplied as lines to | ||
# the standard input in the form: | ||
# | ||
# <local ref> <local oid> <remote ref> <remote oid> | ||
|
||
set -e | ||
|
||
while read -r local_ref local_oid remote_ref remote_oid | ||
do | ||
>&2 printf "pre-push: %s\t%s\n" "$local_ref" "$local_oid" | ||
>&2 printf " -> %s\t%s\n" "$remote_ref" "$remote_oid" | ||
|
||
rev=$(nix flake metadata --json | jq --raw-output '.locks.nodes."nixpkgs-config".locked.rev') | ||
>&2 echo "flake.lock: nixpkgs-config @ $rev" | ||
|
||
cd nixpkgs-config || exit 1 | ||
gh_runs=$(gh run list --commit "$rev" --json attempt,conclusion,databaseId,displayTitle,headSha,status,updatedAt,url) | ||
echo "$gh_runs" | jq 'sort_by(.databaseId) | reverse' | ||
|
||
latest_status=$(echo "$gh_runs" | jq --raw-output 'sort_by(.databaseId) | reverse | .[0].status') | ||
if [[ "$latest_status" != "completed" ]]; then | ||
>&2 echo "nixpkgs-config: $latest_status, not completed" | ||
exit 1 | ||
fi | ||
|
||
latest_conclusion=$(echo "$gh_runs" | jq --raw-output 'sort_by(.databaseId) | reverse | .[0].conclusion') | ||
if [[ "$latest_conclusion" != "success" ]]; then | ||
>&2 echo "nixpkgs-config: $latest_conclusion, not successful" | ||
exit 1 | ||
fi | ||
done | ||
|
||
exit 0 | ||
|
||
# vim: ft=sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters