Skip to content

Commit

Permalink
Merge pull request #59 from ballerina-platform/heshan-codecov
Browse files Browse the repository at this point in the history
Generate test coverage reports using CodeCov
  • Loading branch information
NipunaRanasinghe authored Jul 19, 2023
2 parents 56da486 + 79b362c commit 0ef09f2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 35 deletions.
20 changes: 3 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,15 @@ jobs:
uses: ballerina-platform/ballerina-action/@nightly
with:
args:
test --code-coverage
test --test-report --code-coverage --coverage-format=xml
env:
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
REFRESH_TOKEN: ${{ secrets.REFRESH_TOKEN }}
WORKING_DIR: ./gpeople

# Read the ballerina test results
- name: Read Ballerina Test Results
id: test_results
run: |
content=`cat ./gpeople/target/report/test_results.json`
content="${content//'%'/'%25'}"
content="${content//$'\n'/'%0A'}"
content="${content//$'\r'/'%0D'}"
echo "::set-output name=testResultsJson::$content"
# Print the code coverage information
- name: Code Coverage
run: |
echo "Covered Code Lines : ${{fromJson(steps.test_results.outputs.testResultsJson).coveredLines}}"
echo "Total Code Lines : $(expr ${{fromJson(steps.test_results.outputs.testResultsJson).missedLines}} + ${{fromJson(steps.test_results.outputs.testResultsJson).coveredLines}})"
echo "Code Coverage Percentage : ${{fromJson(steps.test_results.outputs.testResultsJson).coveragePercentage}}"
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3

- name: Alert notifier on failure
if: failure() && (github.event.action == 'check_connector_for_breaking_changes')
Expand Down
20 changes: 3 additions & 17 deletions .github/workflows/daily-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,16 @@ jobs:
uses: ballerina-platform/ballerina-action/@nightly
with:
args:
test --code-coverage
test --test-report --code-coverage --coverage-format=xml
env:
JAVA_HOME: /usr/lib/jvm/default-jvm
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
REFRESH_TOKEN: ${{ secrets.REFRESH_TOKEN }}
WORKING_DIR: ./gpeople

# Read the ballerina test results
- name: Read Ballerina Test Results
id: test_results
run: |
content=`cat ./gpeople/target/report/test_results.json`
content="${content//'%'/'%25'}"
content="${content//$'\n'/'%0A'}"
content="${content//$'\r'/'%0D'}"
echo "::set-output name=testResultsJson::$content"
# Print the code coverage information
- name: Code Coverage
run: |
echo "Covered Code Lines : ${{fromJson(steps.test_results.outputs.testResultsJson).coveredLines}}"
echo "Total Code Lines : $(expr ${{fromJson(steps.test_results.outputs.testResultsJson).missedLines}} + ${{fromJson(steps.test_results.outputs.testResultsJson).coveredLines}})"
echo "Code Coverage Percentage : ${{fromJson(steps.test_results.outputs.testResultsJson).coveragePercentage}}"
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3

# Send notification when build fails
- name: Notify failure
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@ jobs:
uses: ballerina-platform/ballerina-action/@nightly
with:
args:
test
test --test-report --code-coverage --coverage-format=xml
env:
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
REFRESH_TOKEN: ${{ secrets.REFRESH_TOKEN }}
WORKING_DIR: ./gpeople

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Ballerina Google People API Connector

[![Build](https://github.com/ballerina-platform/module-ballerinax-googleapis.people/workflows/CI/badge.svg)](https://github.com/ballerina-platform/module-ballerinax-googleapis.people/actions?query=workflow%3ACI)
[![codecov](https://codecov.io/gh/ballerina-platform/module-ballerinax-googleapis.people/branch/master/graph/badge.svg)](https://codecov.io/gh/ballerina-platform/module-ballerinax-googleapis.people)
[![GitHub Last Commit](https://img.shields.io/github/last-commit/ballerina-platform/module-ballerinax-googleapis.people.svg)](https://github.com/ballerina-platform/module-ballerinax-googleapis.people/commits/master)
[![GraalVM Check](https://github.com/ballerina-platform/module-ballerinax-googleapis.people/actions/workflows/build-with-bal-test-native.yml/badge.svg)](https://github.com/ballerina-platform/module-ballerinax-googleapis.people/actions/workflows/build-with-bal-test-native.yml)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
Expand Down

0 comments on commit 0ef09f2

Please sign in to comment.