Skip to content

Commit d5f4dc1

Browse files
sleepdefic1tfaustbrian
authored andcommitted
ci: add coverage workflow (#163)
1 parent 8e27d3d commit d5f4dc1

6 files changed

Lines changed: 96 additions & 16 deletions

File tree

.codeclimate.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
1+
version: "2"
12
plugins:
23
cppcheck:
34
enabled: true
5+
config:
6+
check: all
7+
language: c++
8+
stds:
9+
- c++11
10+
includes:
11+
- src/
12+
- src/include/cpp-crypto
413
exclude_patterns:
5-
- "src/lib/"
6-
- "test/"
14+
- "src/lib/"
15+
- "extern/"
16+
- "test/"

.github/workflows/coverage.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Coverage
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
- 'develop'
8+
pull_request:
9+
types: [ready_for_review, synchronize, opened]
10+
11+
jobs:
12+
codeclimate:
13+
runs-on: macOS-latest
14+
15+
steps:
16+
- uses: actions/checkout@v1
17+
- name: Set compiler to clang++
18+
run: COMPILER=clang++
19+
- name: Install Dependencies
20+
run: brew install cmake lcov
21+
- name: Make scripts executable
22+
run: sudo chmod +x ./.github/workflows/test/clang_tidy.sh
23+
- name: Setup Code Climate test-reporter
24+
run: |
25+
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-darwin-amd64 > ./cc-test-reporter
26+
chmod +x ./cc-test-reporter
27+
- name: Build & Run Coverage Tests
28+
run: |
29+
./cc-test-reporter before-build
30+
cmake -DCMAKE_BUILD_TYPE=Coverage -DUNIT_TEST=ON .
31+
cmake --build .
32+
./test/ark_cpp_crypto_tests
33+
lcov --directory . --include "*/src/*" --include "*/test/*" --exclude "*/src/lib/*" --exclude "*/extern/*" --capture --output-file coverage.info --ignore-errors gcov
34+
./cc-test-reporter format-coverage --input-type lcov coverage.info
35+
./cc-test-reporter upload-coverage
36+
env:
37+
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
38+
39+
codecov:
40+
runs-on: ubuntu-latest
41+
42+
steps:
43+
- uses: actions/checkout@v1
44+
- name: Install Dependencies
45+
run: |
46+
sudo apt-add-repository -y ppa:ubuntu-toolchain-r/test
47+
sudo apt-get update
48+
sudo apt-get -y install g++-7 gcc-7 lcov
49+
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 60 --slave /usr/bin/g++ g++ /usr/bin/g++-7
50+
sudo update-alternatives --config gcc
51+
- name: Create Build directory
52+
run: mkdir build
53+
- name: Build
54+
run: |
55+
cd build
56+
cmake -DCMAKE_BUILD_TYPE=Coverage -DUNIT_TEST=ON ..
57+
cmake --build .
58+
- name: Run Coverage Tests
59+
run: ./build/test/ark_cpp_crypto_tests
60+
- name: Upload Coverage Report
61+
run: bash <(curl -s https://codecov.io/bash) -t ${{ secrets.CODECOV_TOKEN }}

.github/workflows/test.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ name: Test
33
on:
44
push:
55
branches:
6-
- "**"
6+
- 'master'
7+
- 'develop'
78
pull_request:
8-
types: [ready_for_review, synchronize, opened] # fix: synchronize triggers builds for PR merges with the base branch, currently causes duplicate builds as synchronize is treated the same as push for everything besides merges
9+
types: [ready_for_review, synchronize, opened]
910

1011
jobs:
1112
arduino:
@@ -43,18 +44,16 @@ jobs:
4344
run: |
4445
sudo apt-add-repository -y ppa:ubuntu-toolchain-r/test
4546
sudo apt-get update
46-
sudo apt-get -y install g++-7 gcc-7 lcov
47+
sudo apt-get -y install g++-7 gcc-7
4748
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 60 --slave /usr/bin/g++ g++ /usr/bin/g++-7
4849
sudo update-alternatives --config gcc
4950
- name: Build
5051
run: |
5152
mkdir build && cd build
52-
cmake -DCMAKE_BUILD_TYPE=Coverage -DUNIT_TEST=ON ..
53+
cmake -DUNIT_TEST=ON ..
5354
cmake --build .
5455
- name: Run Tests
5556
run: ./build/test/ark_cpp_crypto_tests
56-
- name: Codecov upload
57-
run: bash <(curl -s https://codecov.io/bash) -t ${{ secrets.CODECOV_TOKEN }}
5857

5958
linux-clang-5:
6059
runs-on: ubuntu-latest
@@ -64,7 +63,7 @@ jobs:
6463
- name: Install Dependencies
6564
run: |
6665
sudo apt-get update
67-
sudo apt install liblldb-5.0-dev python-lldb-5.0 lcov
66+
sudo apt install liblldb-5.0-dev python-lldb-5.0
6867
sudo apt install clang-5.0 clang-tidy-5.0 clang-format-5.0 clang-5.0-doc libclang-common-5.0-dev libclang-5.0-dev libclang1-5.0 libllvm5.0 lldb-5.0 llvm-5.0 llvm-5.0-dev
6968
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/clang-5.0 60
7069
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 50
@@ -116,4 +115,4 @@ jobs:
116115
shell: cmd
117116
run: msbuild "%GITHUB_WORKSPACE%\ark_cpp_crypto.sln"
118117
- name: Run Tests
119-
run: call "%GITHUB_WORKSPACE%\test\Debug\ark_cpp_crypto_tests"
118+
run: call "%GITHUB_WORKSPACE%\test\Debug\ark_cpp_crypto_tests"

CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ endif()
2828

2929
# ------------------------------------------------------------------------------
3030

31+
# ------------------------------------------------------------------------------
32+
# Coverage 1:2
33+
# ------------------------------------------------------------------------------
34+
35+
if (CMAKE_BUILD_TYPE STREQUAL "Coverage")
36+
add_definitions(-Wno-unused-command-line-argument)
37+
endif() #CMAKE_BUILD_TYPE STREQUAL "Coverage"
38+
39+
# ------------------------------------------------------------------------------
40+
3141
# ------------------------------------------------------------------------------
3242
# Clang Tidy
3343
# ------------------------------------------------------------------------------

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66

77
> A simple Cryptography Implementation in C++ for the Ark Blockchain.
88
9-
[![Build Status](https://badgen.now.sh/circleci/github/ArkEcosystem/cpp-crypto)](https://circleci.com/gh/ArkEcosystem/cpp-crypto)
10-
[![Codecov](https://badgen.now.sh/codecov/c/github/arkecosystem/cpp-crypto)](https://codecov.io/gh/arkecosystem/cpp-crypto)
11-
[![Latest Version](https://badgen.now.sh/github/release/ArkEcosystem/cpp-crypto)](https://github.com/ArkEcosystem/cpp-crypto/releases)
12-
[![License: MIT](https://badgen.now.sh/badge/license/MIT/green)](https://opensource.org/licenses/MIT)
9+
[![Test Actions](https://github.com/ArkEcosystem/cpp-crypto/workflows/Test/badge.svg)](https://github.com/ArkEcosystem/cpp-crypto/actions)
10+
[![Coverage Actions](https://github.com/ArkEcosystem/cpp-crypto/workflows/Coverage/badge.svg)](https://github.com/ArkEcosystem/cpp-crypto/actions)
11+
[![Latest Version](https://badgen.now.sh/github/release/ArkEcosystem/cpp-crypto?labelColor=black)](https://github.com/ArkEcosystem/cpp-crypto/releases)
12+
[![License: MIT](https://badgen.now.sh/badge/license/MIT/green?labelColor=black)](https://opensource.org/licenses/MIT)
1313

1414
> Lead Maintainer: [Simon Downey](https://github.com/sleepdefic1t)
1515

test/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,13 @@ add_test(NAME test COMMAND ${PROJECT_NAME})
127127
# ------------------------------------------------------------------------------
128128

129129
# ------------------------------------------------------------------------------
130-
# Coverage
130+
# Coverage 2:2
131131
# ------------------------------------------------------------------------------
132132

133133
if (CMAKE_BUILD_TYPE STREQUAL "Coverage")
134134
include("${CMAKE_SOURCE_DIR}/cmake/CodeCoverage.cmake")
135135

136-
setup_target_for_coverage(${PROJECT_NAME}_coverage ${PROJECT_NAME}_tests coverage)
136+
setup_target_for_coverage(${PROJECT_NAME}_coverage ${PROJECT_NAME} coverage)
137137

138138
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")
139139
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")

0 commit comments

Comments
 (0)