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