From 0dedc25861d5ea4cd63cc8e789251dfc8e40784b Mon Sep 17 00:00:00 2001 From: deftio Date: Wed, 7 Aug 2024 12:17:49 -0700 Subject: [PATCH] added github actions support --- .github/workflows/ci.yml | 51 ++++++++++++++++++++++++++++++++++++++++ README.md | 10 ++++---- 2 files changed, 56 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..076bc92 --- /dev/null +++ b/.github/workflows/ci.yml @@ -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 diff --git a/README.md b/README.md index 9e26739..2fc5abd 100755 --- a/README.md +++ b/README.md @@ -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> -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. @@ -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> +version 1.0.3 (added github actions support) +version 1.0.2 (updated for travis-ci.com transition) M. A. Chatterjee