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 | - { |
| 21 | name: "Release, Ubuntu 18.04, gcc", |
| 22 | os: "ubuntu-18.04", |
| 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 | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 27 | packages: "libcmocka-dev shunit2", |
| 28 | snaps: "", |
| 29 | make-prepend: "", |
| 30 | make-target: "" |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 31 | } |
| 32 | - { |
| 33 | name: "Release, Ubuntu 18.04, clang", |
| 34 | os: "ubuntu-18.04", |
| 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 | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 39 | packages: "libcmocka-dev shunit2", |
| 40 | snaps: "", |
| 41 | make-prepend: "", |
| 42 | make-target: "" |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 43 | } |
| 44 | - { |
| 45 | name: "Debug, Ubuntu 18.04, gcc", |
| 46 | os: "ubuntu-18.04", |
| 47 | build-type: "Debug", |
| 48 | cc: "gcc", |
| 49 | options: "", |
| 50 | packager: "sudo apt-get", |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 51 | packages: "libcmocka-dev valgrind shunit2", |
| 52 | snaps: "", |
| 53 | make-prepend: "", |
| 54 | make-target: "" |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 55 | } |
| 56 | - { |
| 57 | name: "Debug, Ubuntu 18.04, clang", |
| 58 | os: "ubuntu-18.04", |
| 59 | build-type: "Debug", |
| 60 | cc: "clang", |
| 61 | options: "", |
| 62 | packager: "sudo apt-get", |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 63 | packages: "libcmocka-dev valgrind shunit2", |
| 64 | snaps: "", |
| 65 | make-prepend: "", |
| 66 | make-target: "" |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 67 | } |
| 68 | - { |
| 69 | name: "Release, macOS 10.15, clang", |
| 70 | os: "macos-10.15", |
| 71 | build-type: "Release", |
| 72 | cc: "clang", |
Michal Vasko | cdffdab | 2021-06-23 14:00:10 +0200 | [diff] [blame] | 73 | options: "-DENABLE_TESTS=ON", |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 74 | packager: "brew", |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 75 | packages: "cmocka shunit2", |
| 76 | snaps: "", |
| 77 | make-prepend: "", |
| 78 | make-target: "" |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 79 | } |
| 80 | - { |
Jan Kundrát | da34569 | 2022-07-16 13:21:23 +0200 | [diff] [blame] | 81 | name: "ASAN and UBSAN, clang 14", |
| 82 | os: "ubuntu-22.04", |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 83 | build-type: "Debug", |
Jan Kundrát | da34569 | 2022-07-16 13:21:23 +0200 | [diff] [blame] | 84 | cc: "clang-14", |
Michal Vasko | cdffdab | 2021-06-23 14:00:10 +0200 | [diff] [blame] | 85 | 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] | 86 | packager: "sudo apt-get", |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 87 | packages: "libcmocka-dev", |
| 88 | snaps: "", |
| 89 | make-prepend: "", |
| 90 | make-target: "" |
| 91 | } |
| 92 | - { |
| 93 | name: "ABI Check", |
| 94 | os: "ubuntu-latest", |
| 95 | build-type: "ABICheck", |
| 96 | cc: "gcc", |
| 97 | options: "", |
Michal Vasko | b504368 | 2021-05-28 10:33:24 +0200 | [diff] [blame] | 98 | packager: "sudo apt-get", |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 99 | packages: "libcmocka-dev abi-dumper abi-compliance-checker", |
| 100 | snaps: "core universal-ctags", |
| 101 | make-prepend: "", |
| 102 | make-target: "abi-check" |
| 103 | } |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 104 | |
| 105 | steps: |
| 106 | - uses: actions/checkout@v2 |
| 107 | |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 108 | - name: Deps-packages |
| 109 | shell: bash |
| 110 | run: | |
| 111 | ${{ matrix.config.packager }} update |
| 112 | if ${{ matrix.config.packages != '' }} |
| 113 | then ${{ matrix.config.packager }} install ${{ matrix.config.packages }} |
| 114 | fi |
| 115 | if ${{ matrix.config.snaps != '' }} |
| 116 | then sudo snap install ${{ matrix.config.snaps }} |
| 117 | fi |
| 118 | |
| 119 | - name: Deps-uncrustify |
Michal Vasko | 8bdbf85 | 2021-04-14 16:19:17 +0200 | [diff] [blame] | 120 | shell: bash |
| 121 | working-directory: ${{ github.workspace }} |
| 122 | run: | |
Michal Vasko | 26bbb27 | 2022-08-02 14:54:33 +0200 | [diff] [blame^] | 123 | git clone --branch uncrustify-0.75.1 https://github.com/uncrustify/uncrustify |
Michal Vasko | 8bdbf85 | 2021-04-14 16:19:17 +0200 | [diff] [blame] | 124 | cd uncrustify |
| 125 | mkdir build |
| 126 | cd build |
| 127 | CC=${{ matrix.config.cc }} cmake .. |
| 128 | make |
| 129 | sudo make install |
| 130 | if: ${{ matrix.config.name == 'Debug, Ubuntu 18.04, gcc' }} |
| 131 | |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 132 | - name: Configure |
| 133 | shell: bash |
| 134 | working-directory: ${{ github.workspace }} |
| 135 | run: | |
| 136 | mkdir build |
| 137 | cd build |
| 138 | CC=${{ matrix.config.cc }} cmake -DCMAKE_BUILD_TYPE=${{ matrix.config.build-type }} ${{ matrix.config.options }} .. |
| 139 | |
| 140 | - name: Build |
| 141 | shell: bash |
| 142 | working-directory: ${{ github.workspace }}/build |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 143 | run: | |
| 144 | export LC_ALL=C.UTF-8 |
| 145 | export PATH=/snap/bin:${{ github.workspace }}/coverity-tools/bin:$PATH |
| 146 | ${{ matrix.config.make-prepend }} make ${{ matrix.config.make-target }} |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 147 | |
| 148 | - name: Test |
| 149 | shell: bash |
| 150 | working-directory: ${{ github.workspace }}/build |
| 151 | run: ctest --output-on-failure |
Jan Kundrát | f202b12 | 2021-12-14 19:02:10 +0100 | [diff] [blame] | 152 | |
| 153 | build-windows: |
| 154 | name: ${{ matrix.name }} |
| 155 | runs-on: ${{ matrix.os }} |
| 156 | strategy: |
| 157 | fail-fast: false |
| 158 | matrix: |
| 159 | include: |
Jan Kundrát | a3b1c6d | 2022-07-07 21:53:34 +0200 | [diff] [blame] | 160 | - name: "Windows 2022 MSVC 16 LF" |
| 161 | os: windows-2022 |
| 162 | triplet: x64-windows |
| 163 | build_type: Release |
| 164 | generators: "Visual Studio 17 2022" |
| 165 | autocrlf: input |
| 166 | eol: lf |
| 167 | |
| 168 | - name: "Windows 2022 MSVC 16 no autoCRLF" |
Jan Kundrát | f202b12 | 2021-12-14 19:02:10 +0100 | [diff] [blame] | 169 | os: windows-2022 |
| 170 | triplet: x64-windows |
| 171 | build_type: Release |
| 172 | generators: "Visual Studio 17 2022" |
| 173 | |
| 174 | steps: |
| 175 | - name: Unix line endings in git |
Jan Kundrát | a3b1c6d | 2022-07-07 21:53:34 +0200 | [diff] [blame] | 176 | if: matrix.autocrlf |
Jan Kundrát | f202b12 | 2021-12-14 19:02:10 +0100 | [diff] [blame] | 177 | run: | |
Jan Kundrát | a3b1c6d | 2022-07-07 21:53:34 +0200 | [diff] [blame] | 178 | git config --global core.autocrlf ${{ matrix.autocrlf }} |
| 179 | |
| 180 | - name: Unix line endings in git |
| 181 | if: matrix.eol |
| 182 | run: | |
| 183 | git config --global core.eol ${{ matrix.eol }} |
Jan Kundrát | f202b12 | 2021-12-14 19:02:10 +0100 | [diff] [blame] | 184 | |
| 185 | - uses: actions/checkout@v2 |
| 186 | |
| 187 | - name: Get number of CPU cores |
| 188 | id: cpu-cores |
| 189 | uses: SimenB/github-actions-cpu-cores@5e7112c2e8c5b63b649a678bc2fb5920d0c8202e |
| 190 | |
| 191 | - name: Install Windows dependencies |
| 192 | run: vcpkg install --triplet=${{ matrix.triplet }} pcre2 pthreads dirent dlfcn-win32 cmocka getopt |
| 193 | |
| 194 | - name: Configure |
| 195 | shell: bash |
| 196 | run: | |
| 197 | cmake \ |
| 198 | -S '${{ github.workspace }}/' \ |
| 199 | -B '${{ github.workspace }}/'../build \ |
| 200 | -G '${{ matrix.generators }}' \ |
| 201 | -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ |
| 202 | -DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }} \ |
| 203 | -DCMAKE_TOOLCHAIN_FILE=${VCPKG_INSTALLATION_ROOT//\\//}/scripts/buildsystems/vcpkg.cmake \ |
| 204 | -DENABLE_TESTS=ON \ |
| 205 | '-DCMAKE_INSTALL_PREFIX:PATH=${{ github.workspace }}'/../target |
| 206 | |
| 207 | - name: Build |
| 208 | working-directory: '${{ github.workspace }}/../build' |
| 209 | run: cmake --build . -j${{ steps.cpu-cores.outputs.count }} --config ${{ matrix.build_type }} |
| 210 | |
| 211 | - name: Test |
| 212 | working-directory: '${{ github.workspace }}/../build' |
| 213 | run: ctest --output-on-failure -j${{ steps.cpu-cores.outputs.count }} --build-config ${{ matrix.build_type }} |
| 214 | |
| 215 | - name: Install |
| 216 | working-directory: '${{ github.workspace }}/../build' |
| 217 | run: cmake --install . --strip |