-
Notifications
You must be signed in to change notification settings - Fork 185
148 lines (138 loc) · 5.13 KB
/
build.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
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
# When a PR is updated, cancel the jobs from the previous version. Merges
# do not define head_ref, so use run_id to never cancel those jobs.
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
TinyCBOR:
timeout-minutes: 45
# Common environment variables
env:
HOMEBREW_NO_INSTALL_CLEANUP: 1
HOMEBREW_NO_ANALYTICS: 1
strategy:
# Always run all jobs in the matrix, even if one fails.
fail-fast: false
matrix:
os: [ ubuntu-latest ]
build_cfg: [
{ "name": "gcc-no-math",
"flags":
'{ "QMAKESPEC": "linux-gcc-no-math",
"EVAL": "export CXX=false && touch src/math.h src/float.h",
"CFLAGS": "-ffreestanding -DCBOR_NO_FLOATING_POINT -Os",
"LDFLAGS": "-Wl,--no-undefined",
"LDLIBS": ""
}',
},
{ "name": "gcc-freestanding",
"flags":
'{ "QMAKESPEC": "linux-gcc-freestanding",
"EVAL": "export CXX=false",
"CFLAGS": "-ffreestanding -Os",
"LDFLAGS": "-Wl,--no-undefined -lm"
}',
},
{ "name": "clang",
"flags":
'{ "QMAKESPEC": "linux-clang",
"EVAL": "export CC=clang && export CXX=clang++",
"CFLAGS": "-Oz",
"LDFLAGS": "-Wl,--no-undefined -lm",
"QMAKEFLAGS": "-config release",
"MAKEFLAGS": "-s",
"TESTARGS": "-silent"
}',
},
{ "name": "linux-g++",
"flags":
'{ "QMAKESPEC": "linux-g++",
"EVAL": "export CC=gcc && export CXX=g++",
"CFLAGS": "-Os",
"LDFLAGS": "-Wl,--no-undefined -lm",
"QMAKEFLAGS": "-config release",
"QT_NO_CPU_FEATURE": "rdrnd"
}'
}
]
include:
- os: macos-11
build_cfg: { "name": "clang",
"flags":
'{ "QMAKESPEC": "macx-clang",
"CFLAGS": "-Oz",
"QMAKEFLAGS": "-config debug",
"MAKEFLAGS": "-s",
"TESTARGS": "-silent",
"PATH": "/usr/local/opt/qt5/bin:$PATH"
}'
}
# Default job name is too long to be visible in the "Checks" tab.
name: ${{ matrix.os }}/${{ matrix.build_cfg.name }}
# The type of runner that the job will run on
runs-on: ${{ matrix.os }}
steps:
- name: Clone tinycbor
uses: actions/checkout@v4
- name: install Linux software
if: matrix.os == 'ubuntu-latest'
run: |
# Need a recent Valgrind, otherwise debug info cannot be read.
sudo snap install valgrind --classic
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
doxygen \
jq \
libc6-dbg \
libcjson-dev \
libfuntools-dev \
qtbase5-dev
- name: install macOS software
if: matrix.os == 'macos-11'
run: |
# Doxygen 1.9.7 is broken with ifdefs again, install 1.9.4 which works.
wget https://raw.githubusercontent.com/Homebrew/homebrew-core/41828ee36b96e35b63b2a4c8cfc2df2c3728944a/Formula/doxygen.rb
brew install doxygen.rb
rm doxygen.rb
brew install qt5 cjson
# Valgrind takes a long time to build, so put in a separate step
# to make it easy to disable.
- name: install macOS valgrind
if: matrix.os == 'macos-11'
run: |
# 3 cores on CI runners, so use make -j6 for homebrew.
export HOMEBREW_MAKE_JOBS=6
brew tap LouisBrunner/valgrind
brew install --HEAD LouisBrunner/valgrind/valgrind
- name: Execute tests
run: |
set -x
PATH=`echo /opt/qt*/bin`:$PATH
eval $(echo '${{ matrix.build_cfg.flags }}' | jq -r 'to_entries[] | "\(.key)=\"\(.value)\""')
eval "$EVAL"
# FIXME: remove -Wno-error-line below.
export CFLAGS="$CFLAGS -Wno-error=implicit-function-declaration"
make OUT=.config -s -f Makefile.configure configure | tee .config
make -k \
CFLAGS="$CFLAGS -march=native -g1 -Wall -Wextra -Werror" \
CPPFLAGS="-DNDEBUG -DCBOR_ENCODER_WRITER_CONTROL=-1 -DCBOR_PARSER_READER_CONTROL=-1" \
lib/libtinycbor.a
size lib/libtinycbor.a | tee sizes
make -s clean
make -k \
CFLAGS="$CFLAGS -O0 -g" \
LDFLAGS="$LDFLAGS" ${LDLIBS+LDLIBS="$LDLIBS"}
grep -q freestanding-pass .config || make \
QMAKEFLAGS="$QMAKEFLAGS QMAKE_CXX=$CXX" \
tests/Makefile
grep -q freestanding-pass .config || \
(cd tests && make TESTARGS=-silent check -k \
TESTRUNNER=`which valgrind 2>/dev/null`)
make -s clean
! [ $BUILD_DOCS ] || ./scripts/update-docs.sh