blob: fb21f667362176c3e932f8fbb69447238a36c84a [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: "",
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 Krejcif4d97292020-11-30 16:38:32 +0100142 }
143
144 steps:
145 - uses: actions/checkout@v2
146
Michal Vaskoa2177482021-05-28 10:29:41 +0200147 - 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 Vasko8bdbf852021-04-14 16:19:17 +0200159 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 Vaskoa2177482021-05-28 10:29:41 +0200171 - name: Deps-coverity
Radek Krejcif4d97292020-11-30 16:38:32 +0100172 shell: bash
Michal Vaskoa2177482021-05-28 10:29:41 +0200173 working-directory: ${{ github.workspace }}
Radek Krejcif4d97292020-11-30 16:38:32 +0100174 run: |
Michal Vaskoa2177482021-05-28 10:29:41 +0200175 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 Krejcif4d97292020-11-30 16:38:32 +0100187
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 Vaskoa2177482021-05-28 10:29:41 +0200199 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 Krejcif4d97292020-11-30 16:38:32 +0100203
204 - name: Test
205 shell: bash
206 working-directory: ${{ github.workspace }}/build
207 run: ctest --output-on-failure
208
Michal Vaskoa2177482021-05-28 10:29:41 +0200209 - name: Upload to Coverity.com
Radek Krejcif4d97292020-11-30 16:38:32 +0100210 shell: bash
211 working-directory: ${{ github.workspace }}/build
Radek Krejcif4d97292020-11-30 16:38:32 +0100212 run: |
Michal Vaskoa2177482021-05-28 10:29:41 +0200213 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 Krejcif4d97292020-11-30 16:38:32 +0100224
Michal Vaskod52860b2021-05-25 10:02:03 +0200225 - name: Upload to Codecov.io
Radek Krejcif4d97292020-11-30 16:38:32 +0100226 shell: bash
227 working-directory: ${{ github.workspace }}/build
228 run: bash <(curl -s https://codecov.io/bash)
Michal Vaskoa2177482021-05-28 10:29:41 +0200229 if: ${{ matrix.config.name == 'Codecov' && github.event_name == 'push' }}