Skip to content

Commit

Permalink
Fix #729, Add local and bundle unit test action with coverage verific…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
skliper committed Apr 14, 2021
1 parent ed5c3a9 commit e2be278
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 9 deletions.
13 changes: 4 additions & 9 deletions .github/workflows/codeql-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ jobs:
timeout-minutes: 15

steps:
# Checks out a copy of your repository on the ubuntu-latest machine
- name: Checkout bundle
uses: actions/checkout@v2
with:
Expand All @@ -38,21 +37,17 @@ jobs:
languages: c
queries: +security-extended, security-and-quality

# Setup the build system
- name: Set up for build
run: |
cp ./cfe/cmake/Makefile.sample Makefile
cp -r ./cfe/cmake/sample_defs sample_defs
make prep
# Build the code
- name: Build
run: |
make osal
make native/default_cpu1/osal/tests/
make native/default_cpu1/osal/unit-test-coverage/
make native/default_cpu1/osal/unit-tests/
make native/default_cpu1/osal/ut-stubs/
run: make -j native/default_cpu1/osal/

- name: Run tests
run: (cd build/native/default_cpu1/osal && make test)

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
43 changes: 43 additions & 0 deletions .github/workflows/local_unit_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: "Local Unit Test"

on:
push:
pull_request:

jobs:

Local-Unit-Test:
runs-on: ubuntu-18.04
timeout-minutes: 15

steps:
- name: Install cppcheck
run: sudo apt-get install lcov -y

- name: Checkout submodule
uses: actions/checkout@v2

- name: Set up for build
run: |
cp Makefile.sample Makefile
make ENABLE_UNIT_TESTS=true PERMISSIVE_MODE=true prep
- name: Build the code
run: make -j

# Baseline lcov and run all tests
- name: Test
run: |
make test
- name: Calculate coverage
run: |
make lcov | tee lcov_out.txt
- name: Confirm 100% line coverage
run: |
if [[ `grep -A 3 "Overall coverage rate" lcov_out.txt | grep lines` != *"100.0%"* ]]; then
grep -A 3 "Overall coverage rate" lcov_out.txt
echo "Lacks 100.0% line unit test coverage"
exit -1
fi

0 comments on commit e2be278

Please sign in to comment.