Update scripts-testing.yml #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
# SPDX-FileCopyrightText: (c) 2024 ale5000 | |
# SPDX-License-Identifier: GPL-3.0-or-later | |
name: "Scripts testing" | |
permissions: {} | |
on: | |
push: | |
paths: | |
- ".github/workflows/scripts-testing.yml" | |
- "tools/*.sh" | |
- "includes/*.sh" | |
- "cmdline.sh" | |
pull_request: | |
paths: | |
- ".github/workflows/scripts-testing.yml" | |
- "tools/*.sh" | |
- "includes/*.sh" | |
- "cmdline.sh" | |
workflow_dispatch: | |
jobs: | |
base: | |
strategy: | |
matrix: | |
os: | |
- ubuntu-latest | |
- windows-latest | |
- macos-latest | |
- macos-13 | |
name: "${{ matrix.os }}" | |
runs-on: "${{ matrix.os }}" | |
steps: | |
- name: "Checkout sources" | |
uses: actions/checkout@v4 | |
- name: "Test scripts on Bash" | |
shell: bash | |
run: | | |
# Testing scripts... | |
# shellcheck disable=SC2016 # Intended: Expressions don't expand in single quotes | |
readonly workspace_dir='${{ github.workspace }}' | |
contains() | |
{ | |
case "|${2?}|" in | |
*"|${1:?}|"*) return 0 ;; # Found | |
*) ;; | |
esac | |
return 1 # NOT found | |
} | |
test_on_all_shells() | |
{ | |
local _shell _executed_list | |
for _shell in sh bash dash ksh zsh osh csh tcsh; do | |
if ! _shell="$(command -v "${_shell:?}")" || ! _shell="$(realpath "${_shell:?}")"; then continue; fi | |
printf 'SHELL: %s - SCRIPT: "%s"\n\n' "${_shell:?}" "${1:?}" | |
"${_shell:?}" "${1:?}" | |
printf '\nRETURN CODE:%s\n' "${?}" | |
done | |
} | |
export ONLY_FOR_TESTING='true' | |
for _script in 'tools/bits-info.sh' 'cmdline.sh'; do | |
test_on_all_shells "${workspace_dir}/${_script}" | |
printf '\n---\n' | |
done | |
- name: "Test script on Oils (only under macOS-latest)" | |
if: "${{ matrix.os == 'macos-latest' }}" | |
shell: bash | |
run: | | |
# Testing script... | |
brew 1> /dev/null install --quiet oils-for-unix | |
osh --version | head -n 1 | |
printf '\n%s\n\n' 'bits-info.sh:' | |
osh '${{ github.workspace }}/tools/bits-info.sh' |