Skip to content

Commit

Permalink
Code coverage reporting added to Actions workflow (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
vvish committed Nov 17, 2020
1 parent 045541d commit 186684c
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,7 @@ jobs:
- uses: actions/checkout@v2
- name: Build
run: make
- name: Run tests
run: make test
- name: Run tests and produce code coverage
run: make code-coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,12 @@
*.app

# Executable dir
bin/
bin/

# Coverage dir
coverage/

# Coverage/profiling artifacts
*.gcda
*.gcno
*.gcov
18 changes: 15 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ EXAMPLE_DIR = examples
CXX_FLAGS = -std=c++17 -Iinclude
OUT_DIR = bin

COVERAGE_CXX_FLAGS = -O0 --coverage
COVERAGE_DIR = coverage

code-coverage: CXX_FLAGS += $(COVERAGE_CXX_FLAGS)

$(TEST_TARGETS): % : $(TEST_DIR)/%.cpp
mkdir -p $(OUT_DIR)
g++ $(CXX_FLAGS) -o $(OUT_DIR)/$@ $< $(TEST_LIBS)
Expand All @@ -19,8 +24,15 @@ $(EXAMPLE_TARGETS): % : $(EXAMPLE_DIR)/%.cpp
test: $(TEST_TARGETS)
./$(OUT_DIR)/$<

code-coverage: $(TEST_TARGETS)
./$(OUT_DIR)/$<
mkdir -p $(COVERAGE_DIR)
mv *.gcda *.gcno $(COVERAGE_DIR)

clean:
rm $(addprefix $(OUT_DIR)/, $(TEST_TARGETS))
rm -f $(addprefix $(OUT_DIR)/, $(TEST_TARGETS))
rmdir --ignore-fail-on-non-empty $(OUT_DIR)

.PHONY: test clean
rm -f $(addprefix $(COVERAGE_DIR)/, *.gcda *.gcno)
rmdir --ignore-fail-on-non-empty $(COVERAGE_DIR)

.PHONY: test code-coverage clean
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# The minimalist error handling framework

[![codecov](https://codecov.io/gh/vvish/cpp_result/branch/master/graph/badge.svg)](https://codecov.io/gh/vvish/cpp_result)

## Motivation

The framework makes an attempt to provide resource efficient ways to define
Expand Down

0 comments on commit 186684c

Please sign in to comment.