Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 1 | name: libyang CI |
Michal Vasko | 8bdbf85 | 2021-04-14 16:19:17 +0200 | [diff] [blame] | 2 | on: |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 3 | push: |
| 4 | branches: |
Michal Vasko | 0791e80 | 2021-05-27 10:29:14 +0200 | [diff] [blame] | 5 | - master |
| 6 | - devel |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 7 | pull_request: |
| 8 | branches: |
Michal Vasko | 0791e80 | 2021-05-27 10:29:14 +0200 | [diff] [blame] | 9 | - master |
| 10 | - devel |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 11 | |
| 12 | jobs: |
Jan Kundrát | f202b12 | 2021-12-14 19:02:10 +0100 | [diff] [blame] | 13 | build-unix: |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 14 | name: ${{ matrix.config.name }} |
| 15 | runs-on: ${{ matrix.config.os }} |
| 16 | strategy: |
| 17 | fail-fast: false |
| 18 | matrix: |
| 19 | config: |
| 20 | - { |
Michal Vasko | 09bddf9 | 2022-11-09 12:04:11 +0100 | [diff] [blame] | 21 | name: "Release, gcc", |
| 22 | os: "ubuntu-22.04", |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 23 | build-type: "Release", |
| 24 | cc: "gcc", |
Michal Vasko | cdffdab | 2021-06-23 14:00:10 +0200 | [diff] [blame] | 25 | options: "-DENABLE_TESTS=ON", |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 26 | packager: "sudo apt-get", |
Michal Vasko | c1372ae | 2022-11-09 12:13:45 +0100 | [diff] [blame] | 27 | # no expect because stdout seems to be redirected |
| 28 | packages: "libcmocka-dev shunit2", |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 29 | snaps: "", |
Michal Vasko | cbb3061 | 2024-03-18 10:34:16 +0100 | [diff] [blame] | 30 | build-cmd: "make" |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 31 | } |
| 32 | - { |
Michal Vasko | 09bddf9 | 2022-11-09 12:04:11 +0100 | [diff] [blame] | 33 | name: "Release, clang", |
| 34 | os: "ubuntu-22.04", |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 35 | build-type: "Release", |
| 36 | cc: "clang", |
Michal Vasko | cdffdab | 2021-06-23 14:00:10 +0200 | [diff] [blame] | 37 | options: "-DENABLE_TESTS=ON", |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 38 | packager: "sudo apt-get", |
Michal Vasko | c1372ae | 2022-11-09 12:13:45 +0100 | [diff] [blame] | 39 | packages: "libcmocka-dev shunit2", |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 40 | snaps: "", |
Michal Vasko | cbb3061 | 2024-03-18 10:34:16 +0100 | [diff] [blame] | 41 | build-cmd: "make" |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 42 | } |
| 43 | - { |
Michal Vasko | 09bddf9 | 2022-11-09 12:04:11 +0100 | [diff] [blame] | 44 | name: "Debug, gcc", |
| 45 | os: "ubuntu-22.04", |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 46 | build-type: "Debug", |
| 47 | cc: "gcc", |
| 48 | options: "", |
| 49 | packager: "sudo apt-get", |
Michal Vasko | c1372ae | 2022-11-09 12:13:45 +0100 | [diff] [blame] | 50 | packages: "libcmocka-dev valgrind shunit2", |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 51 | snaps: "", |
Michal Vasko | cbb3061 | 2024-03-18 10:34:16 +0100 | [diff] [blame] | 52 | build-cmd: "make" |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 53 | } |
| 54 | - { |
Michal Vasko | 09bddf9 | 2022-11-09 12:04:11 +0100 | [diff] [blame] | 55 | name: "Debug, clang", |
| 56 | os: "ubuntu-22.04", |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 57 | build-type: "Debug", |
| 58 | cc: "clang", |
| 59 | options: "", |
| 60 | packager: "sudo apt-get", |
Michal Vasko | 09bddf9 | 2022-11-09 12:04:11 +0100 | [diff] [blame] | 61 | # no valgrind because it does not support DWARF5 yet generated by clang 14 |
Michal Vasko | c1372ae | 2022-11-09 12:13:45 +0100 | [diff] [blame] | 62 | packages: "libcmocka-dev shunit2", |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 63 | snaps: "", |
Michal Vasko | cbb3061 | 2024-03-18 10:34:16 +0100 | [diff] [blame] | 64 | build-cmd: "make" |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 65 | } |
| 66 | - { |
Michal Vasko | d4200ac | 2024-07-16 11:12:44 +0200 | [diff] [blame^] | 67 | name: "Release, macOS 14, clang", |
| 68 | os: "macos-14", |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 69 | build-type: "Release", |
| 70 | cc: "clang", |
Michal Vasko | 682d543 | 2022-08-17 12:31:55 +0200 | [diff] [blame] | 71 | options: "-DENABLE_TESTS=ON -DPATH_EXPECT=", |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 72 | packager: "brew", |
Michal Vasko | 682d543 | 2022-08-17 12:31:55 +0200 | [diff] [blame] | 73 | packages: "cmocka shunit2", |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 74 | snaps: "", |
Michal Vasko | cbb3061 | 2024-03-18 10:34:16 +0100 | [diff] [blame] | 75 | build-cmd: "make" |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 76 | } |
| 77 | - { |
Michal Vasko | 09bddf9 | 2022-11-09 12:04:11 +0100 | [diff] [blame] | 78 | name: "ASAN and UBSAN", |
Jan Kundrát | da34569 | 2022-07-16 13:21:23 +0200 | [diff] [blame] | 79 | os: "ubuntu-22.04", |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 80 | build-type: "Debug", |
Michal Vasko | 09bddf9 | 2022-11-09 12:04:11 +0100 | [diff] [blame] | 81 | cc: "clang", |
Michal Vasko | cdffdab | 2021-06-23 14:00:10 +0200 | [diff] [blame] | 82 | options: "-DCMAKE_C_FLAGS=-fsanitize=address,undefined -DENABLE_TESTS=ON -DENABLE_VALGRIND_TESTS=OFF", |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 83 | packager: "sudo apt-get", |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 84 | packages: "libcmocka-dev", |
| 85 | snaps: "", |
Michal Vasko | cbb3061 | 2024-03-18 10:34:16 +0100 | [diff] [blame] | 86 | build-cmd: "make" |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 87 | } |
| 88 | - { |
| 89 | name: "ABI Check", |
Michal Vasko | 09bddf9 | 2022-11-09 12:04:11 +0100 | [diff] [blame] | 90 | os: "ubuntu-22.04", |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 91 | build-type: "ABICheck", |
| 92 | cc: "gcc", |
| 93 | options: "", |
Michal Vasko | b504368 | 2021-05-28 10:33:24 +0200 | [diff] [blame] | 94 | packager: "sudo apt-get", |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 95 | packages: "libcmocka-dev abi-dumper abi-compliance-checker", |
| 96 | snaps: "core universal-ctags", |
Michal Vasko | cbb3061 | 2024-03-18 10:34:16 +0100 | [diff] [blame] | 97 | 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", |
Michal Vasko | 8ef803c | 2024-03-18 11:38:59 +0100 | [diff] [blame] | 106 | packages: "cmake debhelper libcmocka-dev python3-pip", |
Michal Vasko | cbb3061 | 2024-03-18 10:34:16 +0100 | [diff] [blame] | 107 | snaps: "", |
Michal Vasko | d69f738 | 2024-03-18 11:06:03 +0100 | [diff] [blame] | 108 | build-cmd: "" |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 109 | } |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 110 | |
| 111 | steps: |
Michal Vasko | cbb3061 | 2024-03-18 10:34:16 +0100 | [diff] [blame] | 112 | - uses: actions/checkout@main |
Michal Vasko | 8f6ddc5 | 2024-03-18 11:36:42 +0100 | [diff] [blame] | 113 | with: |
| 114 | fetch-depth: 100 |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 115 | |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 116 | - name: Deps-packages |
| 117 | shell: bash |
| 118 | run: | |
| 119 | ${{ matrix.config.packager }} update |
| 120 | if ${{ matrix.config.packages != '' }} |
| 121 | then ${{ matrix.config.packager }} install ${{ matrix.config.packages }} |
| 122 | fi |
| 123 | if ${{ matrix.config.snaps != '' }} |
| 124 | then sudo snap install ${{ matrix.config.snaps }} |
| 125 | fi |
| 126 | |
| 127 | - name: Deps-uncrustify |
Michal Vasko | 8bdbf85 | 2021-04-14 16:19:17 +0200 | [diff] [blame] | 128 | shell: bash |
| 129 | working-directory: ${{ github.workspace }} |
| 130 | run: | |
Michal Vasko | 84bf6f4 | 2023-05-19 11:09:48 +0200 | [diff] [blame] | 131 | git clone --branch uncrustify-0.77.1 https://github.com/uncrustify/uncrustify |
Michal Vasko | 8bdbf85 | 2021-04-14 16:19:17 +0200 | [diff] [blame] | 132 | cd uncrustify |
| 133 | mkdir build |
| 134 | cd build |
| 135 | CC=${{ matrix.config.cc }} cmake .. |
| 136 | make |
| 137 | sudo make install |
Michal Vasko | 09bddf9 | 2022-11-09 12:04:11 +0100 | [diff] [blame] | 138 | if: ${{ matrix.config.name == 'Debug, gcc' }} |
Michal Vasko | 8bdbf85 | 2021-04-14 16:19:17 +0200 | [diff] [blame] | 139 | |
Michal Vasko | d69f738 | 2024-03-18 11:06:03 +0100 | [diff] [blame] | 140 | - name: Build-and-install-package |
| 141 | shell: bash |
Michal Vasko | d187d9c | 2024-03-18 11:24:49 +0100 | [diff] [blame] | 142 | working-directory: ${{ github.workspace }} |
Michal Vasko | d69f738 | 2024-03-18 11:06:03 +0100 | [diff] [blame] | 143 | run: | |
| 144 | pip install apkg |
| 145 | apkg system-setup |
| 146 | apkg build |
| 147 | apkg install |
| 148 | if: ${{ matrix.config.name == 'DEB Package' }} |
| 149 | |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 150 | - name: Configure |
| 151 | shell: bash |
| 152 | working-directory: ${{ github.workspace }} |
| 153 | run: | |
| 154 | mkdir build |
| 155 | cd build |
| 156 | CC=${{ matrix.config.cc }} cmake -DCMAKE_BUILD_TYPE=${{ matrix.config.build-type }} ${{ matrix.config.options }} .. |
Michal Vasko | cbb3061 | 2024-03-18 10:34:16 +0100 | [diff] [blame] | 157 | if: ${{ matrix.config.name != 'DEB Package' }} |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 158 | |
| 159 | - name: Build |
| 160 | shell: bash |
| 161 | working-directory: ${{ github.workspace }}/build |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 162 | run: | |
| 163 | export LC_ALL=C.UTF-8 |
| 164 | export PATH=/snap/bin:${{ github.workspace }}/coverity-tools/bin:$PATH |
Michal Vasko | cbb3061 | 2024-03-18 10:34:16 +0100 | [diff] [blame] | 165 | ${{ matrix.config.build-cmd }} |
Michal Vasko | d69f738 | 2024-03-18 11:06:03 +0100 | [diff] [blame] | 166 | if: ${{ matrix.config.name != 'DEB Package' }} |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 167 | |
| 168 | - name: Test |
| 169 | shell: bash |
| 170 | working-directory: ${{ github.workspace }}/build |
| 171 | run: ctest --output-on-failure |
Michal Vasko | d69f738 | 2024-03-18 11:06:03 +0100 | [diff] [blame] | 172 | if: ${{ matrix.config.name != 'DEB Package' }} |
Jan Kundrát | f202b12 | 2021-12-14 19:02:10 +0100 | [diff] [blame] | 173 | |
| 174 | build-windows: |
| 175 | name: ${{ matrix.name }} |
| 176 | runs-on: ${{ matrix.os }} |
| 177 | strategy: |
| 178 | fail-fast: false |
| 179 | matrix: |
| 180 | include: |
Jan Kundrát | a3b1c6d | 2022-07-07 21:53:34 +0200 | [diff] [blame] | 181 | - name: "Windows 2022 MSVC 16 LF" |
| 182 | os: windows-2022 |
| 183 | triplet: x64-windows |
| 184 | build_type: Release |
| 185 | generators: "Visual Studio 17 2022" |
| 186 | autocrlf: input |
| 187 | eol: lf |
| 188 | |
| 189 | - name: "Windows 2022 MSVC 16 no autoCRLF" |
Jan Kundrát | f202b12 | 2021-12-14 19:02:10 +0100 | [diff] [blame] | 190 | os: windows-2022 |
| 191 | triplet: x64-windows |
| 192 | build_type: Release |
| 193 | generators: "Visual Studio 17 2022" |
| 194 | |
| 195 | steps: |
| 196 | - name: Unix line endings in git |
Jan Kundrát | a3b1c6d | 2022-07-07 21:53:34 +0200 | [diff] [blame] | 197 | if: matrix.autocrlf |
Jan Kundrát | f202b12 | 2021-12-14 19:02:10 +0100 | [diff] [blame] | 198 | run: | |
Jan Kundrát | a3b1c6d | 2022-07-07 21:53:34 +0200 | [diff] [blame] | 199 | git config --global core.autocrlf ${{ matrix.autocrlf }} |
| 200 | |
| 201 | - name: Unix line endings in git |
| 202 | if: matrix.eol |
| 203 | run: | |
| 204 | git config --global core.eol ${{ matrix.eol }} |
Jan Kundrát | f202b12 | 2021-12-14 19:02:10 +0100 | [diff] [blame] | 205 | |
Michal Vasko | 99697d7 | 2024-03-18 11:11:32 +0100 | [diff] [blame] | 206 | - uses: actions/checkout@main |
Jan Kundrát | f202b12 | 2021-12-14 19:02:10 +0100 | [diff] [blame] | 207 | |
| 208 | - name: Get number of CPU cores |
| 209 | id: cpu-cores |
Michal Vasko | 09bddf9 | 2022-11-09 12:04:11 +0100 | [diff] [blame] | 210 | uses: SimenB/github-actions-cpu-cores@v1 |
Jan Kundrát | f202b12 | 2021-12-14 19:02:10 +0100 | [diff] [blame] | 211 | |
| 212 | - name: Install Windows dependencies |
| 213 | run: vcpkg install --triplet=${{ matrix.triplet }} pcre2 pthreads dirent dlfcn-win32 cmocka getopt |
| 214 | |
| 215 | - name: Configure |
| 216 | shell: bash |
| 217 | run: | |
| 218 | cmake \ |
| 219 | -S '${{ github.workspace }}/' \ |
| 220 | -B '${{ github.workspace }}/'../build \ |
| 221 | -G '${{ matrix.generators }}' \ |
| 222 | -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ |
| 223 | -DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }} \ |
| 224 | -DCMAKE_TOOLCHAIN_FILE=${VCPKG_INSTALLATION_ROOT//\\//}/scripts/buildsystems/vcpkg.cmake \ |
| 225 | -DENABLE_TESTS=ON \ |
| 226 | '-DCMAKE_INSTALL_PREFIX:PATH=${{ github.workspace }}'/../target |
| 227 | |
| 228 | - name: Build |
| 229 | working-directory: '${{ github.workspace }}/../build' |
| 230 | run: cmake --build . -j${{ steps.cpu-cores.outputs.count }} --config ${{ matrix.build_type }} |
| 231 | |
| 232 | - name: Test |
| 233 | working-directory: '${{ github.workspace }}/../build' |
| 234 | run: ctest --output-on-failure -j${{ steps.cpu-cores.outputs.count }} --build-config ${{ matrix.build_type }} |
| 235 | |
| 236 | - name: Install |
| 237 | working-directory: '${{ github.workspace }}/../build' |
| 238 | run: cmake --install . --strip |