blob: 210b5be096bc93e261e346d5d50349ecd4d98b33 [file] [log] [blame]
Radek Krejcif4d97292020-11-30 16:38:32 +01001name: libyang CI
Michal Vasko8bdbf852021-04-14 16:19:17 +02002on:
Radek Krejcif4d97292020-11-30 16:38:32 +01003 push:
4 branches:
Michal Vasko0791e802021-05-27 10:29:14 +02005 - master
6 - devel
Radek Krejcif4d97292020-11-30 16:38:32 +01007 pull_request:
8 branches:
Michal Vasko0791e802021-05-27 10:29:14 +02009 - master
10 - devel
Radek Krejcif4d97292020-11-30 16:38:32 +010011
12jobs:
Jan Kundrátf202b122021-12-14 19:02:10 +010013 build-unix:
Radek Krejcif4d97292020-11-30 16:38:32 +010014 name: ${{ matrix.config.name }}
15 runs-on: ${{ matrix.config.os }}
16 strategy:
17 fail-fast: false
18 matrix:
19 config:
20 - {
Michal Vasko09bddf92022-11-09 12:04:11 +010021 name: "Release, gcc",
22 os: "ubuntu-22.04",
Radek Krejcif4d97292020-11-30 16:38:32 +010023 build-type: "Release",
24 cc: "gcc",
Michal Vaskocdffdab2021-06-23 14:00:10 +020025 options: "-DENABLE_TESTS=ON",
Radek Krejcif4d97292020-11-30 16:38:32 +010026 packager: "sudo apt-get",
Michal Vaskoc1372ae2022-11-09 12:13:45 +010027 # no expect because stdout seems to be redirected
28 packages: "libcmocka-dev shunit2",
Michal Vaskoa2177482021-05-28 10:29:41 +020029 snaps: "",
30 make-prepend: "",
31 make-target: ""
Radek Krejcif4d97292020-11-30 16:38:32 +010032 }
33 - {
Michal Vasko09bddf92022-11-09 12:04:11 +010034 name: "Release, clang",
35 os: "ubuntu-22.04",
Radek Krejcif4d97292020-11-30 16:38:32 +010036 build-type: "Release",
37 cc: "clang",
Michal Vaskocdffdab2021-06-23 14:00:10 +020038 options: "-DENABLE_TESTS=ON",
Radek Krejcif4d97292020-11-30 16:38:32 +010039 packager: "sudo apt-get",
Michal Vaskoc1372ae2022-11-09 12:13:45 +010040 packages: "libcmocka-dev shunit2",
Michal Vaskoa2177482021-05-28 10:29:41 +020041 snaps: "",
42 make-prepend: "",
43 make-target: ""
Radek Krejcif4d97292020-11-30 16:38:32 +010044 }
45 - {
Michal Vasko09bddf92022-11-09 12:04:11 +010046 name: "Debug, gcc",
47 os: "ubuntu-22.04",
Radek Krejcif4d97292020-11-30 16:38:32 +010048 build-type: "Debug",
49 cc: "gcc",
50 options: "",
51 packager: "sudo apt-get",
Michal Vaskoc1372ae2022-11-09 12:13:45 +010052 packages: "libcmocka-dev valgrind shunit2",
Michal Vaskoa2177482021-05-28 10:29:41 +020053 snaps: "",
54 make-prepend: "",
55 make-target: ""
Radek Krejcif4d97292020-11-30 16:38:32 +010056 }
57 - {
Michal Vasko09bddf92022-11-09 12:04:11 +010058 name: "Debug, clang",
59 os: "ubuntu-22.04",
Radek Krejcif4d97292020-11-30 16:38:32 +010060 build-type: "Debug",
61 cc: "clang",
62 options: "",
63 packager: "sudo apt-get",
Michal Vasko09bddf92022-11-09 12:04:11 +010064 # no valgrind because it does not support DWARF5 yet generated by clang 14
Michal Vaskoc1372ae2022-11-09 12:13:45 +010065 packages: "libcmocka-dev shunit2",
Michal Vaskoa2177482021-05-28 10:29:41 +020066 snaps: "",
67 make-prepend: "",
68 make-target: ""
Radek Krejcif4d97292020-11-30 16:38:32 +010069 }
70 - {
Michal Vaskodca63462022-08-17 12:03:34 +020071 name: "Release, macOS 11, clang",
72 os: "macos-11",
Radek Krejcif4d97292020-11-30 16:38:32 +010073 build-type: "Release",
74 cc: "clang",
Michal Vasko682d5432022-08-17 12:31:55 +020075 options: "-DENABLE_TESTS=ON -DPATH_EXPECT=",
Radek Krejcif4d97292020-11-30 16:38:32 +010076 packager: "brew",
Michal Vasko682d5432022-08-17 12:31:55 +020077 packages: "cmocka shunit2",
Michal Vaskoa2177482021-05-28 10:29:41 +020078 snaps: "",
79 make-prepend: "",
80 make-target: ""
Radek Krejcif4d97292020-11-30 16:38:32 +010081 }
82 - {
Michal Vasko09bddf92022-11-09 12:04:11 +010083 name: "ASAN and UBSAN",
Jan Kundrátda345692022-07-16 13:21:23 +020084 os: "ubuntu-22.04",
Radek Krejcif4d97292020-11-30 16:38:32 +010085 build-type: "Debug",
Michal Vasko09bddf92022-11-09 12:04:11 +010086 cc: "clang",
Michal Vaskocdffdab2021-06-23 14:00:10 +020087 options: "-DCMAKE_C_FLAGS=-fsanitize=address,undefined -DENABLE_TESTS=ON -DENABLE_VALGRIND_TESTS=OFF",
Radek Krejcif4d97292020-11-30 16:38:32 +010088 packager: "sudo apt-get",
Michal Vaskoa2177482021-05-28 10:29:41 +020089 packages: "libcmocka-dev",
90 snaps: "",
91 make-prepend: "",
92 make-target: ""
93 }
94 - {
95 name: "ABI Check",
Michal Vasko09bddf92022-11-09 12:04:11 +010096 os: "ubuntu-22.04",
Michal Vaskoa2177482021-05-28 10:29:41 +020097 build-type: "ABICheck",
98 cc: "gcc",
99 options: "",
Michal Vaskob5043682021-05-28 10:33:24 +0200100 packager: "sudo apt-get",
Michal Vaskoa2177482021-05-28 10:29:41 +0200101 packages: "libcmocka-dev abi-dumper abi-compliance-checker",
102 snaps: "core universal-ctags",
103 make-prepend: "",
104 make-target: "abi-check"
105 }
Radek Krejcif4d97292020-11-30 16:38:32 +0100106
107 steps:
Michal Vasko09bddf92022-11-09 12:04:11 +0100108 - uses: actions/checkout@v3
Radek Krejcif4d97292020-11-30 16:38:32 +0100109
Michal Vaskoa2177482021-05-28 10:29:41 +0200110 - name: Deps-packages
111 shell: bash
112 run: |
113 ${{ matrix.config.packager }} update
114 if ${{ matrix.config.packages != '' }}
115 then ${{ matrix.config.packager }} install ${{ matrix.config.packages }}
116 fi
117 if ${{ matrix.config.snaps != '' }}
118 then sudo snap install ${{ matrix.config.snaps }}
119 fi
120
121 - name: Deps-uncrustify
Michal Vasko8bdbf852021-04-14 16:19:17 +0200122 shell: bash
123 working-directory: ${{ github.workspace }}
124 run: |
Michal Vasko26bbb272022-08-02 14:54:33 +0200125 git clone --branch uncrustify-0.75.1 https://github.com/uncrustify/uncrustify
Michal Vasko8bdbf852021-04-14 16:19:17 +0200126 cd uncrustify
127 mkdir build
128 cd build
129 CC=${{ matrix.config.cc }} cmake ..
130 make
131 sudo make install
Michal Vasko09bddf92022-11-09 12:04:11 +0100132 if: ${{ matrix.config.name == 'Debug, gcc' }}
Michal Vasko8bdbf852021-04-14 16:19:17 +0200133
Radek Krejcif4d97292020-11-30 16:38:32 +0100134 - name: Configure
135 shell: bash
136 working-directory: ${{ github.workspace }}
137 run: |
138 mkdir build
139 cd build
140 CC=${{ matrix.config.cc }} cmake -DCMAKE_BUILD_TYPE=${{ matrix.config.build-type }} ${{ matrix.config.options }} ..
141
142 - name: Build
143 shell: bash
144 working-directory: ${{ github.workspace }}/build
Michal Vaskoa2177482021-05-28 10:29:41 +0200145 run: |
146 export LC_ALL=C.UTF-8
147 export PATH=/snap/bin:${{ github.workspace }}/coverity-tools/bin:$PATH
148 ${{ matrix.config.make-prepend }} make ${{ matrix.config.make-target }}
Radek Krejcif4d97292020-11-30 16:38:32 +0100149
150 - name: Test
151 shell: bash
152 working-directory: ${{ github.workspace }}/build
153 run: ctest --output-on-failure
Jan Kundrátf202b122021-12-14 19:02:10 +0100154
155 build-windows:
156 name: ${{ matrix.name }}
157 runs-on: ${{ matrix.os }}
158 strategy:
159 fail-fast: false
160 matrix:
161 include:
Jan Kundráta3b1c6d2022-07-07 21:53:34 +0200162 - name: "Windows 2022 MSVC 16 LF"
163 os: windows-2022
164 triplet: x64-windows
165 build_type: Release
166 generators: "Visual Studio 17 2022"
167 autocrlf: input
168 eol: lf
169
170 - name: "Windows 2022 MSVC 16 no autoCRLF"
Jan Kundrátf202b122021-12-14 19:02:10 +0100171 os: windows-2022
172 triplet: x64-windows
173 build_type: Release
174 generators: "Visual Studio 17 2022"
175
176 steps:
177 - name: Unix line endings in git
Jan Kundráta3b1c6d2022-07-07 21:53:34 +0200178 if: matrix.autocrlf
Jan Kundrátf202b122021-12-14 19:02:10 +0100179 run: |
Jan Kundráta3b1c6d2022-07-07 21:53:34 +0200180 git config --global core.autocrlf ${{ matrix.autocrlf }}
181
182 - name: Unix line endings in git
183 if: matrix.eol
184 run: |
185 git config --global core.eol ${{ matrix.eol }}
Jan Kundrátf202b122021-12-14 19:02:10 +0100186
Michal Vasko09bddf92022-11-09 12:04:11 +0100187 - uses: actions/checkout@v3
Jan Kundrátf202b122021-12-14 19:02:10 +0100188
189 - name: Get number of CPU cores
190 id: cpu-cores
Michal Vasko09bddf92022-11-09 12:04:11 +0100191 uses: SimenB/github-actions-cpu-cores@v1
Jan Kundrátf202b122021-12-14 19:02:10 +0100192
193 - name: Install Windows dependencies
194 run: vcpkg install --triplet=${{ matrix.triplet }} pcre2 pthreads dirent dlfcn-win32 cmocka getopt
195
196 - name: Configure
197 shell: bash
198 run: |
199 cmake \
200 -S '${{ github.workspace }}/' \
201 -B '${{ github.workspace }}/'../build \
202 -G '${{ matrix.generators }}' \
203 -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
204 -DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }} \
205 -DCMAKE_TOOLCHAIN_FILE=${VCPKG_INSTALLATION_ROOT//\\//}/scripts/buildsystems/vcpkg.cmake \
206 -DENABLE_TESTS=ON \
207 '-DCMAKE_INSTALL_PREFIX:PATH=${{ github.workspace }}'/../target
208
209 - name: Build
210 working-directory: '${{ github.workspace }}/../build'
211 run: cmake --build . -j${{ steps.cpu-cores.outputs.count }} --config ${{ matrix.build_type }}
212
213 - name: Test
214 working-directory: '${{ github.workspace }}/../build'
215 run: ctest --output-on-failure -j${{ steps.cpu-cores.outputs.count }} --build-config ${{ matrix.build_type }}
216
217 - name: Install
218 working-directory: '${{ github.workspace }}/../build'
219 run: cmake --install . --strip