Minor change #19
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" | |
shell: bash | |
run: | | |
# Testing scripts... | |
# shellcheck disable=SC2016 # Intended: Expressions don't expand in single quotes | |
readonly workspace_dir='${{ github.workspace }}' | |
not_already_excuted() | |
{ | |
local _shell | |
_shell="$(realpath "${1:?}")" || return 2 | |
case "${EXECUTED_LIST?}|" in | |
*"|${_shell:?}|"*) return 1 ;; # Already executed | |
*) ;; | |
esac | |
EXECUTED_LIST="${EXECUTED_LIST?}|${_shell:?}" | |
return 0 # NOT already executed | |
} | |
test_on_all_shells() | |
{ | |
local _shell | |
EXECUTED_LIST='' | |
for _shell in sh dash bash ksh zsh osh; do | |
if ! _shell="$(command -v "${_shell:?}")" || ! not_already_excuted "${_shell:?}"; then continue; fi | |
printf 'SHELL: %s - SCRIPT: %s\n\n' "${_shell:?}" "${1:?}" | |
"${_shell:?}" "${1:?}" | |
printf '\nRETURN CODE:%s\n\n' "${?}" | |
done | |
} | |
export ONLY_FOR_TESTING='true' | |
for _script in 'tools/bits-info.sh'; do | |
test_on_all_shells "${workspace_dir}/${_script}" | |
printf '%s\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' |