Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add script to reproduce GitHub Actions runs locally #431

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@
coreutils
curlMinimal.bin
gitMinimal
gh # GitHub CLI tool
gnutar
foliage.packages.${system}.default
];
Expand Down
38 changes: 38 additions & 0 deletions scripts/reproduce-github-actions-run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env bash

set -o errexit
set -o pipefail

usage() {
echo "Usage: $0 [GHA RUN ID] [(DERIVATION=allPackages)]"
}

REPO="input-output-hk/cardano-haskell-packages"

ghaRunId="$1"
derivation="${2:-allPackages}"

if ! shift; then
usage
exit 0
fi

ARTIFACT_TEMP_DIR="$(mktemp -d)"
trap '{ echo "Cleaning up $ARTIFACT_TEMP_DIR"; rm -rf -- "$ARTIFACT_TEMP_DIR"; }' EXIT

echo "Downloading artifacts for run $ghaRunId in $ARTIFACT_TEMP_DIR"
gh run download --repo "$REPO" "$ghaRunId" --dir "$ARTIFACT_TEMP_DIR"

echo "Unpacking built-repo in $ARTIFACT_TEMP_DIR/_repo"
mkdir "$ARTIFACT_TEMP_DIR/_repo"
tar xf "$ARTIFACT_TEMP_DIR/built-repo/_repo.tar" -C "$ARTIFACT_TEMP_DIR/_repo"

echo -n "Obtaining commit hash ..."
headSha=$(gh run view --repo "$REPO" "$ghaRunId" --json headSha --jq .headSha)
echo " $headSha"

nix build \
"github:$REPO/${headSha}#${derivation}" \
--override-input CHaP "path:$ARTIFACT_TEMP_DIR/_repo" \
--accept-flake-config true \
--print-build-logs --show-trace