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 | |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 12 | env: |
| 13 | COVERITY_PROJECT: CESNET%2Flibyang |
| 14 | |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 15 | jobs: |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 16 | git-branch: |
| 17 | name: Get git branch |
| 18 | runs-on: ubuntu-18.04 |
| 19 | outputs: |
| 20 | branch-name: ${{ steps.get-git-branch.outputs.branch-name }} |
| 21 | steps: |
| 22 | - id: get-git-branch |
| 23 | run: | |
| 24 | if ${{ github.event_name == 'push' }} |
| 25 | then export GIT_BRANCH=`echo ${{ github.ref }} | cut -d'/' -f 3` |
| 26 | else |
| 27 | export GIT_BRANCH=${{ github.base_ref }} |
| 28 | fi |
| 29 | echo "::set-output name=branch-name::$GIT_BRANCH" |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 30 | build: |
| 31 | name: ${{ matrix.config.name }} |
| 32 | runs-on: ${{ matrix.config.os }} |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 33 | needs: git-branch |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 34 | strategy: |
| 35 | fail-fast: false |
| 36 | matrix: |
| 37 | config: |
| 38 | - { |
| 39 | name: "Release, Ubuntu 18.04, gcc", |
| 40 | os: "ubuntu-18.04", |
| 41 | build-type: "Release", |
| 42 | cc: "gcc", |
| 43 | options: "-DENABLE_BUILD_TESTS=ON", |
| 44 | packager: "sudo apt-get", |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 45 | packages: "libcmocka-dev shunit2", |
| 46 | snaps: "", |
| 47 | make-prepend: "", |
| 48 | make-target: "" |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 49 | } |
| 50 | - { |
| 51 | name: "Release, Ubuntu 18.04, clang", |
| 52 | os: "ubuntu-18.04", |
| 53 | build-type: "Release", |
| 54 | cc: "clang", |
| 55 | options: "-DENABLE_BUILD_TESTS=ON", |
| 56 | packager: "sudo apt-get", |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 57 | packages: "libcmocka-dev shunit2", |
| 58 | snaps: "", |
| 59 | make-prepend: "", |
| 60 | make-target: "" |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 61 | } |
| 62 | - { |
| 63 | name: "Debug, Ubuntu 18.04, gcc", |
| 64 | os: "ubuntu-18.04", |
| 65 | build-type: "Debug", |
| 66 | cc: "gcc", |
| 67 | options: "", |
| 68 | packager: "sudo apt-get", |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 69 | packages: "libcmocka-dev valgrind shunit2", |
| 70 | snaps: "", |
| 71 | make-prepend: "", |
| 72 | make-target: "" |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 73 | } |
| 74 | - { |
| 75 | name: "Debug, Ubuntu 18.04, clang", |
| 76 | os: "ubuntu-18.04", |
| 77 | build-type: "Debug", |
| 78 | cc: "clang", |
| 79 | options: "", |
| 80 | packager: "sudo apt-get", |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 81 | packages: "libcmocka-dev valgrind shunit2", |
| 82 | snaps: "", |
| 83 | make-prepend: "", |
| 84 | make-target: "" |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 85 | } |
| 86 | - { |
| 87 | name: "Release, macOS 10.15, clang", |
| 88 | os: "macos-10.15", |
| 89 | build-type: "Release", |
| 90 | cc: "clang", |
| 91 | options: "-DENABLE_BUILD_TESTS=ON", |
| 92 | packager: "brew", |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 93 | packages: "cmocka shunit2", |
| 94 | snaps: "", |
| 95 | make-prepend: "", |
| 96 | make-target: "" |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 97 | } |
| 98 | - { |
| 99 | name: "ASAN and UBSAN", |
| 100 | os: "ubuntu-18.04", |
| 101 | build-type: "Debug", |
| 102 | cc: "clang", |
| 103 | options: "-DCMAKE_C_FLAGS=-fsanitize=address,undefined -DENABLE_BUILD_TESTS=ON -DENABLE_VALGRIND_TESTS=OFF", |
| 104 | packager: "sudo apt-get", |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 105 | packages: "libcmocka-dev", |
| 106 | snaps: "", |
| 107 | make-prepend: "", |
| 108 | make-target: "" |
| 109 | } |
| 110 | - { |
| 111 | name: "ABI Check", |
| 112 | os: "ubuntu-latest", |
| 113 | build-type: "ABICheck", |
| 114 | cc: "gcc", |
| 115 | options: "", |
Michal Vasko | b504368 | 2021-05-28 10:33:24 +0200 | [diff] [blame^] | 116 | packager: "sudo apt-get", |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 117 | packages: "libcmocka-dev abi-dumper abi-compliance-checker", |
| 118 | snaps: "core universal-ctags", |
| 119 | make-prepend: "", |
| 120 | make-target: "abi-check" |
| 121 | } |
| 122 | - { |
| 123 | name: "Coverity", |
| 124 | os: "ubuntu-latest", |
| 125 | build-type: "Debug", |
| 126 | cc: "clang", |
| 127 | options: "", |
Michal Vasko | b504368 | 2021-05-28 10:33:24 +0200 | [diff] [blame^] | 128 | packager: "sudo apt-get", |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 129 | packages: "", |
| 130 | snaps: "", |
| 131 | make-prepend: "cov-build --dir cov-int", |
| 132 | make-target: "" |
| 133 | } |
| 134 | - { |
| 135 | name: "Codecov", |
| 136 | os: "ubuntu-latest", |
| 137 | build-type: "Debug", |
| 138 | cc: "gcc", |
| 139 | options: "-DENABLE_COVERAGE=ON", |
Michal Vasko | b504368 | 2021-05-28 10:33:24 +0200 | [diff] [blame^] | 140 | packager: "sudo apt-get", |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 141 | packages: "libcmocka-dev lcov", |
| 142 | snaps: "", |
| 143 | make-prepend: "", |
| 144 | make-target: "" |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 145 | } |
| 146 | |
| 147 | steps: |
| 148 | - uses: actions/checkout@v2 |
| 149 | |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 150 | - name: Deps-packages |
| 151 | shell: bash |
| 152 | run: | |
| 153 | ${{ matrix.config.packager }} update |
| 154 | if ${{ matrix.config.packages != '' }} |
| 155 | then ${{ matrix.config.packager }} install ${{ matrix.config.packages }} |
| 156 | fi |
| 157 | if ${{ matrix.config.snaps != '' }} |
| 158 | then sudo snap install ${{ matrix.config.snaps }} |
| 159 | fi |
| 160 | |
| 161 | - name: Deps-uncrustify |
Michal Vasko | 8bdbf85 | 2021-04-14 16:19:17 +0200 | [diff] [blame] | 162 | shell: bash |
| 163 | working-directory: ${{ github.workspace }} |
| 164 | run: | |
| 165 | git clone --branch uncrustify-0.71.0 https://github.com/uncrustify/uncrustify |
| 166 | cd uncrustify |
| 167 | mkdir build |
| 168 | cd build |
| 169 | CC=${{ matrix.config.cc }} cmake .. |
| 170 | make |
| 171 | sudo make install |
| 172 | if: ${{ matrix.config.name == 'Debug, Ubuntu 18.04, gcc' }} |
| 173 | |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 174 | - name: Deps-coverity |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 175 | shell: bash |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 176 | working-directory: ${{ github.workspace }} |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 177 | run: | |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 178 | wget -q https://scan.coverity.com/download/linux64 --post-data "token=$TOKEN&project=$COVERITY_PROJECT" -O coverity-tools.tar.gz |
| 179 | mkdir coverity-tools |
| 180 | tar xzf coverity-tools.tar.gz --strip 1 -C coverity-tools |
| 181 | env: |
| 182 | TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }} |
| 183 | if: ${{ matrix.config.name == 'Coverity' }} |
| 184 | |
| 185 | - name: Deps-coverity-fix-permissions |
| 186 | run: | |
| 187 | chmod go-w $HOME |
| 188 | sudo chmod -R go-w /usr/share |
| 189 | if: ${{ matrix.config.name == 'Coverity' }} |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 190 | |
| 191 | - name: Configure |
| 192 | shell: bash |
| 193 | working-directory: ${{ github.workspace }} |
| 194 | run: | |
| 195 | mkdir build |
| 196 | cd build |
| 197 | CC=${{ matrix.config.cc }} cmake -DCMAKE_BUILD_TYPE=${{ matrix.config.build-type }} ${{ matrix.config.options }} .. |
| 198 | |
| 199 | - name: Build |
| 200 | shell: bash |
| 201 | working-directory: ${{ github.workspace }}/build |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 202 | run: | |
| 203 | export LC_ALL=C.UTF-8 |
| 204 | export PATH=/snap/bin:${{ github.workspace }}/coverity-tools/bin:$PATH |
| 205 | ${{ matrix.config.make-prepend }} make ${{ matrix.config.make-target }} |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 206 | |
| 207 | - name: Test |
| 208 | shell: bash |
| 209 | working-directory: ${{ github.workspace }}/build |
| 210 | run: ctest --output-on-failure |
| 211 | |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 212 | - name: Upload to Coverity.com |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 213 | shell: bash |
| 214 | working-directory: ${{ github.workspace }}/build |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 215 | run: | |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 216 | tar czvf libyang.tgz cov-int |
| 217 | curl \ |
| 218 | --form token=$TOKEN \ |
| 219 | --form email=mvasko@cesnet.cz \ |
| 220 | --form file=libyang.tgz \ |
| 221 | --form version="`./yanglint -v | cut -d\" \" -f2`" \ |
| 222 | --form description="libyang YANG library" \ |
| 223 | https://scan.coverity.com/builds?project=$COVERITY_PROJECT |
| 224 | env: |
| 225 | TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }} |
| 226 | if: ${{ matrix.config.name == 'Coverity' && github.event_name == 'push' && needs.git-branch.outputs.branch-name == 'devel' }} |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 227 | |
Michal Vasko | d52860b | 2021-05-25 10:02:03 +0200 | [diff] [blame] | 228 | - name: Upload to Codecov.io |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 229 | shell: bash |
| 230 | working-directory: ${{ github.workspace }}/build |
| 231 | run: bash <(curl -s https://codecov.io/bash) |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame] | 232 | if: ${{ matrix.config.name == 'Codecov' && github.event_name == 'push' }} |