diff --git a/.github/actions/publish-coverage/report/report.py b/.github/actions/publish-coverage/report/report.py index fd9af72..96fe4ae 100644 --- a/.github/actions/publish-coverage/report/report.py +++ b/.github/actions/publish-coverage/report/report.py @@ -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' % { @@ -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() \ No newline at end of file diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000..608b2d8 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -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" + diff --git a/.github/workflows/note-arduino-ci.yml b/.github/workflows/note-arduino-ci.yml index ea8af3f..fdcc3c0 100644 --- a/.github/workflows/note-arduino-ci.yml +++ b/.github/workflows/note-arduino-ci.yml @@ -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 diff --git a/test/run_all_tests.sh b/test/run_all_tests.sh index d71829f..52702be 100755 --- a/test/run_all_tests.sh +++ b/test/run_all_tests.sh @@ -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!!!' \