-
Notifications
You must be signed in to change notification settings - Fork 14
255 lines (223 loc) · 8.85 KB
/
main.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
name: run-tests
on:
pull_request: # Should trigger on pull requests for all branches
branches:
- '**' # Matches all branches
# Cancel previous runs if a new one is triggered
concurrency:
group: "${{ github.ref }}"
cancel-in-progress: true
jobs:
build-without-warnings:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install gcc and clang
run: |
set -e
sudo apt-get update
sudo apt-get install -y build-essential clang-14
- name: Build with warnings
run: |
set -e
# Testing with gcc clang in case they have different warnings
gcc -Wall -Werror pnut.c -Dsh
gcc -Wall -Werror pnut.c -Dtarget_x86_64_mac
gcc -Wall -Werror pnut.c -Dtarget_x86_64_linux
gcc -Wall -Werror pnut.c -Dtarget_i386_linux
# With clang
clang-14 -Wall -Werror pnut.c -Dsh
clang-14 -Wall -Werror pnut.c -Dtarget_x86_64_mac
clang-14 -Wall -Werror pnut.c -Dtarget_x86_64_linux
clang-14 -Wall -Werror pnut.c -Dtarget_i386_linux
catch-bad-whitespace:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Check for trailing whitespace and tab characters
run: |
set -e
check_dir() { # $1 is the file extension, $2 is the directory and $3 the max depth to check
result=$(find $2 -maxdepth ${3:-1000} -name "$1" -type f -exec egrep -l " +$" {} \;)
if [ -n "$result" ]; then
echo "Trailing whitespace found in the following files:"
echo "$result"
exit 1
fi
result=$(find $2 -maxdepth ${3:-1000} -name "$1" -type f -exec egrep -l "$(printf '\t')" {} \;)
if [ -n "$result" ]; then
echo "Tab characters found in the following files:"
echo "$result"
exit 1
fi
}
check_dir "*.c" . 1 # Check pnut source files
check_dir "*.c" tests # and the tests directory recursively
check_dir "*.c" examples 1 # and examples
tests-exe: # Run tests for pnut-exe on all supported platforms and architectures
strategy:
matrix:
include:
- target: i386_linux
host: ubuntu-latest
- target: x86_64_linux
host: ubuntu-latest
- target: x86_64_mac
host: macos-latest
runs-on: ${{ matrix.host }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install utils
run: |
if [ ${{ matrix.host }} = "macos-latest" ]; then
brew install coreutils
else
sudo apt-get update
sudo apt-get install -y coreutils
fi
- name: Run ${{ matrix.target }} tests on ${{ matrix.host }}
run: |
set -e
./run-tests.sh ${{ matrix.target }}
tests-shell: # Run tests for pnut-sh on all supported shells
strategy:
matrix:
shell: ["bash", "dash", "ksh", "mksh", "yash", "zsh"]
include:
- shell: dash # Using dash because it's the fastest
pnut_opts: "'-DSH_SAVE_VARS_WITH_SET' '-DOPTIMIZE_CONSTANT_PARAM'"
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install ${{ matrix.shell }} shell
run: |
sudo apt-get update
sudo apt-get install -y coreutils ${{ matrix.shell }}
- name: Run tests with ${{ matrix.shell }}
run: |
set -e
./run-tests.sh sh --shell ${{ matrix.shell }}
for pnut_opts in ${{ matrix.pnut_opts }}; do
echo "Running tests with pnut options: $pnut_opts"
PNUT_OPTIONS="${pnut_opts}" ./run-tests.sh sh --shell ${{ matrix.shell }}
done
bootstrap-pnut-sh:
strategy:
matrix:
shell: ["bash", "dash", "ksh", "mksh", "yash", "zsh"]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install ${{ matrix.shell }} shell
run: |
sudo apt-get update
sudo apt-get install -y coreutils ${{ matrix.shell }}
- name: Bootstrap pnut-sh.sh on ${{ matrix.shell }}
run: |
set -e
./bootstrap-pnut-sh.sh --shell ${{ matrix.shell }} --fast
bootstrap-pnut-exe:
strategy:
matrix:
shell: ["bash", "dash", "ksh"] # Not all shells to save some time
target: ["i386_linux", "x86_64_linux", "x86_64_mac"]
include:
- target: i386_linux
host: ubuntu-latest
- target: x86_64_linux
host: ubuntu-latest
- target: x86_64_mac
host: macos-latest
runs-on: ${{ matrix.host }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install ${{ matrix.shell }} shell
run: |
if [ ${{ matrix.host }} = "macos-latest" ]; then
brew install coreutils ${{ matrix.shell }}
else
sudo apt-get update
sudo apt-get install -y coreutils ${{ matrix.shell }}
fi
- name: Bootstrap pnut-exe with ${{ matrix.target }} backend
run: |
set -e
./bootstrap-pnut-exe.sh --backend ${{ matrix.target }} --fast
- name: Bootstrap pnut-exe with ${{ matrix.target }} backend on ${{ matrix.shell }}
run: |
set -e
./bootstrap-pnut-exe.sh --backend ${{ matrix.target }} --shell ${{ matrix.shell }} --fast
bootstrap-pnut-sh-with-pnut-exe:
strategy:
matrix:
target: ["i386_linux", "x86_64_linux", "x86_64_mac"]
include:
- target: i386_linux
host: ubuntu-latest
- target: x86_64_linux
host: ubuntu-latest
- target: x86_64_mac
host: macos-latest
runs-on: ${{ matrix.host }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install dependencies
run: |
if [ ${{ matrix.host }} = "macos-latest" ]; then
brew install coreutils
else
sudo apt-get update
sudo apt-get install -y coreutils
fi
- name: Bootstrap pnut-sh with pnut-exe on ${{ matrix.target }} backend
run: |
set -e
./bootstrap-pnut-sh-by-pnut-exe.sh --backend ${{ matrix.target }}
bootstrap-bash-2_05a:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup woody environment
run: |
set -e
sudo apt-get update
sudo apt-get install -y debootstrap # debootstrap allows us to create a minimal Debian environment
tar -czf ../pnut.tar.gz . # Make a copy of the pnut repo (excluding the woody directory)
sudo debootstrap --arch=i386 woody woody http://archive.debian.org/debian
sudo cp ../pnut.tar.gz woody/pnut.tar.gz # Copy the pnut repo into the woody environment
# Check that the woody environment has the right bash version
sudo chroot woody /bin/bash -c "bash --version" | grep 2.05a || { echo "Bash 2.05a is required for this job"; exit 1; }
sudo chroot woody /bin/bash -c "mkdir pnut && tar -xvzf pnut.tar.gz -C pnut" # Extract the pnut repo into the woody environment
sudo chroot woody /bin/bash -c "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential time timeout" # Install gcc and time utils
- name: Run tests with bash 2.05a
run: |
sudo chroot woody /bin/bash -c "cd pnut && PNUT_OPTIONS='-DRT_FREE_UNSETS_VARS_NOT' ./run-tests.sh sh --shell bash"
- name: Bootstrap pnut-sh.sh with bash 2.05a
run: |
sudo chroot woody /bin/bash -c "cd /pnut && PNUT_OPTIONS='-DRT_FREE_UNSETS_VARS_NOT' ./bootstrap-pnut-sh.sh --shell bash --fast"
- name: Bootstrap pnut-exe with bash 2.05a
run: |
sudo chroot woody /bin/bash -c "cd /pnut && PNUT_OPTIONS='-DRT_FREE_UNSETS_VARS_NOT' ./bootstrap-pnut-exe.sh --backend i386_linux --fast"
sudo chroot woody /bin/bash -c "cd /pnut && PNUT_OPTIONS='-DRT_FREE_UNSETS_VARS_NOT' ./bootstrap-pnut-exe.sh --backend i386_linux --shell bash --fast"
success-message:
runs-on: ubuntu-latest
needs: [build-without-warnings, tests-exe, tests-shell, bootstrap-pnut-sh, bootstrap-pnut-exe, bootstrap-pnut-sh-with-pnut-exe, bootstrap-bash-2_05a]
steps:
- name: Tests finished
run: |
echo " ,-~~-.___."
echo " / | ' \\ Pnut tests completed...."
echo "( ) 0"
echo " \\_/-, ,----'"
echo " ==== //"
echo " / \\-'~; /~~~(O)"
echo " / __/~| / |"
echo "=( _____| (_________| "