-
-
Notifications
You must be signed in to change notification settings - Fork 15k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
126 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
name: Check eval on pull request | ||
|
||
on: | ||
- workflow_dispatch | ||
- push | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
tests: | ||
name: eval-check | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
arch: [x86_64-linux, aarch64-linux, aarch64-darwin, x86_64-darwin] | ||
steps: | ||
- name: Set up Git | ||
run: | | ||
git config --global user.email "github-actions[bot]@users.noreply.github.com" | ||
git config --global user.name "GitHub Actions" | ||
- name: Check if Branch is Part of an Open Pull Request | ||
id: check_pr | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
# Extract the current branch name (removes "refs/heads/" from GITHUB_REF) | ||
BRANCH_NAME="${GITHUB_REF#refs/heads/}" | ||
# Get all open pull requests where the head is this branch in the user's fork | ||
PR_INFO=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \ | ||
"https://api.github.com/repos/NixOS/nixpkgs/pulls?head=${{ github.actor }}:${BRANCH_NAME}") | ||
if [[ "$PR_INFO" == "[]" ]]; then | ||
echo "No open pull request found for this branch." | ||
echo "is_pr=false" >> $GITHUB_ENV | ||
else | ||
echo "This branch is part of an open pull request." | ||
PR_NUMBER=$(echo "$PR_INFO" | jq -r '.[0].number') | ||
echo "Pull Request #${PR_NUMBER} detected." | ||
echo "is_pr=true" >> $GITHUB_ENV | ||
echo "pr_number=${PR_NUMBER}" >> $GITHUB_ENV | ||
fi | ||
- name: Wait for PR Merge Commit Ref to Become Available | ||
if: env.is_pr == 'true' | ||
run: | | ||
MAX_ATTEMPTS=10 | ||
SLEEP_TIME=10 | ||
ATTEMPT=1 | ||
while [[ $ATTEMPT -le $MAX_ATTEMPTS ]]; do | ||
MERGE_REF=$(git ls-remote https://github.com/NixOS/nixpkgs "refs/pull/${{ env.pr_number }}/merge") | ||
if [[ -n "$MERGE_REF" ]]; then | ||
echo "Merge commit ref is available." | ||
break | ||
fi | ||
echo "Merge commit ref not available yet. Attempt $ATTEMPT/$MAX_ATTEMPTS. Waiting $SLEEP_TIME seconds..." | ||
sleep $SLEEP_TIME | ||
((ATTEMPT++)) | ||
done | ||
if [[ $ATTEMPT -gt $MAX_ATTEMPTS ]]; then | ||
echo "Merge commit ref did not become available in time." | ||
exit 1 | ||
fi | ||
- name: Checkout PR Merge Commit | ||
if: env.is_pr == 'true' | ||
run: | | ||
git clone --depth 1 https://github.com/NixOS/nixpkgs.git nixpkgs | ||
cd nixpkgs | ||
git fetch --depth 1 https://github.com/NixOS/nixpkgs.git pull/${{ env.pr_number }}/merge | ||
git checkout FETCH_HEAD | ||
- uses: cachix/install-nix-action@08dcb3a5e62fa31e2da3d490afc4176ef55ecd72 # v30 | ||
if: env.is_pr == 'true' | ||
|
||
- name: Check eval | ||
if: env.is_pr == 'true' | ||
run: | | ||
cd nixpkgs | ||
./ci/eval-nixpkgs.sh --system "$system" |
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,46 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euxo pipefail | ||
|
||
system="x86_64-linux" | ||
|
||
parseArgs() { | ||
while [[ $# -gt 0 ]]; do | ||
case $1 in | ||
--system) | ||
system=$2 | ||
shift | ||
;; | ||
*) | ||
echo "Unknown argument: $1" | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
} | ||
|
||
main() { | ||
parseArgs "$@" | ||
tmpdir=$(mktemp -d) | ||
trap 'rm -rf "$tmpdir"' EXIT | ||
( | ||
set +e | ||
nix-env -f . \ | ||
-qa \* \ | ||
--meta \ | ||
--xml \ | ||
--drv-path \ | ||
--show-trace \ | ||
--eval-system "$system" \ | ||
> "$tmpdir/store-path" | ||
echo $? > "$tmpdir/exit-code" | ||
) & | ||
pid=$! | ||
while kill -0 "$pid"; do | ||
free -g | ||
sleep 20 | ||
done | ||
exit "$(cat "$tmpdir/exit-code")" | ||
} | ||
|
||
main |