blob: 1c58058a62d8c1fb3a6d498767ee6d732ab6873f [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 Vasko09bddf92022-11-09 12:04:11 +010027 packages: "libcmocka-dev shunit2 expect",
Michal Vaskoa2177482021-05-28 10:29:41 +020028 snaps: "",
29 make-prepend: "",
30 make-target: ""
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 Vasko09bddf92022-11-09 12:04:11 +010039 packages: "libcmocka-dev shunit2 expect",
Michal Vaskoa2177482021-05-28 10:29:41 +020040 snaps: "",
41 make-prepend: "",
42 make-target: ""
Radek Krejcif4d97292020-11-30 16:38:32 +010043 }
44 - {
Michal Vasko09bddf92022-11-09 12:04:11 +010045 name: "Debug, gcc",
46 os: "ubuntu-22.04",
Radek Krejcif4d97292020-11-30 16:38:32 +010047 build-type: "Debug",
48 cc: "gcc",
49 options: "",
50 packager: "sudo apt-get",
Michal Vasko09bddf92022-11-09 12:04:11 +010051 packages: "libcmocka-dev valgrind shunit2 expect",
Michal Vaskoa2177482021-05-28 10:29:41 +020052 snaps: "",
53 make-prepend: "",
54 make-target: ""
Radek Krejcif4d97292020-11-30 16:38:32 +010055 }
56 - {
Michal Vasko09bddf92022-11-09 12:04:11 +010057 name: "Debug, clang",
58 os: "ubuntu-22.04",
Radek Krejcif4d97292020-11-30 16:38:32 +010059 build-type: "Debug",
60 cc: "clang",
61 options: "",
62 packager: "sudo apt-get",
Michal Vasko09bddf92022-11-09 12:04:11 +010063 # no valgrind because it does not support DWARF5 yet generated by clang 14
64 packages: "libcmocka-dev shunit2 expect",
Michal Vaskoa2177482021-05-28 10:29:41 +020065 snaps: "",
66 make-prepend: "",
67 make-target: ""
Radek Krejcif4d97292020-11-30 16:38:32 +010068 }
69 - {
Michal Vaskodca63462022-08-17 12:03:34 +020070 name: "Release, macOS 11, clang",
71 os: "macos-11",
Radek Krejcif4d97292020-11-30 16:38:32 +010072 build-type: "Release",
73 cc: "clang",
Michal Vasko682d5432022-08-17 12:31:55 +020074 options: "-DENABLE_TESTS=ON -DPATH_EXPECT=",
Radek Krejcif4d97292020-11-30 16:38:32 +010075 packager: "brew",
Michal Vasko682d5432022-08-17 12:31:55 +020076 packages: "cmocka shunit2",
Michal Vaskoa2177482021-05-28 10:29:41 +020077 snaps: "",
78 make-prepend: "",
79 make-target: ""
Radek Krejcif4d97292020-11-30 16:38:32 +010080 }
81 - {
Michal Vasko09bddf92022-11-09 12:04:11 +010082 name: "ASAN and UBSAN",
Jan Kundrátda345692022-07-16 13:21:23 +020083 os: "ubuntu-22.04",
Radek Krejcif4d97292020-11-30 16:38:32 +010084 build-type: "Debug",
Michal Vasko09bddf92022-11-09 12:04:11 +010085 cc: "clang",
Michal Vaskocdffdab2021-06-23 14:00:10 +020086 options: "-DCMAKE_C_FLAGS=-fsanitize=address,undefined -DENABLE_TESTS=ON -DENABLE_VALGRIND_TESTS=OFF",
Radek Krejcif4d97292020-11-30 16:38:32 +010087 packager: "sudo apt-get",
Michal Vaskoa2177482021-05-28 10:29:41 +020088 packages: "libcmocka-dev",
89 snaps: "",
90 make-prepend: "",
91 make-target: ""
92 }
93 - {
94 name: "ABI Check",
Michal Vasko09bddf92022-11-09 12:04:11 +010095 os: "ubuntu-22.04",
Michal Vaskoa2177482021-05-28 10:29:41 +020096 build-type: "ABICheck",
97 cc: "gcc",
98 options: "",
Michal Vaskob5043682021-05-28 10:33:24 +020099 packager: "sudo apt-get",
Michal Vaskoa2177482021-05-28 10:29:41 +0200100 packages: "libcmocka-dev abi-dumper abi-compliance-checker",
101 snaps: "core universal-ctags",
102 make-prepend: "",
103 make-target: "abi-check"
104 }
Radek Krejcif4d97292020-11-30 16:38:32 +0100105
106 steps:
Michal Vasko09bddf92022-11-09 12:04:11 +0100107 - uses: actions/checkout@v3
Radek Krejcif4d97292020-11-30 16:38:32 +0100108
Michal Vaskoa2177482021-05-28 10:29:41 +0200109 - name: Deps-packages
110 shell: bash
111 run: |
112 ${{ matrix.config.packager }} update
113 if ${{ matrix.config.packages != '' }}
114 then ${{ matrix.config.packager }} install ${{ matrix.config.packages }}
115 fi
116 if ${{ matrix.config.snaps != '' }}
117 then sudo snap install ${{ matrix.config.snaps }}
118 fi
119
120 - name: Deps-uncrustify
Michal Vasko8bdbf852021-04-14 16:19:17 +0200121 shell: bash
122 working-directory: ${{ github.workspace }}
123 run: |
Michal Vasko26bbb272022-08-02 14:54:33 +0200124 git clone --branch uncrustify-0.75.1 https://github.com/uncrustify/uncrustify
Michal Vasko8bdbf852021-04-14 16:19:17 +0200125 cd uncrustify
126 mkdir build
127 cd build
128 CC=${{ matrix.config.cc }} cmake ..
129 make
130 sudo make install
Michal Vasko09bddf92022-11-09 12:04:11 +0100131 if: ${{ matrix.config.name == 'Debug, gcc' }}
Michal Vasko8bdbf852021-04-14 16:19:17 +0200132
Radek Krejcif4d97292020-11-30 16:38:32 +0100133 - name: Configure
134 shell: bash
135 working-directory: ${{ github.workspace }}
136 run: |
137 mkdir build
138 cd build
139 CC=${{ matrix.config.cc }} cmake -DCMAKE_BUILD_TYPE=${{ matrix.config.build-type }} ${{ matrix.config.options }} ..
140
141 - name: Build
142 shell: bash
143 working-directory: ${{ github.workspace }}/build
Michal Vaskoa2177482021-05-28 10:29:41 +0200144 run: |
145 export LC_ALL=C.UTF-8
146 export PATH=/snap/bin:${{ github.workspace }}/coverity-tools/bin:$PATH
147 ${{ matrix.config.make-prepend }} make ${{ matrix.config.make-target }}
Radek Krejcif4d97292020-11-30 16:38:32 +0100148
149 - name: Test
150 shell: bash
151 working-directory: ${{ github.workspace }}/build
152 run: ctest --output-on-failure
Jan Kundrátf202b122021-12-14 19:02:10 +0100153
154 build-windows:
155 name: ${{ matrix.name }}
156 runs-on: ${{ matrix.os }}
157 strategy:
158 fail-fast: false
159 matrix:
160 include:
Jan Kundráta3b1c6d2022-07-07 21:53:34 +0200161 - name: "Windows 2022 MSVC 16 LF"
162 os: windows-2022
163 triplet: x64-windows
164 build_type: Release
165 generators: "Visual Studio 17 2022"
166 autocrlf: input
167 eol: lf
168
169 - name: "Windows 2022 MSVC 16 no autoCRLF"
Jan Kundrátf202b122021-12-14 19:02:10 +0100170 os: windows-2022
171 triplet: x64-windows
172 build_type: Release
173 generators: "Visual Studio 17 2022"
174
175 steps:
176 - name: Unix line endings in git
Jan Kundráta3b1c6d2022-07-07 21:53:34 +0200177 if: matrix.autocrlf
Jan Kundrátf202b122021-12-14 19:02:10 +0100178 run: |
Jan Kundráta3b1c6d2022-07-07 21:53:34 +0200179 git config --global core.autocrlf ${{ matrix.autocrlf }}
180
181 - name: Unix line endings in git
182 if: matrix.eol
183 run: |
184 git config --global core.eol ${{ matrix.eol }}
Jan Kundrátf202b122021-12-14 19:02:10 +0100185
Michal Vasko09bddf92022-11-09 12:04:11 +0100186 - uses: actions/checkout@v3
Jan Kundrátf202b122021-12-14 19:02:10 +0100187
188 - name: Get number of CPU cores
189 id: cpu-cores
Michal Vasko09bddf92022-11-09 12:04:11 +0100190 uses: SimenB/github-actions-cpu-cores@v1
Jan Kundrátf202b122021-12-14 19:02:10 +0100191
192 - name: Install Windows dependencies
193 run: vcpkg install --triplet=${{ matrix.triplet }} pcre2 pthreads dirent dlfcn-win32 cmocka getopt
194
195 - name: Configure
196 shell: bash
197 run: |
198 cmake \
199 -S '${{ github.workspace }}/' \
200 -B '${{ github.workspace }}/'../build \
201 -G '${{ matrix.generators }}' \
202 -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
203 -DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }} \
204 -DCMAKE_TOOLCHAIN_FILE=${VCPKG_INSTALLATION_ROOT//\\//}/scripts/buildsystems/vcpkg.cmake \
205 -DENABLE_TESTS=ON \
206 '-DCMAKE_INSTALL_PREFIX:PATH=${{ github.workspace }}'/../target
207
208 - name: Build
209 working-directory: '${{ github.workspace }}/../build'
210 run: cmake --build . -j${{ steps.cpu-cores.outputs.count }} --config ${{ matrix.build_type }}
211
212 - name: Test
213 working-directory: '${{ github.workspace }}/../build'
214 run: ctest --output-on-failure -j${{ steps.cpu-cores.outputs.count }} --build-config ${{ matrix.build_type }}
215
216 - name: Install
217 working-directory: '${{ github.workspace }}/../build'
218 run: cmake --install . --strip