Rewrite workflow to use Docker images for testing on linux (#956)
Some checks failed
Build / build-linux (3.0.0) (push) Has been cancelled
Build / build-linux (3.0.2) (push) Has been cancelled
Build / build-linux (3.1.2) (push) Has been cancelled
Build / build-linux (3.2.2) (push) Has been cancelled
Build / build-linux (3.3.1) (push) Has been cancelled
Build / build-linux (3.4.1) (push) Has been cancelled
Build / build-linux (3.5.1) (push) Has been cancelled
Build / build-linux (3.6.4) (push) Has been cancelled
Build / build-linux (3.7.1) (push) Has been cancelled
Build / build-linux (4.0.0) (push) Has been cancelled
Build / build-macos (macos-13) (push) Has been cancelled
Build / build-macos (macos-14) (push) Has been cancelled
Build / build-macos (macos-latest) (push) Has been cancelled

* rewrite workflow to use Docker images for testing on linux

* avoid string collect as it's unsupported in 3.0.0

* use while read instead of mktemp to capture outputs

---------

Co-authored-by: Kevin F. Konrad <kevin.konrad@skillbyte.de>
This commit is contained in:
Kevin F. Konrad 2025-03-11 00:35:25 +01:00 committed by GitHub
parent fb79486f9f
commit 3fea811147
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 64 additions and 73 deletions

19
.github/actions/run-tests/action.yml vendored Normal file
View File

@ -0,0 +1,19 @@
name: "Run tests"
description: "Install fish and Oh My Fish! if necessary and run CI tests"
runs:
using: "composite"
steps:
- name: Install Fish
shell: bash
if: runner.os == 'macOS'
run: brew update && brew install fish
- name: Install Oh My Fish!
shell: bash
run: fish bin/install --verbose --offline --noninteractive --yes
- name: Run tests on latest fish
shell: bash
run: |
tests/run.fish
fish -c 'fish-spec pkg/{fish-spec,omf}/spec/*_spec.fish'

View File

@ -7,50 +7,45 @@ on:
paths-ignore:
- '**.md'
jobs:
build:
build-linux:
strategy:
fail-fast: false
matrix:
# only use the latest patch level for all minor versions to reduce number of jobs
fish:
- '3.0.0' # since 3.0.0 is the oldest officially supported version it's included as well
- '3.0.2'
- '3.1.2'
- '3.2.2'
- '3.3.1'
- '3.4.1'
- '3.5.1'
- '3.6.4'
- '3.7.1'
- '4.0.0'
runs-on: ubuntu-latest
container:
image: ohmyfish/fish:${{ matrix.fish }}
options: --user root
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Run tests
uses: ./.github/actions/run-tests
build-macos:
strategy:
fail-fast: false
matrix:
os:
- ubuntu-20.04
- ubuntu-22.04
- ubuntu-latest
fish:
- stock
- 3
- 4
- brew
exclude:
- os: ubuntu-20.04
fish: 4
- os: ubuntu-latest
fish: 4
include:
- os: macos-latest
fish: brew
- os: macos-13
fish: brew
- os: macos-14
fish: brew
- macos-latest
- macos-13
- macos-14
runs-on: ${{ matrix.os }}
steps:
- name: Checkout the repository
uses: actions/checkout@v3
- name: Add brew to path for Ubuntu
if: startsWith(matrix.os, 'ubuntu') && matrix.fish == 'brew'
run: |
echo "/home/linuxbrew/.linuxbrew/bin" >> $GITHUB_PATH
echo "/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH
- name: Install Fish
run: FISH_RELEASE=${{ matrix.fish }} tools/ci-install-fish.sh
- name: Install Oh My Fish!
run: fish bin/install --verbose --offline --noninteractive --yes
uses: actions/checkout@v4
- name: Run tests
run: |
tests/run.fish
pushd pkg/fish-spec; fish -c 'fish-spec'; popd
pushd pkg/omf; fish -c 'fish-spec'; popd
uses: ./.github/actions/run-tests

View File

@ -75,29 +75,32 @@ function __fish_spec_run_test_function -a test_func
set test_func_human_readable (string replace 'it_' 'IT ' $test_func | string replace -a '_' ' ')
__fish_spec.color.echo-n.info "$test_func_human_readable"
set -l before_each_output ""
if functions --query before_each
set -l before_each_output (before_each 2>&1 | string collect)
before_each 2>1 | while read -l line; test -z "$before_each_output" && set before_each_output $line || set before_each_output $before_each_output\n$line; end
end
set -l test_func_output ($test_func 2>&1 | string collect)
set -l test_func_output ""
$test_func 2>&1 | while read -l line; test -z "$test_func_output" && set test_func_output $line || set test_func_output $test_func_output\n$line; end
set result $status
set -l after_each_output ""
if functions --query after_each
set -l before_each_output (before_each 2>&1 | string collect)
after_each 2>&1 | while read -l line; test -z "$after_each_output" && set after_each_output $line || set after_each_output $after_each_output\n$line; end
end
if test $__fish_spec_last_assertion_failed = no
__fish_spec.color.echo.success \r"$test_func_human_readable passed!"
if test "$FISH_SPEC_VERBOSE" = 1
test -n "$before_each_output" && echo $before_each_output
test -n "$test_func_output" && echo $test_func_output
test -n "$after_each_output" && echo $after_each_output
test -n "$before_each_output" && echo "$before_each_output"
test -n "$test_func_output" && echo "$test_func_output"
test -n "$after_each_output" && echo "$after_each_output"
end
else
__fish_spec.color.echo.failure \r"$test_func_human_readable failed."
test -n "$before_each_output" && echo $before_each_output
test -n "$test_func_output" && echo $test_func_output
test -n "$after_each_output" && echo $after_each_output
test -n "$before_each_output" && echo "$before_each_output"
test -n "$test_func_output" && echo "$test_func_output"
test -n "$after_each_output" && echo "$after_each_output"
set __fish_spec_last_assertion_failed no
end
end

View File

@ -1,26 +0,0 @@
#!/usr/bin/env bash
set -o pipefail
set -o errexit
set -o nounset
if [[ $FISH_RELEASE = "brew" ]]; then
brew update
brew install fish
else
if [[ $FISH_RELEASE == "4" ]]; then
REPO_PPA="ppa:fish-shell/beta-4"
else
REPO_PPA="ppa:fish-shell/release-3"
fi
if [[ $FISH_RELEASE != "stock" ]]; then
sudo apt-add-repository -y $REPO_PPA
fi
sudo apt-cache policy fish
sudo apt-get update
sudo apt-get install -y fish
fi
fish --version