blob: b6dc78f9900c52de3708157a56ac9a74163b0438 [file] [log] [blame]
Radek Krejcif4d97292020-11-30 16:38:32 +01001name: libyang CI
Michal Vasko8bdbf852021-04-14 16:19:17 +02002on:
Radek Krejcif4d97292020-11-30 16:38:32 +01003 push:
4 branches:
Michal Vasko0791e802021-05-27 10:29:14 +02005 - master
6 - devel
Radek Krejcif4d97292020-11-30 16:38:32 +01007 pull_request:
8 branches:
Michal Vasko0791e802021-05-27 10:29:14 +02009 - master
10 - devel
Radek Krejcif4d97292020-11-30 16:38:32 +010011
Michal Vaskoa2177482021-05-28 10:29:41 +020012env:
13 COVERITY_PROJECT: CESNET%2Flibyang
14
Radek Krejcif4d97292020-11-30 16:38:32 +010015jobs:
Michal Vaskoa2177482021-05-28 10:29:41 +020016 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 Krejcif4d97292020-11-30 16:38:32 +010030 build:
31 name: ${{ matrix.config.name }}
32 runs-on: ${{ matrix.config.os }}
Michal Vaskoa2177482021-05-28 10:29:41 +020033 needs: git-branch
Radek Krejcif4d97292020-11-30 16:38:32 +010034 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 Vaskoa2177482021-05-28 10:29:41 +020045 packages: "libcmocka-dev shunit2",
46 snaps: "",
47 make-prepend: "",
48 make-target: ""
Radek Krejcif4d97292020-11-30 16:38:32 +010049 }
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 Vaskoa2177482021-05-28 10:29:41 +020057 packages: "libcmocka-dev shunit2",
58 snaps: "",
59 make-prepend: "",
60 make-target: ""
Radek Krejcif4d97292020-11-30 16:38:32 +010061 }
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 Vaskoa2177482021-05-28 10:29:41 +020069 packages: "libcmocka-dev valgrind shunit2",
70 snaps: "",
71 make-prepend: "",
72 make-target: ""
Radek Krejcif4d97292020-11-30 16:38:32 +010073 }
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 Vaskoa2177482021-05-28 10:29:41 +020081 packages: "libcmocka-dev valgrind shunit2",
82 snaps: "",
83 make-prepend: "",
84 make-target: ""
Radek Krejcif4d97292020-11-30 16:38:32 +010085 }
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 Vaskoa2177482021-05-28 10:29:41 +020093 packages: "cmocka shunit2",
94 snaps: "",
95 make-prepend: "",
96 make-target: ""
Radek Krejcif4d97292020-11-30 16:38:32 +010097 }
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 Vaskoa2177482021-05-28 10:29:41 +0200105 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 Vaskob5043682021-05-28 10:33:24 +0200116 packager: "sudo apt-get",
Michal Vaskoa2177482021-05-28 10:29:41 +0200117 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 Vaskob5043682021-05-28 10:33:24 +0200128 packager: "sudo apt-get",
Michal Vaskoa2177482021-05-28 10:29:41 +0200129 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 Vaskob5043682021-05-28 10:33:24 +0200140 packager: "sudo apt-get",
Michal Vaskoa2177482021-05-28 10:29:41 +0200141 packages: "libcmocka-dev lcov",
142 snaps: "",
143 make-prepend: "",
144 make-target: ""
Radek Krejcif4d97292020-11-30 16:38:32 +0100145 }
146
147 steps:
148 - uses: actions/checkout@v2
149
Michal Vaskoa2177482021-05-28 10:29:41 +0200150 - 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 Vasko8bdbf852021-04-14 16:19:17 +0200162 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 Vaskoa2177482021-05-28 10:29:41 +0200174 - name: Deps-coverity
Radek Krejcif4d97292020-11-30 16:38:32 +0100175 shell: bash
Michal Vaskoa2177482021-05-28 10:29:41 +0200176 working-directory: ${{ github.workspace }}
Radek Krejcif4d97292020-11-30 16:38:32 +0100177 run: |
Michal Vaskoa2177482021-05-28 10:29:41 +0200178 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
Radek Krejcif4d97292020-11-30 16:38:32 +0100185 - name: Configure
186 shell: bash
187 working-directory: ${{ github.workspace }}
188 run: |
189 mkdir build
190 cd build
191 CC=${{ matrix.config.cc }} cmake -DCMAKE_BUILD_TYPE=${{ matrix.config.build-type }} ${{ matrix.config.options }} ..
192
193 - name: Build
194 shell: bash
195 working-directory: ${{ github.workspace }}/build
Michal Vaskoa2177482021-05-28 10:29:41 +0200196 run: |
197 export LC_ALL=C.UTF-8
198 export PATH=/snap/bin:${{ github.workspace }}/coverity-tools/bin:$PATH
199 ${{ matrix.config.make-prepend }} make ${{ matrix.config.make-target }}
Radek Krejcif4d97292020-11-30 16:38:32 +0100200
201 - name: Test
202 shell: bash
203 working-directory: ${{ github.workspace }}/build
204 run: ctest --output-on-failure
205
Michal Vaskoa2177482021-05-28 10:29:41 +0200206 - name: Upload to Coverity.com
Radek Krejcif4d97292020-11-30 16:38:32 +0100207 shell: bash
208 working-directory: ${{ github.workspace }}/build
Radek Krejcif4d97292020-11-30 16:38:32 +0100209 run: |
Michal Vaskoa2177482021-05-28 10:29:41 +0200210 tar czvf libyang.tgz cov-int
211 curl \
212 --form token=$TOKEN \
213 --form email=mvasko@cesnet.cz \
214 --form file=libyang.tgz \
215 --form version="`./yanglint -v | cut -d\" \" -f2`" \
216 --form description="libyang YANG library" \
217 https://scan.coverity.com/builds?project=$COVERITY_PROJECT
218 env:
219 TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}
220 if: ${{ matrix.config.name == 'Coverity' && github.event_name == 'push' && needs.git-branch.outputs.branch-name == 'devel' }}
Radek Krejcif4d97292020-11-30 16:38:32 +0100221
Michal Vaskod52860b2021-05-25 10:02:03 +0200222 - name: Upload to Codecov.io
Radek Krejcif4d97292020-11-30 16:38:32 +0100223 shell: bash
224 working-directory: ${{ github.workspace }}/build
225 run: bash <(curl -s https://codecov.io/bash)
Michal Vaskoa2177482021-05-28 10:29:41 +0200226 if: ${{ matrix.config.name == 'Codecov' && github.event_name == 'push' }}