Merge commit '9c9b9f6dd75b7b3adaf9021040db3d112ef709e5' into lems-dev #30
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Local Unit Test" | |
on: | |
push: | |
pull_request: | |
jobs: | |
#Checks for duplicate actions. Skips push actions if there is a matching or duplicate pull-request action. | |
check-for-duplicates: | |
runs-on: ubuntu-latest | |
# Map a step output to a job output | |
outputs: | |
should_skip: ${{ steps.skip_check.outputs.should_skip }} | |
steps: | |
- id: skip_check | |
uses: fkirc/skip-duplicate-actions@master | |
with: | |
concurrent_skipping: 'same_content' | |
skip_after_successful_duplicate: 'true' | |
do_not_skip: '["pull_request", "workflow_dispatch", "schedule"]' | |
Local-Unit-Test: | |
needs: check-for-duplicates | |
if: ${{ needs.check-for-duplicates.outputs.should_skip != 'true' }} | |
runs-on: ubuntu-20.04 | |
timeout-minutes: 15 | |
steps: | |
- name: Install coverage tools | |
run: sudo apt-get install lcov -y | |
- name: Checkout submodule | |
uses: actions/checkout@v3 | |
- 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 | |
- name: Confirm absolute line coverage | |
run: | | |
# Current best possible branch coverage is all but 4, with associated issues for each missing case | |
missed_branches=4 | |
coverage_nums=$(grep -A 3 "Overall coverage rate" lcov_out.txt | grep branches | grep -oP "[0-9]+[0-9]*") | |
diff=$(echo $coverage_nums | awk '{ print $4 - $3 }') | |
if [ $diff -gt $missed_branches ] | |
then | |
grep -A 3 "Overall coverage rate" lcov_out.txt | |
echo "More than $missed_branches branches missed" | |
exit -1 | |
fi |