Skip to content

Commit

Permalink
ci: fix the underlying failure with xonsh var failures
Browse files Browse the repository at this point in the history
it cannot delete unset variables, so check them first:
- https://github.com/bevry/dorothy/actions/runs/13228345318/job/36922092005#step:9:82

to debug in the future:

```
      - name: 'Debug Login Shell: xonsh'
        shell: bash -leo pipefail {0}
        run: |
          echo-file -- '/home/runner/.config/xonsh/rc.xsh'
          echo-file -- xonsh.log || :
          setup-environment-commands xonsh --refresh
```
  • Loading branch information
balupton committed Feb 9, 2025
1 parent d3cacc2 commit 5430d8b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 22 deletions.
8 changes: 1 addition & 7 deletions .github/workflows/dorothy-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,7 @@ jobs:
command-exists -- dorothy
echo-style --success='ok'
- name: 'Dorothy Login Shell: xonsh'
env:
PKG_CONFIG_PATH: '' # fix: https://github.com/bevry/dorothy/actions/runs/6349881708/job/17248752072#step:8:8
LDFLAGS: '' # fix: https://github.com/bevry/dorothy/actions/runs/6349927188/job/17248892389#step:8:9
CPPFLAGS: '' # fix: https://github.com/bevry/dorothy/actions/runs/6349956372/job/17248986621#step:8:10
CXX: '' # fix: https://github.com/bevry/dorothy/actions/runs/7538723888/job/20519802798#step:8:12
CC: '' #fix: https://github.com/bevry/dorothy/actions/runs/7538922544/job/20520381661#step:8:13
shell: xonsh -DXONSH_SHOW_TRACEBACK=True -l {0}
shell: xonsh -DXONSH_SHOW_TRACEBACK=True -DXONSH_TRACEBACK_LOGFILE=xonsh.log -l {0}
run: |
command-exists -- dorothy
echo-style --success='ok'
Expand Down
38 changes: 23 additions & 15 deletions sources/env.bash
Original file line number Diff line number Diff line change
Expand Up @@ -112,46 +112,54 @@ function on_env_finish {
if [[ -z $value ]]; then
# echo var action: delete
if [[ $shell == 'fish' ]]; then
echo "set --universal --erase $name;"
printf '%s\n' "set --universal --erase $name;"
elif [[ $shell == 'nu' ]]; then
echo "setenv $name"
printf '%s\n' "setenv $name"
elif [[ $shell == 'xonsh' ]]; then
echo 'del $'"$name"
printf '%s\n' "if \${...}.get('$name') != None:"$'\n\t'"del \$$name"
elif [[ $shell == 'elvish' ]]; then
# https://elv.sh/ref/builtin.html#unset-env
echo "unset-env $name"
printf '%s\n' "unset-env $name"
else
echo "unset -v $name;"
printf '%s\n' "unset -v $name;"
fi
elif [[ $is_path == 'yes' ]]; then
# echo var action: set path
if [[ $shell == 'fish' ]]; then
echo "set --export --path $name '$value';"
printf '%s\n' "set --export --path $name '$value';"
elif [[ $shell == 'nu' ]]; then
echo "setenv $name $value"
printf '%s\n' "setenv $name $value"
elif [[ $shell == 'xonsh' ]]; then
echo '$'"$name = '$value'.split(':')"
printf '%s\n' '$'"$name = '$value'.split(':')"
elif [[ $shell == 'elvish' ]]; then
# https://elv.sh/ref/builtin.html#set-env
echo "set-env $name '$value'"
printf '%s\n' "set-env $name '$value'"
else
echo "export $name='$value';"
printf '%s\n' "export $name='$value';"
fi
else
# echo var action: set
if [[ $shell == 'fish' ]]; then
echo "set --export $name '$value';"
printf '%s\n' "set --export $name '$value';"
elif [[ $shell == 'nu' ]]; then
echo "setenv $name $value"
printf '%s\n' "setenv $name $value"
elif [[ $shell == 'xonsh' ]]; then
echo '$'"$name = '$value'"
printf '%s\n' '$'"$name = '$value'"
elif [[ $shell == 'elvish' ]]; then
# https://elv.sh/ref/builtin.html#set-env
echo "set-env $name '$value'"
printf '%s\n' "set-env $name '$value'"
else
echo "export $name='$value';"
printf '%s\n' "export $name='$value';"
fi
fi
done < <(env)
# xonsh needs a trailing newline, because xonsh, fixes:
# > xonsh
# xonsh: For full traceback set: $XONSH_SHOW_TRACEBACK = True
# SyntaxError: None: no further code
# syntax error in xonsh run control file '/Users/balupton/.config/xonsh/rc.xsh': None: no further code
if [[ $shell == 'xonsh' ]]; then
printf '\n'
fi
}
trap on_env_finish EXIT

0 comments on commit 5430d8b

Please sign in to comment.