Skip to content

Commit 0dedc25

Browse files
committed
added github actions support
1 parent 7f0c8a3 commit 0dedc25

File tree

2 files changed

+56
-5
lines changed

2 files changed

+56
-5
lines changed

.github/workflows/ci.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build:
11+
strategy:
12+
matrix:
13+
compiler: [clang, gcc]
14+
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v2
20+
21+
- name: Install LCOV
22+
run: |
23+
sudo apt-get update
24+
sudo apt-get install -y lcov
25+
26+
- name: Install coveralls-lcov
27+
run: |
28+
gem install coveralls-lcov
29+
30+
- name: Set up compiler ${{ matrix.compiler }}
31+
run: sudo apt-get install -y ${{ matrix.compiler }}
32+
33+
- name: Zero counters
34+
run: lcov --directory . --zerocounters
35+
36+
- name: Build and run tests
37+
run: |
38+
make
39+
./test-library.out
40+
41+
- name: Capture coverage info
42+
run: lcov --directory . --capture --output-file coverage.info
43+
44+
- name: Filter out system and test code
45+
run: lcov --remove coverage.info 'tests/*' '/usr/*' 'test-library*' --output-file coverage.info
46+
47+
- name: List coverage info
48+
run: lcov --list coverage.info
49+
50+
- name: Upload coverage to Coveralls
51+
run: coveralls-lcov coverage.info

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,13 @@
44

55
# Simple Example for C/C++ Testing with CI/CD
66

7-
This repo covers setting up a basic testing suite with github badges for a C/C++ library. Its not meant to be deep tutorial on testing but just cover some basics of setting up unit tests, coverage tests, and continuous integration (in this case using Travis-CI). The repo doesn't have a lot of code - there is a simple library which is tested for coverage and integration.
7+
This repo covers setting up a basic testing suite with github badges for a C/C++ library. Its not meant to be deep tutorial on testing but just cover some basics of setting up unit tests, coverage tests, and continuous integration (in this case using either GitHub Actions or Travis-CI). The repo doesn't have a lot of code - there is a simple library which is tested for coverage and integration.
88

99
### Motivation
1010
I just wanted to make a small standalone test project to see tools and workflow for C (or C++) language testing.
1111

1212

1313

14-
copyright (C) <2016 and onward> <M. A. Chatterjee> <deftio [at] deftio [dot] com>
15-
version 1.0.2 (updated for travis-ci.com transition) M. A. Chatterjee
16-
17-
1814
## Features
1915

2016
The lib.h / lib.c files are broken out as examples of testing an embedded library. Most of the projects I work on are for embedded systems so I wanted a way to get a build badge for these embedded projects. Since many of those compilers and environments are not on Linux I wanted just a simple abstraction of how the Travis build project works without all the complexities of a "real" project.
@@ -215,3 +211,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
215211
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
216212

217213

214+
215+
copyright (C) <2016 and onward> <M. A. Chatterjee> <deftio [at] deftio [dot] com>
216+
version 1.0.3 (added github actions support)
217+
version 1.0.2 (updated for travis-ci.com transition) M. A. Chatterjee

0 commit comments

Comments
 (0)