Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions .github/actions/publish-coverage/report/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ def post_report(coverage, args):
"""Post coverage report to coveralls.io."""
response = requests.post(URL, files={'json_file': json.dumps(coverage)},
verify=(not args.skip_ssl_verify))

try:
result = response.json()
result['status'] = response.status_code
except ValueError:
result = {'error': 'Failure to submit data. '
'Response [%(status)s]: %(text)s' % {
Expand All @@ -86,16 +88,10 @@ def main():
print("Environment variable COVERALLS_REPO_TOKEN is required to upload coverage information")
exit(-1)

# Consume Codefresh CI specific environment variables _(if available)_
json_coverage_details['service_job_id'] = os.environ.get('CF_BUILD_ID')
if (json_coverage_details['service_job_id'] is not None):
json_coverage_details['service_name'] = "codefresh"
else:
json_coverage_details['service_name'] = ""
del json_coverage_details['service_job_id']

# Post report to Coveralls.io
post_report(json_coverage_details, args)
if post_report(json_coverage_details, args)!=0:
exit(-2)


if __name__ == '__main__':
main()
33 changes: 33 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Build and Test

on:
push:
branches:
- '*'
pull_request:
branches:
- '*'


jobs:
coverage:
name: coverage (ubuntu-18.04)
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y lcov g++ valgrind
- name: test
run: ./test/run_all_tests.sh
- name: remove test source coverage
run: rm *mock*.gc?? *Mock*.gc?? *test*.gc??
- name: run lcov
run: lcov --capture --directory . --output-file lcov.info
- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: "./lcov.info"

3 changes: 0 additions & 3 deletions .github/workflows/note-arduino-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,4 @@ jobs:
uses: ./.github/actions/run-tests-in-container
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
- name: Publish Test Coverage
id: publish_coverage
uses: ./.github/actions/publish-coverage

16 changes: 6 additions & 10 deletions test/run_all_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -129,20 +129,16 @@ if [ 0 -eq ${all_tests_result} ]; then
echo && echo 'All tests have passed!'
# Run coverage if available
if [ $(which gcovr) ]; then
gcovr --print-summary --sort-percentage --exclude-throw-branches --delete \
echo "GITHUB_ACTIONS $GITHUB_ACTIONS"
echo "GITHUB_WORKFLOW $GITHUB_WORKFLOW"
echo "GITHUB_RUN_ID $GITHUB_RUN_ID"
echo "GITHUB_SHA $GITHUB_SHA"
gcovr --print-summary --sort-percentage --exclude-throw-branches \
--object-directory . \
--root src \
--exclude .*_error.* \
--exclude test \
--coveralls coverage.json \
--txt \
&& rm ./a.out *.gcno
if [ ! -f "coverage.json" ]; then
echo "Coverage report not produced";
all_tests_result=997
fi
else
rm -f ./a.out *.gcda *.gcno
--txt
fi
else
echo && echo 'TESTS FAILED!!!' \
Expand Down