xref: /freebsd/contrib/libcbor/.circleci/config.yml (revision 089104e0e01f080c9cd45dc5f34c4f636dea4ca7)
1version: 2.1
2
3commands:
4  linux-setup:
5    steps:
6    - run: sudo apt-get update
7    - run: sudo apt-get install -y cmake ${TOOLCHAIN_PACKAGES}
8    - run: sudo apt install libcmocka-dev
9  build:
10    steps:
11    - run: >
12        cmake -DWITH_TESTS=ON \
13          -DCMAKE_BUILD_TYPE=Debug \
14          -DSANITIZE=OFF \
15          -DCOVERAGE="${CMAKE_COVERAGE:='OFF'}" \
16          .
17    - run: make -j 16 VERBOSE=1
18  build-release:
19    steps:
20    - run: >
21        cmake -DWITH_TESTS=ON \
22          -DCMAKE_BUILD_TYPE=Release \
23          .
24    - run: make -j 16 VERBOSE=1
25  test:
26    steps:
27    - run: ctest -VV
28
29orbs:
30  codecov: codecov/codecov@3.2.2
31
32jobs:
33  static-test:
34    machine:
35      image: ubuntu-2204:2022.10.2
36    environment:
37      TOOLCHAIN_PACKAGES: g++
38    steps:
39      - checkout
40      - linux-setup
41      - run: sudo apt-get install -y clang-format doxygen cppcheck
42      - run: cppcheck --inline-suppr --error-exitcode=1 .
43      - run: bash clang-format.sh --verbose
44      - run: >
45          if ! $(git diff-index --quiet HEAD); then
46            echo "Code formatting doesn't conform to clang-format"
47            echo "Please run clang-format.sh, commit the diff, and push to re-run CI"
48            echo "Excerpt of the diff follows"
49            git diff | head -n 20
50          fi
51      - run: >
52          if doxygen Doxyfile | grep 'warning: '; then
53            echo "Doxygen warning (see above) -- misformatted docs?"
54            exit 1
55          fi
56      - run: >
57          cd doc &&
58          pip3 install -r source/requirements.txt &&
59          make html
60
61  build-and-test:
62    machine:
63      image: ubuntu-2204:2022.10.2
64    environment:
65      TOOLCHAIN_PACKAGES: g++
66      CMAKE_COVERAGE: ON
67    steps:
68      - checkout
69      - linux-setup
70      - run: sudo apt-get install -y valgrind
71      - build
72      - test
73      - run: ctest -T Coverage
74      - codecov/upload
75      - run: ctest --output-on-failure -T memcheck | tee memcheck.out
76      - run: >
77          if grep -q 'Memory Leak\|IPW\|Uninitialized Memory Conditional\|Uninitialized Memory Read' memcheck.out; then
78            cat Testing/Temporary/MemoryChecker*
79            exit 1
80          fi;
81
82  build-and-test-clang:
83    machine:
84      image: ubuntu-2204:2022.10.2
85    environment:
86      TOOLCHAIN_PACKAGES: clang
87      CC: clang
88      CXX: clang++
89    steps:
90      - checkout
91      - linux-setup
92      - build
93      - test
94
95  build-and-test-32b:
96    machine:
97      image: ubuntu-2204:2022.10.2
98    steps:
99      - checkout
100      - run: sudo apt-get update
101      - run: sudo apt-get install -y cmake gcc-multilib g++-multilib libc6-dev-i386
102      # Make cmocka from source w/ 32b setup
103      - run: git clone https://git.cryptomilk.org/projects/cmocka.git ~/cmocka
104      - run: >
105          cd $(mktemp -d /tmp/build.XXXX) &&
106          cmake ~/cmocka -DCMAKE_TOOLCHAIN_FILE=~/cmocka/cmake/Toolchain-cross-m32.cmake &&
107          make &&
108          sudo make install
109      # Piggyback on the cmocka 32b toolchain
110      - run: >
111          cmake -DWITH_TESTS=ON \
112            -DCMAKE_BUILD_TYPE=Debug \
113            -DCMAKE_TOOLCHAIN_FILE=~/cmocka/cmake/Toolchain-cross-m32.cmake \
114            .
115      - run: make -j 16 VERBOSE=1
116      - test
117
118  build-and-test-release-clang:
119    machine:
120      image: ubuntu-2204:2022.10.2
121    environment:
122      TOOLCHAIN_PACKAGES: clang
123      CC: clang
124      CXX: clang++
125    steps:
126      - checkout
127      - linux-setup
128      - build-release
129      - test
130
131  llvm-coverage:
132    machine:
133      image: ubuntu-2204:2022.10.2
134    environment:
135      TOOLCHAIN_PACKAGES: clang
136      CC: clang
137      CXX: clang++
138      CMAKE_COVERAGE: ON
139    steps:
140      - checkout
141      - linux-setup
142      - build
143      - run: make llvm-coverage
144
145
146  build-and-test-arm:
147    machine:
148      image: ubuntu-2204:2022.10.2
149    environment:
150      TOOLCHAIN_PACKAGES: g++
151    resource_class: arm.medium
152    steps:
153      - checkout
154      - linux-setup
155      - build
156      - test
157
158  build-bazel:
159    machine:
160      image: ubuntu-2204:2022.10.2
161    environment:
162      TOOLCHAIN_PACKAGES: g++
163    steps:
164      - checkout
165      - linux-setup
166      - run: sudo apt install apt-transport-https curl gnupg
167      - run: curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor > bazel.gpg
168      - run: sudo mv bazel.gpg /etc/apt/trusted.gpg.d/
169      - run: echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
170      - run: sudo apt update
171      - run: sudo apt install bazel
172      - run: bazel --version
173      - run: >
174          pushd examples/bazel &&
175          bazel run -s src:hello
176
177  build-and-test-osx:
178    macos:
179      xcode: 12.5.1
180    steps:
181      - checkout
182      - run: bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
183      - run: brew install cmocka cmake
184      - build
185      - test
186
187
188  build-and-test-win:
189    resource_class: 'windows.medium'
190    machine:
191      image: 'windows-server-2022-gui:current'
192      shell: 'bash.exe'
193    steps:
194      - checkout
195      - run: choco install cmake -y
196      - run: git clone https://git.cryptomilk.org/projects/cmocka.git
197      - run: cd cmocka && git checkout tags/cmocka-1.1.5
198      - run: /c/Program\ Files/Cmake/bin/cmake -S cmocka -B cmocka_build
199      - run: /c/Program\ Files/Cmake/bin/cmake --build cmocka_build
200      - run: /c/Program\ Files/Cmake/bin/cmake -S . -B libcbor_build -DWITH_TESTS=ON -DCMOCKA_INCLUDE_DIR=cmocka/include -DCMOCKA_LIBRARIES=$(pwd)/cmocka_build/src/Debug/cmocka.lib
201      - run: /c/Program\ Files/Cmake/bin/cmake --build libcbor_build
202      - run: >
203          export PATH="$(pwd)/cmocka_build/src/Debug/:$PATH" &&
204          /c/Program\ Files/Cmake/bin/ctest.exe --test-dir libcbor_build --output-on-failure
205
206workflows:
207  build-and-test:
208    jobs:
209      - static-test
210      - build-and-test
211      - build-and-test-clang
212      - build-and-test-32b
213      - build-and-test-release-clang
214      - build-and-test-arm
215      - build-and-test-win
216      - build-bazel
217      - llvm-coverage
218      # OSX builds are expensive, run only on master
219      - build-and-test-osx:
220          requires:
221            - build-and-test
222          filters:
223            branches:
224              only: [master]
225