Commit 3fea8111 authored by Kevin  F. Konrad's avatar Kevin F. Konrad Committed by GitHub

Rewrite workflow to use Docker images for testing on linux (#956)

* 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: default avatarKevin F. Konrad <kevin.konrad@skillbyte.de>
parent fb79486f
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'
...@@ -7,50 +7,45 @@ on: ...@@ -7,50 +7,45 @@ on:
paths-ignore: paths-ignore:
- '**.md' - '**.md'
jobs: jobs:
build: build-linux:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
os: # only use the latest patch level for all minor versions to reduce number of jobs
- ubuntu-20.04
- ubuntu-22.04
- ubuntu-latest
fish: fish:
- stock - '3.0.0' # since 3.0.0 is the oldest officially supported version it's included as well
- 3 - '3.0.2'
- 4 - '3.1.2'
- brew - '3.2.2'
exclude: - '3.3.1'
- os: ubuntu-20.04 - '3.4.1'
fish: 4 - '3.5.1'
- os: ubuntu-latest - '3.6.4'
fish: 4 - '3.7.1'
include: - '4.0.0'
- os: macos-latest runs-on: ubuntu-latest
fish: brew container:
- os: macos-13 image: ohmyfish/fish:${{ matrix.fish }}
fish: brew options: --user root
- os: macos-14
fish: brew
runs-on: ${{ matrix.os }}
steps: steps:
- name: Checkout the repository - name: Checkout the repository
uses: actions/checkout@v3 uses: actions/checkout@v4
- 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 - name: Run tests
run: FISH_RELEASE=${{ matrix.fish }} tools/ci-install-fish.sh uses: ./.github/actions/run-tests
- name: Install Oh My Fish! build-macos:
run: fish bin/install --verbose --offline --noninteractive --yes strategy:
fail-fast: false
matrix:
os:
- macos-latest
- macos-13
- macos-14
runs-on: ${{ matrix.os }}
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Run tests - name: Run tests
run: | uses: ./.github/actions/run-tests
tests/run.fish
pushd pkg/fish-spec; fish -c 'fish-spec'; popd
pushd pkg/omf; fish -c 'fish-spec'; popd
...@@ -75,29 +75,32 @@ function __fish_spec_run_test_function -a test_func ...@@ -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 '_' ' ') set test_func_human_readable (string replace 'it_' 'IT ' $test_func | string replace -a '_' ' ')
__fish_spec.color.echo-n.info "⏳ $test_func_human_readable" __fish_spec.color.echo-n.info "⏳ $test_func_human_readable"
set -l before_each_output ""
if functions --query before_each 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 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 result $status
set -l after_each_output ""
if functions --query after_each 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 end
if test $__fish_spec_last_assertion_failed = no if test $__fish_spec_last_assertion_failed = no
__fish_spec.color.echo.success \r"✅ $test_func_human_readable passed!" __fish_spec.color.echo.success \r"✅ $test_func_human_readable passed!"
if test "$FISH_SPEC_VERBOSE" = 1 if test "$FISH_SPEC_VERBOSE" = 1
test -n "$before_each_output" && echo $before_each_output test -n "$before_each_output" && echo "$before_each_output"
test -n "$test_func_output" && echo $test_func_output test -n "$test_func_output" && echo "$test_func_output"
test -n "$after_each_output" && echo $after_each_output test -n "$after_each_output" && echo "$after_each_output"
end end
else else
__fish_spec.color.echo.failure \r"❌ $test_func_human_readable failed." __fish_spec.color.echo.failure \r"❌ $test_func_human_readable failed."
test -n "$before_each_output" && echo $before_each_output test -n "$before_each_output" && echo "$before_each_output"
test -n "$test_func_output" && echo $test_func_output test -n "$test_func_output" && echo "$test_func_output"
test -n "$after_each_output" && echo $after_each_output test -n "$after_each_output" && echo "$after_each_output"
set __fish_spec_last_assertion_failed no set __fish_spec_last_assertion_failed no
end end
end end
#!/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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment