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: "", |
| 116 | packages: "libcmocka-dev abi-dumper abi-compliance-checker", |
| 117 | snaps: "core universal-ctags", |
| 118 | make-prepend: "", |
| 119 | make-target: "abi-check" |
| 120 | } |
| 121 | - { |
| 122 | name: "Coverity", |
| 123 | os: "ubuntu-latest", |
| 124 | build-type: "Debug", |
| 125 | cc: "clang", |
| 126 | options: "", |
| 127 | packages: "", |
| 128 | snaps: "", |
| 129 | make-prepend: "cov-build --dir cov-int", |
| 130 | make-target: "" |
| 131 | } |
| 132 | - { |
| 133 | name: "Codecov", |
| 134 | os: "ubuntu-latest", |
| 135 | build-type: "Debug", |
| 136 | cc: "gcc", |
| 137 | options: "-DENABLE_COVERAGE=ON", |
| 138 | packages: "libcmocka-dev lcov", |
| 139 | snaps: "", |
| 140 | make-prepend: "", |
| 141 | make-target: "" |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 142 | } |
| 143 | |
| 144 | steps: |
| 145 | - uses: actions/checkout@v2 |
| 146 | |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame^] | 147 | - name: Deps-packages |
| 148 | shell: bash |
| 149 | run: | |
| 150 | ${{ matrix.config.packager }} update |
| 151 | if ${{ matrix.config.packages != '' }} |
| 152 | then ${{ matrix.config.packager }} install ${{ matrix.config.packages }} |
| 153 | fi |
| 154 | if ${{ matrix.config.snaps != '' }} |
| 155 | then sudo snap install ${{ matrix.config.snaps }} |
| 156 | fi |
| 157 | |
| 158 | - name: Deps-uncrustify |
Michal Vasko | 8bdbf85 | 2021-04-14 16:19:17 +0200 | [diff] [blame] | 159 | shell: bash |
| 160 | working-directory: ${{ github.workspace }} |
| 161 | run: | |
| 162 | git clone --branch uncrustify-0.71.0 https://github.com/uncrustify/uncrustify |
| 163 | cd uncrustify |
| 164 | mkdir build |
| 165 | cd build |
| 166 | CC=${{ matrix.config.cc }} cmake .. |
| 167 | make |
| 168 | sudo make install |
| 169 | if: ${{ matrix.config.name == 'Debug, Ubuntu 18.04, gcc' }} |
| 170 | |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame^] | 171 | - name: Deps-coverity |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 172 | shell: bash |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame^] | 173 | working-directory: ${{ github.workspace }} |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 174 | run: | |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame^] | 175 | wget -q https://scan.coverity.com/download/linux64 --post-data "token=$TOKEN&project=$COVERITY_PROJECT" -O coverity-tools.tar.gz |
| 176 | mkdir coverity-tools |
| 177 | tar xzf coverity-tools.tar.gz --strip 1 -C coverity-tools |
| 178 | env: |
| 179 | TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }} |
| 180 | if: ${{ matrix.config.name == 'Coverity' }} |
| 181 | |
| 182 | - name: Deps-coverity-fix-permissions |
| 183 | run: | |
| 184 | chmod go-w $HOME |
| 185 | sudo chmod -R go-w /usr/share |
| 186 | if: ${{ matrix.config.name == 'Coverity' }} |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 187 | |
| 188 | - name: Configure |
| 189 | shell: bash |
| 190 | working-directory: ${{ github.workspace }} |
| 191 | run: | |
| 192 | mkdir build |
| 193 | cd build |
| 194 | CC=${{ matrix.config.cc }} cmake -DCMAKE_BUILD_TYPE=${{ matrix.config.build-type }} ${{ matrix.config.options }} .. |
| 195 | |
| 196 | - name: Build |
| 197 | shell: bash |
| 198 | working-directory: ${{ github.workspace }}/build |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame^] | 199 | run: | |
| 200 | export LC_ALL=C.UTF-8 |
| 201 | export PATH=/snap/bin:${{ github.workspace }}/coverity-tools/bin:$PATH |
| 202 | ${{ matrix.config.make-prepend }} make ${{ matrix.config.make-target }} |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 203 | |
| 204 | - name: Test |
| 205 | shell: bash |
| 206 | working-directory: ${{ github.workspace }}/build |
| 207 | run: ctest --output-on-failure |
| 208 | |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame^] | 209 | - name: Upload to Coverity.com |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 210 | shell: bash |
| 211 | working-directory: ${{ github.workspace }}/build |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 212 | run: | |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame^] | 213 | tar czvf libyang.tgz cov-int |
| 214 | curl \ |
| 215 | --form token=$TOKEN \ |
| 216 | --form email=mvasko@cesnet.cz \ |
| 217 | --form file=libyang.tgz \ |
| 218 | --form version="`./yanglint -v | cut -d\" \" -f2`" \ |
| 219 | --form description="libyang YANG library" \ |
| 220 | https://scan.coverity.com/builds?project=$COVERITY_PROJECT |
| 221 | env: |
| 222 | TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }} |
| 223 | 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] | 224 | |
Michal Vasko | d52860b | 2021-05-25 10:02:03 +0200 | [diff] [blame] | 225 | - name: Upload to Codecov.io |
Radek Krejci | f4d9729 | 2020-11-30 16:38:32 +0100 | [diff] [blame] | 226 | shell: bash |
| 227 | working-directory: ${{ github.workspace }}/build |
| 228 | run: bash <(curl -s https://codecov.io/bash) |
Michal Vasko | a217748 | 2021-05-28 10:29:41 +0200 | [diff] [blame^] | 229 | if: ${{ matrix.config.name == 'Codecov' && github.event_name == 'push' }} |