Skip to content

Commit

Permalink
Set up Circle CI (#206)
Browse files Browse the repository at this point in the history
* Add .circleci/config.yml

* Fix machine setup

* Set up CI build workflow

* Fix project directory

* Fix project directory, take 2

* Fix project directory, take 3

* Set up clang test, extract shared bits

* YAML fun time

* YAML fun time continued

* Add arm, fix static tests

* Add arm, take 2

* Set Up Bazel test

* Try osx runner

* Test dir state between run commands

* OSX setup with Homebrew

* Try codecov orb

* Try codecov orb, take 2

* Codecov runner, take 2
  • Loading branch information
PJK committed Mar 15, 2022
1 parent abb8d6e commit a453526
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 1 deletion.
109 changes: 109 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
version: 2.1

linux-setup: &linux-setup >
sudo apt-get update &&
sudo apt-get install -y gcc clang g++ cmake clang-format-8 cppcheck valgrind &&
sudo apt install libcmocka-dev

build-test: &build-test >
cmake -DWITH_TESTS=ON \
-DCBOR_CUSTOM_ALLOC=ON \
-DCMAKE_BUILD_TYPE=Debug \
-DSANITIZE=OFF \
. &&
make VERBOSE=1 &&
ctest -VV

orbs:
codecov: codecov/codecov@3.2.2
jobs:
static-test:
machine:
image: ubuntu-2004:202010-01
steps:
- checkout
- run: *linux-setup
- run: cppcheck . --error-exitcode=1
- run: bash clang-format.sh --verbose && git diff-index --quiet HEAD

build-and-test:
machine:
image: ubuntu-2004:202010-01
steps:
- checkout
- run: *linux-setup
- run: >
cmake -DWITH_TESTS=ON \
-DCBOR_CUSTOM_ALLOC=ON \
-DCMAKE_BUILD_TYPE=Debug \
-DSANITIZE=OFF \
-DCOVERAGE=ON \
.
- run: make VERBOSE=1
- run: ctest -VV
- run: ctest -T Coverage
- codecov/upload
# TODO: Reenable, currently fails on libjson leak (package out of date)
# The issue actually seems to be in the instrumentation code, not
# libcbor (we don't use libjsoncpp)
# https://github.com/open-source-parsers/jsoncpp/issues/507
# - run: >
# ctest --output-on-failure -T memcheck | tee memcheck.out
# if grep -q 'Memory Leak\|IPW\|Uninitialized Memory Conditional\|Uninitialized Memory Read' memcheck.out; then
# exit 1
# fi;

build-and-test-clang:
machine:
image: ubuntu-2004:202010-01
steps:
- checkout
- run: *linux-setup
- run: >
export CC=/usr/bin/clang
export CXX=/usr/bin/clang++
- run: *build-test

build-and-test-arm:
machine:
image: ubuntu-2004:202101-01
resource_class: arm.medium
steps:
- checkout
- run: *linux-setup
- run: *build-test

build-bazel:
machine:
image: ubuntu-2004:202101-01
steps:
- checkout
- run: *linux-setup
- run: sudo apt install apt-transport-https curl gnupg
- run: curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor > bazel.gpg
- run: sudo mv bazel.gpg /etc/apt/trusted.gpg.d/
- run: echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
- run: sudo apt update && sudo apt install bazel
- run: bazel --version
- run: >
pushd examples/bazel &&
bazel run -s src:hello
build-and-test-osx:
macos:
xcode: 12.5.1
steps:
- checkout
- run: bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- run: brew install cmocka cmake
- run: *build-test

workflows:
build-and-test:
jobs:
- static-test
- build-and-test
- build-and-test-clang
- build-and-test-arm
- build-and-test-osx
- build-bazel
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ add_custom_target(coverage
include_directories(src)


option(COVERAGE "Enable code coverage instrumentation" OFF)
option(c "Enable code coverage instrumentation" OFF)
if (COVERAGE)
message("Configuring code coverage instrumentation")
if(NOT CMAKE_C_COMPILER MATCHES "gcc")
Expand Down

0 comments on commit a453526

Please sign in to comment.