Skip to content

Commit

Permalink
Merge pull request #14 from koinos/pitchfork-sanitize
Browse files Browse the repository at this point in the history
Pitchfork sanitize
  • Loading branch information
sgerbino authored Mar 2, 2024
2 parents 9302fb2 + d38fd9a commit e821f75
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 94 deletions.
107 changes: 83 additions & 24 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ language: c++

cache:
ccache: true
pip: true

addons:
apt:
Expand All @@ -11,45 +10,105 @@ addons:
- clang
- clang-format
- llvm
- llvm-dev
- lcov
- ruby
- gcc-12
- g++-12

env:
global:
- CMAKE_C_COMPILER_LAUNCHER=ccache
- CMAKE_CXX_COMPILER_LAUNCHER=ccache

jobs:
include:
- os: linux
- name: "Static Analysis"
os: linux
dist: jammy
env:
- RUN_TYPE=static-analysis
- MATRIX_EVAL="CC=clang && CXX=clang++"
- os: linux
- CC=clang
- CXX=clang++
before_script:
- cmake -DCMAKE_BUILD_TYPE=Debug -DSTATIC_ANALYSIS=ON .
script:
- cmake --build . --config Debug --parallel 3

- name: "Sanitizer"
os: linux
dist: jammy
env:
- RUN_TYPE=coverage
- MATRIX_EVAL="CC=clang && CXX=clang++"
- os: linux
- CC=clang
- CXX=clang++
before_script:
- mkdir build-address
- pushd build-address
- cmake -DCMAKE_BUILD_TYPE=Debug -DSANITIZER=Address ..
- cmake --build . --config Debug --parallel 3
- popd
- mkdir build-stack
- pushd build-stack
- cmake -DCMAKE_BUILD_TYPE=Debug -DSANITIZER=Stack ..
- cmake --build . --config Debug --parallel 3
- popd
- mkdir build-thread
- pushd build-thread
- cmake -DCMAKE_BUILD_TYPE=Debug -DSANITIZER=Thread ..
- cmake --build . --config Debug --parallel 3
- popd
script:
- pushd build-address/tests
- ctest -j1 --output-on-failure
- popd
- pushd build-stack/tests
- ctest -j1 --output-on-failure
- popd
- pushd build-thread/tests
- ctest -j1 --output-on-failure

- name: "Coverage"
os: linux
dist: jammy
env:
- RUN_TYPE=test
- MATRIX_EVAL="CC=gcc-12 && CXX=g++-12"
- os: linux
- CC=clang
- CXX=clang++
install:
- sudo gem install coveralls-lcov
before_script:
- mkdir build
- cd build
- cmake -DCMAKE_BUILD_TYPE=Debug -DCOVERAGE=ON ..
script:
- cmake --build . --config Debug --parallel 3 --target coverage
after_success:
- coveralls-lcov --repo-token $COVERALLS_REPO_TOKEN --service-name travis-pro --service-job-id $TRAVIS_JOB_ID ./coverage.info

- name: "GCC Unit Tests"
os: linux
dist: jammy
env:
- RUN_TYPE=test
- MATRIX_EVAL="CC=clang && CXX=clang++"

before_install:
- eval "${MATRIX_EVAL}"
- CC=gcc-12
- CXX=g++-12
before_script:
- cmake -DCMAKE_BUILD_TYPE=Release .
- cmake --build . --config Release --parallel 3
script:
- cd tests
- ctest -j3 --output-on-failure

install:
- tools/ci/install.sh

script:
- tools/ci/build.sh && tools/ci/test.sh

after_success:
- tools/ci/after_success.sh
- name: "Clang Unit Tests and Formatting"
os: linux
dist: jammy
env:
- CC=clang
- CXX=clang++
before_script:
- cmake -DCMAKE_BUILD_TYPE=Release .
- cmake --build . --config Release --parallel 3
script:
- cmake --build . --config Release --parallel 3 --target format.check
- cd tests
- ctest -j3 --output-on-failure

