Skip to content

Commit 4dcad26

Browse files
pjonssonthiagomacieira
authored andcommitted
CI: add Github CI
1 parent c8e12e9 commit 4dcad26

File tree

1 file changed

+148
-0
lines changed

1 file changed

+148
-0
lines changed

.github/workflows/build.yml

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
10+
# When a PR is updated, cancel the jobs from the previous version. Merges
11+
# do not define head_ref, so use run_id to never cancel those jobs.
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
TinyCBOR:
18+
timeout-minutes: 45
19+
# Common environment variables
20+
env:
21+
HOMEBREW_NO_INSTALL_CLEANUP: 1
22+
HOMEBREW_NO_ANALYTICS: 1
23+
24+
strategy:
25+
# Always run all jobs in the matrix, even if one fails.
26+
fail-fast: false
27+
matrix:
28+
os: [ ubuntu-latest ]
29+
build_cfg: [
30+
{ "name": "gcc-no-math",
31+
"flags":
32+
'{ "QMAKESPEC": "linux-gcc-no-math",
33+
"EVAL": "export CXX=false && touch src/math.h src/float.h",
34+
"CFLAGS": "-ffreestanding -DCBOR_NO_FLOATING_POINT -Os",
35+
"LDFLAGS": "-Wl,--no-undefined",
36+
"LDLIBS": ""
37+
}',
38+
},
39+
{ "name": "gcc-freestanding",
40+
"flags":
41+
'{ "QMAKESPEC": "linux-gcc-freestanding",
42+
"EVAL": "export CXX=false",
43+
"CFLAGS": "-ffreestanding -Os",
44+
"LDFLAGS": "-Wl,--no-undefined -lm"
45+
}',
46+
},
47+
{ "name": "clang",
48+
"flags":
49+
'{ "QMAKESPEC": "linux-clang",
50+
"EVAL": "export CC=clang && export CXX=clang++",
51+
"CFLAGS": "-Oz",
52+
"LDFLAGS": "-Wl,--no-undefined -lm",
53+
"QMAKEFLAGS": "-config release",
54+
"MAKEFLAGS": "-s",
55+
"TESTARGS": "-silent"
56+
}',
57+
},
58+
{ "name": "linux-g++",
59+
"flags":
60+
'{ "QMAKESPEC": "linux-g++",
61+
"EVAL": "export CC=gcc && export CXX=g++",
62+
"CFLAGS": "-Os",
63+
"LDFLAGS": "-Wl,--no-undefined -lm",
64+
"QMAKEFLAGS": "-config release",
65+
"QT_NO_CPU_FEATURE": "rdrnd"
66+
}'
67+
}
68+
]
69+
include:
70+
- os: macos-11
71+
build_cfg: { "name": "clang",
72+
"flags":
73+
'{ "QMAKESPEC": "macx-clang",
74+
"CFLAGS": "-Oz",
75+
"QMAKEFLAGS": "-config debug",
76+
"MAKEFLAGS": "-s",
77+
"TESTARGS": "-silent",
78+
"PATH": "/usr/local/opt/qt5/bin:$PATH"
79+
}'
80+
}
81+
82+
# Default job name is too long to be visible in the "Checks" tab.
83+
name: ${{ matrix.os }}/${{ matrix.build_cfg.name }}
84+
# The type of runner that the job will run on
85+
runs-on: ${{ matrix.os }}
86+
steps:
87+
- name: Clone tinycbor
88+
uses: actions/checkout@v4
89+
90+
- name: install Linux software
91+
if: matrix.os == 'ubuntu-latest'
92+
run: |
93+
# Need a recent Valgrind, otherwise debug info cannot be read.
94+
sudo snap install valgrind --classic
95+
sudo apt-get update
96+
sudo apt-get install -y --no-install-recommends \
97+
doxygen \
98+
jq \
99+
libc6-dbg \
100+
libcjson-dev \
101+
libfuntools-dev \
102+
qtbase5-dev
103+
104+
- name: install macOS software
105+
if: matrix.os == 'macos-11'
106+
run: |
107+
# Doxygen 1.9.7 is broken with ifdefs again, install 1.9.4 which works.
108+
wget https://raw.githubusercontent.com/Homebrew/homebrew-core/41828ee36b96e35b63b2a4c8cfc2df2c3728944a/Formula/doxygen.rb
109+
brew install doxygen.rb
110+
rm doxygen.rb
111+
brew install qt5 cjson
112+
113+
# Valgrind takes a long time to build, so put in a separate step
114+
# to make it easy to disable.
115+
- name: install macOS valgrind
116+
if: matrix.os == 'macos-11'
117+
run: |
118+
# 3 cores on CI runners, so use make -j6 for homebrew.
119+
export HOMEBREW_MAKE_JOBS=6
120+
brew tap LouisBrunner/valgrind
121+
brew install --HEAD LouisBrunner/valgrind/valgrind
122+
123+
- name: Execute tests
124+
run: |
125+
set -x
126+
PATH=`echo /opt/qt*/bin`:$PATH
127+
eval $(echo '${{ matrix.build_cfg.flags }}' | jq -r 'to_entries[] | "\(.key)=\"\(.value)\""')
128+
eval "$EVAL"
129+
# FIXME: remove -Wno-error-line below.
130+
export CFLAGS="$CFLAGS -Wno-error=implicit-function-declaration"
131+
make OUT=.config -s -f Makefile.configure configure | tee .config
132+
make -k \
133+
CFLAGS="$CFLAGS -march=native -g1 -Wall -Wextra -Werror" \
134+
CPPFLAGS="-DNDEBUG -DCBOR_ENCODER_WRITER_CONTROL=-1 -DCBOR_PARSER_READER_CONTROL=-1" \
135+
lib/libtinycbor.a
136+
size lib/libtinycbor.a | tee sizes
137+
make -s clean
138+
make -k \
139+
CFLAGS="$CFLAGS -O0 -g" \
140+
LDFLAGS="$LDFLAGS" ${LDLIBS+LDLIBS="$LDLIBS"}
141+
grep -q freestanding-pass .config || make \
142+
QMAKEFLAGS="$QMAKEFLAGS QMAKE_CXX=$CXX" \
143+
tests/Makefile
144+
grep -q freestanding-pass .config || \
145+
(cd tests && make TESTARGS=-silent check -k \
146+
TESTRUNNER=`which valgrind 2>/dev/null`)
147+
make -s clean
148+
! [ $BUILD_DOCS ] || ./scripts/update-docs.sh

0 commit comments

Comments
 (0)