Skip to content

Commit

Permalink
ci: debug xonsh
Browse files Browse the repository at this point in the history
ci: fix the underlying failure with xonsh var failures

it cannot delete unset variables, so check them first:
- https://github.com/bevry/dorothy/actions/runs/13228345318/job/36922092005#step:9:82
  • Loading branch information
balupton committed Feb 9, 2025
1 parent d3cacc2 commit 07d5d80
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 137 deletions.
130 changes: 8 additions & 122 deletions .github/workflows/dorothy-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,16 @@ 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'
- 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
- name: 'Dorothy Login Shell: elvish'
shell: elvish {0}
run: |
Expand Down Expand Up @@ -156,118 +156,4 @@ jobs:
fi
- name: 'Trunk Check'
shell: bash -leo pipefail {0}
run: dorothy check
# https://github.com/actions/runner-images?tab=readme-ov-file#available-images
runner-test:
if: github.event_name == 'push' || ( github.event_name == 'pull_request' && toJson(github.event.pull_request.draft) == 'false' && toJson(github.event.pull_request.state) == '"open"' && toJson(github.event.pull_request.assignees) != '[]' )
strategy:
fail-fast: false
matrix:
runner:
- ubuntu-24.04
- ubuntu-22.04
- ubuntu-24.04-arm
- ubuntu-22.04-arm
- macos-15
- macos-14
- macos-13
runs-on: ${{ matrix.runner }}
steps:
- name: 'Dorothy Test'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # prevent rate limiting
run: |
# ensure dorothy is cloned, and run command
bash -c "$(curl -fsSL 'https://dorothy.bevry.me/run?slug=${{ github.event.pull_request.head.repo.full_name || github.repository }}&commit=${{ github.event.pull_request.head.sha || github.sha }}')" -- dorothy test
fresh-macos-test:
if: github.event_name == 'push' || ( github.event_name == 'pull_request' && toJson(github.event.pull_request.draft) == 'false' && toJson(github.event.pull_request.state) == '"open"' && toJson(github.event.pull_request.assignees) != '[]' )
strategy:
fail-fast: false
matrix:
runner:
- macos-15
- macos-14
- macos-13
runs-on: ${{ matrix.runner }}
steps:
- name: 'Uninstall Homebrew'
run: |
# run homebrew uninstaller
bash -c "$(curl -fsSL 'https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh')"
- name: 'Dorothy Test'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # prevent rate limiting
run: |
# ensure dorothy is cloned, and run command
bash -c "$(curl -fsSL 'https://dorothy.bevry.me/run?slug=${{ github.event.pull_request.head.repo.full_name || github.repository }}&commit=${{ github.event.pull_request.head.sha || github.sha }}')" -- dorothy test
container-test:
if: github.event_name == 'push' || ( github.event_name == 'pull_request' && toJson(github.event.pull_request.draft) == 'false' && toJson(github.event.pull_request.state) == '"open"' && toJson(github.event.pull_request.assignees) != '[]' )
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
container:
- 'ubuntu:latest' # https://hub.docker.com/_/ubuntu
- 'fedora:latest' # https://hub.docker.com/_/fedora
- 'debian:latest' # https://hub.docker.com/_/debian
- 'alpine:latest' # https://hub.docker.com/_/alpine <-- script -qec workaround for TTY does not work on alpine
- 'opensuse/leap' # https://hub.docker.com/r/opensuse/leap <-- has outdated bash, so is good to test
- 'opensuse/tumbleweed' # https://hub.docker.com/r/opensuse/tumbleweed
- 'kalilinux/kali-rolling' # https://hub.docker.com/r/kalilinux/kali-rolling <-- apt based
# - 'manjarolinux/base' # https://hub.docker.com/r/manjarolinux/base <-- broken due to https://gitlab.manjaro.org/packages/core/bash/-/issues/8 trying to remove it, trying to sync/refresh it, trying everything fails, as such disabled test, see all the failed CI attempts sinc: https://github.com/bevry/dorothy/actions/runs/7999660175/job/21847844816#step:3:84
# - 'voidlinux/voidlinux' # https://hub.docker.com/r/voidlinux/voidlinux <-- locale failure, remote failure: https://github.com/bevry/dorothy/actions/runs/6622814794/job/17988863384
# - 'mageia:cauldron' # https://hub.docker.com/_/mageia <-- cauldron is were moreutils is, disabled as couldn't get working
# - 'nixos/nix' # https://hub.docker.com/r/nixos/nix <-- doesn't make bash available to env, also locale failure
# - 'gentoo/stage3' # https://hub.docker.com/r/gentoo/stage3 <-- couldn't get to work due to home misconfigure error
container:
image: ${{ matrix.container }}
steps:
- name: 'Dorothy Dependencies'
run: |
# this should somewhat coincide with [commands/dorothy:ensure_prereq_dependencies]
if command -v apt-get; then
# for ubuntu/debian/kali
apt-get update
apt-get install -y bash curl
elif command -v zypper; then
# for opensuse
zypper --non-interactive --gpg-auto-import-keys refresh
zypper --non-interactive install bash curl
elif command -v apk; then
# for alpine
apk update
apk add bash curl
elif command -v pacman; then
# for manjaro (manjaro CI image doesn't have pamac installed) and arch
pacman-key --init
pacman --noconfirm --refresh --sync --needed bash curl
elif command -v urpmi; then
# for mageia, prefer over fedora as mageia also contains dnf
# https://wiki.mageia.org/en/Cauldron
# https://github.com/bevry/dorothy/actions/runs/6033044029/job/16369147940
# https://github.com/bevry/dorothy/actions/runs/6033557632/job/16370418074
# urpmi --auto-update --auto
urpmi.update -a
urpmi --auto bash curl
elif command -v dnf; then
# for fedora
# dnf check-update --assumeyes
# dnf upgrade --assumeyes --refresh --best --allowerasing
dnf install --assumeyes --refresh --best --allowerasing bash curl
elif command -v xbps-install; then
# for void linux
xbps-install --sync --update --yes xbps
xbps-install --sync --yes bash curl
elif command -v nix-env; then
# for nix
nix-env --install --attr nixpkgs.bash nixpkgs.curl
elif command -v emerge; then
# for gentoo
emerge app-shells/bash net-misc/curl
fi
- name: 'Dorothy Remote Tests'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # prevent rate limiting
run: |
# ensure dorothy is cloned, and run command
bash -c "$(curl -fsSL 'https://dorothy.bevry.me/run?slug=${{ github.event.pull_request.head.repo.full_name || github.repository }}&commit=${{ github.event.pull_request.head.sha || github.sha }}')" -- dorothy test
run: dorothy check
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 07d5d80

Please sign in to comment.