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: "", |
| 30 | make-prepend: "", |
| 31 | make-target: "" |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 32 | } |
| 33 | - { |
Michal Vasko | 09bddf9 | 2022-11-09 12:04:11 +0100 | [diff] [blame] | 34 | name: "Release, clang", |
| 35 | os: "ubuntu-22.04", |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 36 | build-type: "Release", |
| 37 | cc: "clang", |
Michal Vasko | cdffdab | 2021-06-23 14:00:10 +0200 | [diff] [blame] | 38 | options: "-DENABLE_TESTS=ON", |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 39 | packager: "sudo apt-get", |
Michal Vasko | c1372ae | 2022-11-09 12:13:45 +0100 | [diff] [blame] | 40 | packages: "libcmocka-dev shunit2", |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 41 | snaps: "", |
| 42 | make-prepend: "", |
| 43 | make-target: "" |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 44 | } |
| 45 | - { |
Michal Vasko | 09bddf9 | 2022-11-09 12:04:11 +0100 | [diff] [blame] | 46 | name: "Debug, gcc", |
| 47 | os: "ubuntu-22.04", |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 48 | build-type: "Debug", |
| 49 | cc: "gcc", |
| 50 | options: "", |
| 51 | packager: "sudo apt-get", |
Michal Vasko | c1372ae | 2022-11-09 12:13:45 +0100 | [diff] [blame] | 52 | packages: "libcmocka-dev valgrind shunit2", |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 53 | snaps: "", |
| 54 | make-prepend: "", |
| 55 | make-target: "" |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 56 | } |
| 57 | - { |
Michal Vasko | 09bddf9 | 2022-11-09 12:04:11 +0100 | [diff] [blame] | 58 | name: "Debug, clang", |
| 59 | os: "ubuntu-22.04", |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 60 | build-type: "Debug", |
| 61 | cc: "clang", |
| 62 | options: "", |
| 63 | packager: "sudo apt-get", |
Michal Vasko | 09bddf9 | 2022-11-09 12:04:11 +0100 | [diff] [blame] | 64 | # 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] | 65 | packages: "libcmocka-dev shunit2", |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 66 | snaps: "", |
| 67 | make-prepend: "", |
| 68 | make-target: "" |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 69 | } |
| 70 | - { |
Michal Vasko | dca6346 | 2022-08-17 12:03:34 +0200 | [diff] [blame] | 71 | name: "Release, macOS 11, clang", |
| 72 | os: "macos-11", |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 73 | build-type: "Release", |
| 74 | cc: "clang", |
Michal Vasko | 682d543 | 2022-08-17 12:31:55 +0200 | [diff] [blame] | 75 | options: "-DENABLE_TESTS=ON -DPATH_EXPECT=", |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 76 | packager: "brew", |
Michal Vasko | 682d543 | 2022-08-17 12:31:55 +0200 | [diff] [blame] | 77 | packages: "cmocka shunit2", |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 78 | snaps: "", |
| 79 | make-prepend: "", |
| 80 | make-target: "" |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 81 | } |
| 82 | - { |
Michal Vasko | 09bddf9 | 2022-11-09 12:04:11 +0100 | [diff] [blame] | 83 | name: "ASAN and UBSAN", |
Jan Kundrát | da34569 | 2022-07-16 13:21:23 +0200 | [diff] [blame] | 84 | os: "ubuntu-22.04", |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 85 | build-type: "Debug", |
Michal Vasko | 09bddf9 | 2022-11-09 12:04:11 +0100 | [diff] [blame] | 86 | cc: "clang", |
Michal Vasko | cdffdab | 2021-06-23 14:00:10 +0200 | [diff] [blame] | 87 | 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] | 88 | packager: "sudo apt-get", |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 89 | packages: "libcmocka-dev", |
| 90 | snaps: "", |
| 91 | make-prepend: "", |
| 92 | make-target: "" |
| 93 | } |
| 94 | - { |
| 95 | name: "ABI Check", |
Michal Vasko | 09bddf9 | 2022-11-09 12:04:11 +0100 | [diff] [blame] | 96 | os: "ubuntu-22.04", |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 97 | build-type: "ABICheck", |
| 98 | cc: "gcc", |
| 99 | options: "", |
Michal Vasko | b504368 | 2021-05-28 10:33:24 +0200 | [diff] [blame] | 100 | packager: "sudo apt-get", |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 101 | packages: "libcmocka-dev abi-dumper abi-compliance-checker", |
| 102 | snaps: "core universal-ctags", |
| 103 | make-prepend: "", |
| 104 | make-target: "abi-check" |
| 105 | } |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 106 | |
| 107 | steps: |
Michal Vasko | 09bddf9 | 2022-11-09 12:04:11 +0100 | [diff] [blame] | 108 | - uses: actions/checkout@v3 |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 109 | |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 110 | - 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 Vasko | 8bdbf85 | 2021-04-14 16:19:17 +0200 | [diff] [blame] | 122 | shell: bash |
| 123 | working-directory: ${{ github.workspace }} |
| 124 | run: | |
Michal Vasko | 84bf6f4 | 2023-05-19 11:09:48 +0200 | [diff] [blame^] | 125 | git clone --branch uncrustify-0.77.1 https://github.com/uncrustify/uncrustify |
Michal Vasko | 8bdbf85 | 2021-04-14 16:19:17 +0200 | [diff] [blame] | 126 | cd uncrustify |
| 127 | mkdir build |
| 128 | cd build |
| 129 | CC=${{ matrix.config.cc }} cmake .. |
| 130 | make |
| 131 | sudo make install |
Michal Vasko | 09bddf9 | 2022-11-09 12:04:11 +0100 | [diff] [blame] | 132 | if: ${{ matrix.config.name == 'Debug, gcc' }} |
Michal Vasko | 8bdbf85 | 2021-04-14 16:19:17 +0200 | [diff] [blame] | 133 | |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 134 | - 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 Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 145 | 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 Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 149 | |
| 150 | - name: Test |
| 151 | shell: bash |
| 152 | working-directory: ${{ github.workspace }}/build |
| 153 | run: ctest --output-on-failure |
Jan Kundrát | f202b12 | 2021-12-14 19:02:10 +0100 | [diff] [blame] | 154 | |
| 155 | build-windows: |
| 156 | name: ${{ matrix.name }} |
| 157 | runs-on: ${{ matrix.os }} |
| 158 | strategy: |
| 159 | fail-fast: false |
| 160 | matrix: |
| 161 | include: |
Jan Kundrát | a3b1c6d | 2022-07-07 21:53:34 +0200 | [diff] [blame] | 162 | - 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át | f202b12 | 2021-12-14 19:02:10 +0100 | [diff] [blame] | 171 | 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át | a3b1c6d | 2022-07-07 21:53:34 +0200 | [diff] [blame] | 178 | if: matrix.autocrlf |
Jan Kundrát | f202b12 | 2021-12-14 19:02:10 +0100 | [diff] [blame] | 179 | run: | |
Jan Kundrát | a3b1c6d | 2022-07-07 21:53:34 +0200 | [diff] [blame] | 180 | 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át | f202b12 | 2021-12-14 19:02:10 +0100 | [diff] [blame] | 186 | |
Michal Vasko | 09bddf9 | 2022-11-09 12:04:11 +0100 | [diff] [blame] | 187 | - uses: actions/checkout@v3 |
Jan Kundrát | f202b12 | 2021-12-14 19:02:10 +0100 | [diff] [blame] | 188 | |
| 189 | - name: Get number of CPU cores |
| 190 | id: cpu-cores |
Michal Vasko | 09bddf9 | 2022-11-09 12:04:11 +0100 | [diff] [blame] | 191 | uses: SimenB/github-actions-cpu-cores@v1 |
Jan Kundrát | f202b12 | 2021-12-14 19:02:10 +0100 | [diff] [blame] | 192 | |
| 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 |