-
Notifications
You must be signed in to change notification settings - Fork 0
147 lines (144 loc) · 4.75 KB
/
unit-tests.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
---
name: unit-tests
on: [push, pull_request]
jobs:
unit-tests:
env:
SHELL: ${{ matrix.sh }}
TERM: linux # work around tput tty issue
strategy:
fail-fast: false
matrix:
os:
- macos-13
- macos-12
- macos-11
- ubuntu-22.04
- ubuntu-20.04
sh:
- sh # default shell
- bash
- bb # BusyBox
- dash
- gwsh
- ksh
- mksh
- yash
- zsh
exclude:
# BusyBox not easily installable on macOS
- { os: macos-13, sh: bb }
- { os: macos-12, sh: bb }
- { os: macos-11, sh: bb }
# HomeBrew's yash does not work with ShellSpec for some reason
- { os: macos-13, sh: yash }
- { os: macos-12, sh: yash }
- { os: macos-11, sh: yash }
include:
# gwsh: since we're building from source, testing different
# OS versions doesn't make sense.
- { os: ubuntu-22.04, sh: gwsh }
- { os: macos-13, sh: gwsh }
# NOTE: mrsh and posh are temporarily disabled because they don't work
# with ShellSpec.
#
# mrsh: since we're building from source, testing different
# Ubuntu versions doesn't make sense.
# Also, Ubuntu only, because mrsh does not build on macOS.
#- { os: ubuntu-22.04, sh: mrsh } # https://mrsh.sh
# Policy-compliant Ordinary SHell
#- { os: ubuntu-20.04, sh: posh }
#- { os: ubuntu-22.04, sh: posh }
runs-on: ${{ matrix.os }}
steps:
- name: Check out repository code
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: true
- name: Prepare shell
env:
MATRIX_OS: ${{ matrix.os }}
MATRIX_SH: ${{ matrix.sh }}
run: |
set -x
case ${MATRIX_OS%%-*}-${MATRIX_SH}
in
(*-gwsh)
gwsh_src=${TMPDIR:-/tmp}/gwsh-build
git clone 'https://github.com/hvdijk/gwsh.git' "${gwsh_src:?}"
(
cd "${gwsh_src:?}" || exit 1
./configure --prefix="${HOME:?}/.local" &&
make install
case ${MATRIX_OS%%-*}
in
(macos)
mkdir -p "${HOME:?}/bin"
ln -s ../.local/bin/gwsh "${HOME:?}/bin/gwsh" ;;
esac
)
rm -rf "${gwsh_src:?}" ;;
(macos-mksh|macos-yash)
brew install "${MATRIX_SH}" ;;
(*-mrsh)
mrsh_src=${TMPDIR:-/tmp}/mrsh-build
git clone 'https://git.sr.ht/~emersion/mrsh' "${mrsh_src:?}"
(
cd "${mrsh_src:?}" || exit 1
./configure --prefix="${HOME:?}/.local" --without-readline &&
make install
)
rm -rf "${mrsh_src:?}" ;;
(ubuntu-bash|ubuntu-dash|ubuntu-ksh|ubuntu-mksh|ubuntu-posh|ubuntu-yash|ubuntu-zsh)
sudo apt-get -y install "${MATRIX_SH}" ;;
(ubuntu-bb)
sudo apt-get -y install busybox
mkdir -p ~/.local/bin
printf >~/.local/bin/bb "#!/bin/sh\\nBUSYBOX=%s\\ncase \$* in (--version) \"\${BUSYBOX}\" | sed -n -e '/^\$/q' -e 'p'; exit 0 ;; esac\\nexec \"\${BUSYBOX}\" sh \"\$@\"\\n" "$(command -v busybox)"
chmod +x ~/.local/bin/bb
;;
esac
- name: Information
env:
MATRIX_OS: ${{ matrix.os }}
run: |
printf 'Kernel:\n'
uname -a
printf '\nPATH:\n%s\n' "${PATH}"
printf '\nShell (%s):\n' "$(command -v "${SHELL}")"
case ${SHELL}
in
(bash|zsh)
"${SHELL}" --version ;;
(bb)
# (by the launcher script installed before)
"${SHELL}" --version ;;
(sh|dash)
case $(uname -s)
in
(Darwin)
what $(command -v "${SHELL}") ;;
esac ;;
(gwsh)
false ;;
(ksh|mksh)
"${SHELL}" -c 'echo $0: ${KSH_VERSION}' ;;
(yash)
"${SHELL}" --version ;;
(*)
case ${MATRIX_OS%%-*}
in
(ubuntu)
dpkg -s "${SHELL}" | sed -n 's/^Version: *//p' | grep ^ ;;
(*)
false ;;
esac ;;
esac \
|| printf '%s\n' '?'
printf '\nShellSpec:\n'
spec/.shellspec/bin/shellspec --version
- name: Run unit tests (ShellSpec)
if: always()
run: |
make SPEC_SHELL="${SHELL}" spec