blob: c0015c79668ff343230c8b5aefed2dcee0c25fd4 [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: "",
Michal Vaskocbb30612024-03-18 10:34:16 +010030 build-cmd: "make"
Radek Krejcif4d97292020-11-30 16:38:32 +010031 }
32 - {
Michal Vasko09bddf92022-11-09 12:04:11 +010033 name: "Release, clang",
34 os: "ubuntu-22.04",
Radek Krejcif4d97292020-11-30 16:38:32 +010035 build-type: "Release",
36 cc: "clang",
Michal Vaskocdffdab2021-06-23 14:00:10 +020037 options: "-DENABLE_TESTS=ON",
Radek Krejcif4d97292020-11-30 16:38:32 +010038 packager: "sudo apt-get",
Michal Vaskoc1372ae2022-11-09 12:13:45 +010039 packages: "libcmocka-dev shunit2",
Michal Vaskoa2177482021-05-28 10:29:41 +020040 snaps: "",
Michal Vaskocbb30612024-03-18 10:34:16 +010041 build-cmd: "make"
Radek Krejcif4d97292020-11-30 16:38:32 +010042 }
43 - {
Michal Vasko09bddf92022-11-09 12:04:11 +010044 name: "Debug, gcc",
45 os: "ubuntu-22.04",
Radek Krejcif4d97292020-11-30 16:38:32 +010046 build-type: "Debug",
47 cc: "gcc",
48 options: "",
49 packager: "sudo apt-get",
Michal Vaskoc1372ae2022-11-09 12:13:45 +010050 packages: "libcmocka-dev valgrind shunit2",
Michal Vaskoa2177482021-05-28 10:29:41 +020051 snaps: "",
Michal Vaskocbb30612024-03-18 10:34:16 +010052 build-cmd: "make"
Radek Krejcif4d97292020-11-30 16:38:32 +010053 }
54 - {
Michal Vasko09bddf92022-11-09 12:04:11 +010055 name: "Debug, clang",
56 os: "ubuntu-22.04",
Radek Krejcif4d97292020-11-30 16:38:32 +010057 build-type: "Debug",
58 cc: "clang",
59 options: "",
60 packager: "sudo apt-get",
Michal Vasko09bddf92022-11-09 12:04:11 +010061 # no valgrind because it does not support DWARF5 yet generated by clang 14
Michal Vaskoc1372ae2022-11-09 12:13:45 +010062 packages: "libcmocka-dev shunit2",
Michal Vaskoa2177482021-05-28 10:29:41 +020063 snaps: "",
Michal Vaskocbb30612024-03-18 10:34:16 +010064 build-cmd: "make"
Radek Krejcif4d97292020-11-30 16:38:32 +010065 }
66 - {
Michal Vaskodca63462022-08-17 12:03:34 +020067 name: "Release, macOS 11, clang",
68 os: "macos-11",
Radek Krejcif4d97292020-11-30 16:38:32 +010069 build-type: "Release",
70 cc: "clang",
Michal Vasko682d5432022-08-17 12:31:55 +020071 options: "-DENABLE_TESTS=ON -DPATH_EXPECT=",
Radek Krejcif4d97292020-11-30 16:38:32 +010072 packager: "brew",
Michal Vasko682d5432022-08-17 12:31:55 +020073 packages: "cmocka shunit2",
Michal Vaskoa2177482021-05-28 10:29:41 +020074 snaps: "",
Michal Vaskocbb30612024-03-18 10:34:16 +010075 build-cmd: "make"
Radek Krejcif4d97292020-11-30 16:38:32 +010076 }
77 - {
Michal Vasko09bddf92022-11-09 12:04:11 +010078 name: "ASAN and UBSAN",
Jan Kundrátda345692022-07-16 13:21:23 +020079 os: "ubuntu-22.04",
Radek Krejcif4d97292020-11-30 16:38:32 +010080 build-type: "Debug",
Michal Vasko09bddf92022-11-09 12:04:11 +010081 cc: "clang",
Michal Vaskocdffdab2021-06-23 14:00:10 +020082 options: "-DCMAKE_C_FLAGS=-fsanitize=address,undefined -DENABLE_TESTS=ON -DENABLE_VALGRIND_TESTS=OFF",
Radek Krejcif4d97292020-11-30 16:38:32 +010083 packager: "sudo apt-get",
Michal Vaskoa2177482021-05-28 10:29:41 +020084 packages: "libcmocka-dev",
85 snaps: "",
Michal Vaskocbb30612024-03-18 10:34:16 +010086 build-cmd: "make"
Michal Vaskoa2177482021-05-28 10:29:41 +020087 }
88 - {
89 name: "ABI Check",
Michal Vasko09bddf92022-11-09 12:04:11 +010090 os: "ubuntu-22.04",
Michal Vaskoa2177482021-05-28 10:29:41 +020091 build-type: "ABICheck",
92 cc: "gcc",
93 options: "",
Michal Vaskob5043682021-05-28 10:33:24 +020094 packager: "sudo apt-get",
Michal Vaskoa2177482021-05-28 10:29:41 +020095 packages: "libcmocka-dev abi-dumper abi-compliance-checker",
96 snaps: "core universal-ctags",
Michal Vaskocbb30612024-03-18 10:34:16 +010097 build-cmd: "make abi-check"
98 }
99 - {
100 name: "DEB Package",
101 os: "ubuntu-22.04",
102 build-type: "Release",
103 cc: "gcc",
104 options: "",
105 packager: "sudo apt-get",
106 packages: "python3-pip",
107 snaps: "",
Michal Vaskod69f7382024-03-18 11:06:03 +0100108 build-cmd: ""
Michal Vaskoa2177482021-05-28 10:29:41 +0200109 }
Radek Krejcif4d97292020-11-30 16:38:32 +0100110
111 steps:
Michal Vaskocbb30612024-03-18 10:34:16 +0100112 - uses: actions/checkout@main
Radek Krejcif4d97292020-11-30 16:38:32 +0100113
Michal Vaskoa2177482021-05-28 10:29:41 +0200114 - name: Deps-packages
115 shell: bash
116 run: |
117 ${{ matrix.config.packager }} update
118 if ${{ matrix.config.packages != '' }}
119 then ${{ matrix.config.packager }} install ${{ matrix.config.packages }}
120 fi
121 if ${{ matrix.config.snaps != '' }}
122 then sudo snap install ${{ matrix.config.snaps }}
123 fi
124
125 - name: Deps-uncrustify
Michal Vasko8bdbf852021-04-14 16:19:17 +0200126 shell: bash
127 working-directory: ${{ github.workspace }}
128 run: |
Michal Vasko84bf6f42023-05-19 11:09:48 +0200129 git clone --branch uncrustify-0.77.1 https://github.com/uncrustify/uncrustify
Michal Vasko8bdbf852021-04-14 16:19:17 +0200130 cd uncrustify
131 mkdir build
132 cd build
133 CC=${{ matrix.config.cc }} cmake ..
134 make
135 sudo make install
Michal Vasko09bddf92022-11-09 12:04:11 +0100136 if: ${{ matrix.config.name == 'Debug, gcc' }}
Michal Vasko8bdbf852021-04-14 16:19:17 +0200137
Michal Vaskod69f7382024-03-18 11:06:03 +0100138 - name: Build-and-install-package
139 shell: bash
Michal Vaskod187d9c2024-03-18 11:24:49 +0100140 working-directory: ${{ github.workspace }}
Michal Vaskod69f7382024-03-18 11:06:03 +0100141 run: |
142 pip install apkg
143 apkg system-setup
Michal Vaskod187d9c2024-03-18 11:24:49 +0100144 echo "git msg"
145 git log --oneline -n1
146 echo "git msg2"
Michal Vaskod69f7382024-03-18 11:06:03 +0100147 apkg build
148 apkg install
149 if: ${{ matrix.config.name == 'DEB Package' }}
150
Radek Krejcif4d97292020-11-30 16:38:32 +0100151 - name: Configure
152 shell: bash
153 working-directory: ${{ github.workspace }}
154 run: |
155 mkdir build
156 cd build
157 CC=${{ matrix.config.cc }} cmake -DCMAKE_BUILD_TYPE=${{ matrix.config.build-type }} ${{ matrix.config.options }} ..
Michal Vaskocbb30612024-03-18 10:34:16 +0100158 if: ${{ matrix.config.name != 'DEB Package' }}
Radek Krejcif4d97292020-11-30 16:38:32 +0100159
160 - name: Build
161 shell: bash
162 working-directory: ${{ github.workspace }}/build
Michal Vaskoa2177482021-05-28 10:29:41 +0200163 run: |
164 export LC_ALL=C.UTF-8
165 export PATH=/snap/bin:${{ github.workspace }}/coverity-tools/bin:$PATH
Michal Vaskocbb30612024-03-18 10:34:16 +0100166 ${{ matrix.config.build-cmd }}
Michal Vaskod69f7382024-03-18 11:06:03 +0100167 if: ${{ matrix.config.name != 'DEB Package' }}
Radek Krejcif4d97292020-11-30 16:38:32 +0100168
169 - name: Test
170 shell: bash
171 working-directory: ${{ github.workspace }}/build
172 run: ctest --output-on-failure
Michal Vaskod69f7382024-03-18 11:06:03 +0100173 if: ${{ matrix.config.name != 'DEB Package' }}
Jan Kundrátf202b122021-12-14 19:02:10 +0100174
175 build-windows:
176 name: ${{ matrix.name }}
177 runs-on: ${{ matrix.os }}
178 strategy:
179 fail-fast: false
180 matrix:
181 include:
Jan Kundráta3b1c6d2022-07-07 21:53:34 +0200182 - name: "Windows 2022 MSVC 16 LF"
183 os: windows-2022
184 triplet: x64-windows
185 build_type: Release
186 generators: "Visual Studio 17 2022"
187 autocrlf: input
188 eol: lf
189
190 - name: "Windows 2022 MSVC 16 no autoCRLF"
Jan Kundrátf202b122021-12-14 19:02:10 +0100191 os: windows-2022
192 triplet: x64-windows
193 build_type: Release
194 generators: "Visual Studio 17 2022"
195
196 steps:
197 - name: Unix line endings in git
Jan Kundráta3b1c6d2022-07-07 21:53:34 +0200198 if: matrix.autocrlf
Jan Kundrátf202b122021-12-14 19:02:10 +0100199 run: |
Jan Kundráta3b1c6d2022-07-07 21:53:34 +0200200 git config --global core.autocrlf ${{ matrix.autocrlf }}
201
202 - name: Unix line endings in git
203 if: matrix.eol
204 run: |
205 git config --global core.eol ${{ matrix.eol }}
Jan Kundrátf202b122021-12-14 19:02:10 +0100206
Michal Vasko99697d72024-03-18 11:11:32 +0100207 - uses: actions/checkout@main
Jan Kundrátf202b122021-12-14 19:02:10 +0100208
209 - name: Get number of CPU cores
210 id: cpu-cores
Michal Vasko09bddf92022-11-09 12:04:11 +0100211 uses: SimenB/github-actions-cpu-cores@v1
Jan Kundrátf202b122021-12-14 19:02:10 +0100212
213 - name: Install Windows dependencies
214 run: vcpkg install --triplet=${{ matrix.triplet }} pcre2 pthreads dirent dlfcn-win32 cmocka getopt
215
216 - name: Configure
217 shell: bash
218 run: |
219 cmake \
220 -S '${{ github.workspace }}/' \
221 -B '${{ github.workspace }}/'../build \
222 -G '${{ matrix.generators }}' \
223 -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
224 -DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }} \
225 -DCMAKE_TOOLCHAIN_FILE=${VCPKG_INSTALLATION_ROOT//\\//}/scripts/buildsystems/vcpkg.cmake \
226 -DENABLE_TESTS=ON \
227 '-DCMAKE_INSTALL_PREFIX:PATH=${{ github.workspace }}'/../target
228
229 - name: Build
230 working-directory: '${{ github.workspace }}/../build'
231 run: cmake --build . -j${{ steps.cpu-cores.outputs.count }} --config ${{ matrix.build_type }}
232
233 - name: Test
234 working-directory: '${{ github.workspace }}/../build'
235 run: ctest --output-on-failure -j${{ steps.cpu-cores.outputs.count }} --build-config ${{ matrix.build_type }}
236
237 - name: Install
238 working-directory: '${{ github.workspace }}/../build'
239 run: cmake --install . --strip