Skip to content

Commit

Permalink
Preserve exit status of nix develop
Browse files Browse the repository at this point in the history
  • Loading branch information
nicknovitski committed Nov 12, 2024
1 parent 1c99270 commit 1bd9aad
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ jobs:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v30
- uses: ./
- name: Make the nix command fail
uses: ./ --bad-arg
id: should-fail
continue-on-error: true
- name: Fail if the action succeeded when it should have failed
if: steps.should-fail.outcome == success()
run: exit 1
check:
strategy:
matrix:
Expand Down
5 changes: 3 additions & 2 deletions nix-develop-gha.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ contains() {
envOutput=

# Iterate over the output of `env -0` in the shell environment
while IFS='=' read -r -d '' n v; do
while IFS='=' read -r -d '' n v || exit "$n"
do
# If this variable is empty then we're in the first loop, and $n is the
# output of the shellHook _before_ `env` is run.
if ! [ "$envOutput" ]; then
Expand Down Expand Up @@ -68,4 +69,4 @@ while IFS='=' read -r -d '' n v; do
fi
# Add all environment variables except for PATH to GITHUB_ENV.
printf "%s=%s\n" "$n" "$v" >>"${GITHUB_ENV:-/dev/stderr}"
done < <(nix develop "${arguments[@]}" --command bash -c "echo -ne '\0'; env -0")
done < <(set +e; nix develop "${arguments[@]}" --command bash -c "echo -ne '\0'; env -0"; printf "$?")

0 comments on commit 1bd9aad

Please sign in to comment.