Skip to content

Commit

Permalink
added github actions support
Browse files Browse the repository at this point in the history
  • Loading branch information
deftio committed Aug 7, 2024
1 parent 7f0c8a3 commit 0dedc25
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 5 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:
strategy:
matrix:
compiler: [clang, gcc]

runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install LCOV
run: |
sudo apt-get update
sudo apt-get install -y lcov
- name: Install coveralls-lcov
run: |
gem install coveralls-lcov
- name: Set up compiler ${{ matrix.compiler }}
run: sudo apt-get install -y ${{ matrix.compiler }}

- name: Zero counters
run: lcov --directory . --zerocounters

- name: Build and run tests
run: |
make
./test-library.out
- name: Capture coverage info
run: lcov --directory . --capture --output-file coverage.info

- name: Filter out system and test code
run: lcov --remove coverage.info 'tests/*' '/usr/*' 'test-library*' --output-file coverage.info

- name: List coverage info
run: lcov --list coverage.info

- name: Upload coverage to Coveralls
run: coveralls-lcov coverage.info
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,13 @@

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

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.
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.

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



copyright (C) <2016 and onward> <M. A. Chatterjee> <deftio [at] deftio [dot] com>
version 1.0.2 (updated for travis-ci.com transition) M. A. Chatterjee


## Features

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.
Expand Down Expand Up @@ -215,3 +211,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.



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

0 comments on commit 0dedc25

Please sign in to comment.