forked from micro5k/microg-unofficial-installer
-
Notifications
You must be signed in to change notification settings - Fork 0
78 lines (75 loc) · 2.32 KB
/
scripts-testing.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
---
# 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 '\nSHELL: %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'; do
test_on_all_shells "${workspace_dir}/${_script}"
printf '---\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'