notifications:
slack:
Expand Down
13 changes: 2 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
cmake_minimum_required(VERSION 3.19.0)

cmake_policy(SET CMP0074 NEW)
cmake_policy(SET CMP0114 NEW)

if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.24.0)
cmake_policy(SET CMP0135 NEW)
endif()

if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.27.0)
cmake_policy(SET CMP0144 NEW)
endif()
cmake_policy(VERSION 3.19.0...3.27.4)

include(FetchContent)
FetchContent_Declare(
koinos_cmake
GIT_REPOSITORY https://github.com/koinos/koinos-cmake.git
GIT_TAG 1d4961057ac9a99be8a1e21d6383475ee9a430d5
GIT_TAG 897f11188f1761ddd810d77839417549e68465aa
)
FetchContent_MakeAvailable(koinos_cmake)

Expand Down
30 changes: 18 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,12 @@ Pull requests should be submitted to [Koinos Proto Pull Requests](https://github

This project's structure follows the [Pitchfork](https://api.csswg.org/bikeshed/?force=1&url=https://raw.githubusercontent.com/vector-of-bool/pitchfork/develop/data/spec.bs) specification.

**`build`**: An ephemeral directory for building the project. Not checked in, but excluded via `.gitignore`.

**`include`**: Contains all public headers for the Koinos Proto.

**`src`**: Contains all source code and private headers for Koinos Proto.

**`tests`**: Contains tests for Koinos Proto.

**`tools`**: Contains additional tooling for Koinos Proto, primarily CI scripts.
```
├── build/ # An ephemeral directory for building the project. Not checked in, but excluded via .gitignore.
├── include/ # Contains all public headers for the Koinos Proto.
├── src/ # Contains all source code and private headers for Koinos Proto.
└── tests/ # Contains tests for Koinos Proto.
```

### Building

Expand All @@ -39,17 +36,17 @@ cmake -D CMAKE_BUILD_TYPE=Release -D STATIC_ANALYSIS=ON ..

### Testing

Tests are built by default as target `koinos_proto_tests`. You can building them specifically with:
Tests are built by default as target `proto_tests`. You can building them specifically with:

```
cmake --build . --config Release --parallel --target koinos_proto_tests
cmake --build . --config Release --parallel --target proto_tests
```

Tests can be invoked from the tests directiory within the build directory.

```
cd tests
./koinos_proto_tests
./proto_tests
```

Tests can also be ran in parallel using CTest.
Expand All @@ -66,6 +63,15 @@ cmake -D CMAKE_BUILD_TYPE=Debug -D COVERAGE=ON ..
cmake --build . --config Debug --parallel 3 --target coverage
```

You can run tests in different sanitizer profiles. Those profiles are None (Default), Address, Stack, and Thread. Currently, these are only known to work with clang, but may work with gcc with additional environment configuration.

```
cmake -D CMAKE_BUILD_TYPE=Debug -D SANITIZER=Address ..
cmake --build . --config Debug --parallel --target proto_tests
cd tests
ctest -j
```

### Formatting

Formatting of the source code is enforced by ClangFormat. If ClangFormat is installed, build targets will be automatically generated. You can review the library's code style by uploading the included `.clang-format` to https://clang-format-configurator.site/.
Expand Down
6 changes: 0 additions & 6 deletions tools/ci/after_success.sh

This file was deleted.

18 changes: 0 additions & 18 deletions tools/ci/build.sh

This file was deleted.

3 changes: 0 additions & 3 deletions tools/ci/ccache_clang

This file was deleted.

3 changes: 0 additions & 3 deletions tools/ci/ccache_clang++

This file was deleted.

5 changes: 0 additions & 5 deletions tools/ci/install.sh

This file was deleted.

12 changes: 0 additions & 12 deletions tools/ci/test.sh

This file was deleted.

0 comments on commit e821f75

Please sign in to comment.