-
Notifications
You must be signed in to change notification settings - Fork 47
209 lines (182 loc) · 6.8 KB
/
linux_and_macos.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
# Copyright (c) 2023 Sebastian Pipping <sebastian@pipping.org>
# Licensed under Apache License Version 2.0
name: Build on Linux/macOS
on:
pull_request:
push:
schedule:
- cron: '0 3 * * 5' # Every Friday at 3am
workflow_dispatch:
# Minimum permissions for security
permissions:
contents: read
jobs:
linux:
name: Build (${{ matrix.cc }}/${{ matrix.make }} on ${{ matrix.runs-on }})
runs-on: ${{ matrix.runs-on }}
strategy:
fail-fast: false
matrix:
include:
- cc: gcc-13
cxx: g++-13
clang_major_version: null
clang_repo_suffix: null
make: make
runs-on: ubuntu-22.04
- cc: clang-17
cxx: clang++-17
clang_major_version: 17
clang_repo_suffix: -17
make: bmake
runs-on: ubuntu-22.04
- cc: clang-18
cxx: clang++-18
clang_major_version: 18
clang_repo_suffix:
make: bmake
runs-on: ubuntu-22.04
- cc: gcc-11
cxx: g++-11
clang_major_version: null
clang_repo_suffix: null
make: make
runs-on: macos-12
- cc: gcc-13
cxx: g++-13
clang_major_version: null
clang_repo_suffix: null
make: bmake
runs-on: macos-12
- cc: clang-15
cxx: clang++-15
clang_major_version: 15
clang_repo_suffix: null
make: bsdmake
runs-on: macos-12
steps:
- name: Add Clang/LLVM repositories
if: "${{ runner.os == 'Linux' && contains(matrix.cxx, 'clang') }}"
run: |-
set -x
source /etc/os-release
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo add-apt-repository "deb http://apt.llvm.org/${UBUNTU_CODENAME}/ llvm-toolchain-${UBUNTU_CODENAME}${{ matrix.clang_repo_suffix }} main"
- name: Install build dependencies
if: "${{ runner.os == 'Linux' }}"
run: |-
sudo apt-get update
sudo apt-get install --yes --no-install-recommends \
bmake \
libncurses-dev \
pkg-config
- name: Install build dependencies
if: "${{ runner.os == 'macOS' }}"
run: |-
brew tap homebrew/cask-fonts
brew install \
agg \
bmake \
bsdmake \
coreutils \
font-liberation \
imagemagick
- name: Install build dependency Clang ${{ matrix.clang_major_version }}
if: "${{ runner.os == 'Linux' && contains(matrix.cxx, 'clang') }}"
run: |-
sudo apt-get install --yes --no-install-recommends -V \
clang-${{ matrix.clang_major_version }} \
libclang-rt-${{ matrix.clang_major_version }}-dev
- name: Add versioned aliases for Clang ${{ matrix.clang_major_version }}
if: "${{ runner.os == 'macOS' && contains(matrix.cxx, 'clang') }}"
run: |-
set -x
sudo ln -s "$(brew --prefix llvm@${{ matrix.clang_major_version }})"/bin/clang /usr/local/bin/clang-${{ matrix.clang_major_version }}
sudo ln -s "$(brew --prefix llvm@${{ matrix.clang_major_version }})"/bin/clang++ /usr/local/bin/clang++-${{ matrix.clang_major_version }}
- name: Checkout Git branch
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: 'Build'
env:
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
MAKE: ${{ matrix.make }}
run: |-
set -x
# macOS default linker does not seem to support --as-needed,
# would error out saying "ld: unknown option: --as-needed"
if [[ ${{ runner.os }} = macOS ]]; then
as_needed=
else
as_needed='-Wl,--as-needed'
fi
# ASan: https://clang.llvm.org/docs/AddressSanitizer.html
# UBSan: https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
sanitizer='-fsanitize=address,undefined -fno-sanitize-recover=all'
${MAKE} --version 2>/dev/null || true
CFLAGS="-std=gnu99 -pedantic -Werror ${sanitizer}" LDFLAGS="${as_needed} ${sanitizer}" ${MAKE}
- name: 'Install'
env:
MAKE: ${{ matrix.make }}
run: |-
set -x -o pipefail
${MAKE} install DESTDIR="${PWD}"/ROOT/
find ROOT/ | sort | xargs ls -ld
- name: 'Uninstall'
env:
MAKE: ${{ matrix.make }}
run: |-
set -x
${MAKE} uninstall DESTDIR="${PWD}"/ROOT/
[[ "$(find ROOT/ -not -type d | tee /dev/stderr)" == '' ]] # i.e. fail CI if leftover files
- name: 'Run UI tests'
if: "${{ runner.os == 'macOS' }}"
run: |-
./recordings/record.sh
rm -Rf recordings/venv/
- name: 'Upload UI test renderings for inspection'
if: "${{ runner.os == 'macOS' }}"
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
name: ttyplot_ui_test_${{ github.sha }}_${{ matrix.runs-on }}_${{ matrix.cc }}
path: recordings/actual*
if-no-files-found: error
- name: 'Evaluate UI test results'
if: "${{ runner.os == 'macOS' }}"
run: |-
assert_images_equal_enough() {
local a="${1}"
local b="${2}"
local diff_output="${3}"
local dissimilarity="$(compare -metric DSSIM "${a}" "${b}" "${diff_output}" 2>&1)"
if ! python3 <<<"import sys; sys.exit(int(${dissimilarity} > 0.0022))"; then
echo "Image \"${a}\" is not close enough of a match to image \"${b}\", dissimilarity is ${dissimilarity}." >&2
return 1
fi
true
}
cd recordings/
error=0
for expected in expected*.png; do
actual=${expected/expected/actual}
diff=${expected/expected/diff}
assert_images_equal_enough ${actual} ${expected} ${diff} || error=1
done
rm -f actual*.* diff*.*
cat <<"EOF"
################################################################
## If this step FAILS you can get the expected images
## back in sync with reality by running:
##
## $ ./recordings/get_back_in_sync.sh
##
## More details on the topic can be found in CONTRIBUTING.md .
################################################################
EOF
exit ${error}
- name: 'Clean'
env:
MAKE: ${{ matrix.make }}
run: |-
set -x -o pipefail
${MAKE} clean
[[ "$(git ls-files -o | tee /dev/stderr | wc -l)" -eq 0 ]]