From d1fbe674d2b58f510e35413b89a9eab3080c5876 Mon Sep 17 00:00:00 2001 From: Heshan Padmasiri Date: Thu, 20 Jul 2023 07:19:45 +0530 Subject: [PATCH] Generate code coverage reports using CodeCov --- .github/workflows/ci.yml | 14 ++++++++++++++ .github/workflows/daily-build.yml | 19 +++++++++++++++++++ .github/workflows/pull-request.yml | 20 +++++++++++++++++++- README.md | 1 + 4 files changed, 53 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index be0aa2d..4525eca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,6 +28,20 @@ jobs: USER_ID_1: ${{ secrets.USER_ID_1 }} USER_ID_2: ${{ secrets.USER_ID_2 }} USER_ID_3: ${{ secrets.USER_ID_3 }} + - name: Ballerina Tests + run: bal test --test-report --code-coverage --coverage-format=xml + env: + WORKING_DIR: ./teams + REFRESH_URL: ${{ secrets.REFRESH_URL }} + REFRESH_TOKEN: ${{ secrets.REFRESH_TOKEN }} + CLIENT_ID: ${{ secrets.CLIENT_ID }} + CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} + USER_ID_1: ${{ secrets.USER_ID_1 }} + USER_ID_2: ${{ secrets.USER_ID_2 }} + USER_ID_3: ${{ secrets.USER_ID_3 }} + + - 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') diff --git a/.github/workflows/daily-build.yml b/.github/workflows/daily-build.yml index 6d50203..b68353a 100644 --- a/.github/workflows/daily-build.yml +++ b/.github/workflows/daily-build.yml @@ -33,6 +33,25 @@ jobs: USER_ID_2: ${{ secrets.USER_ID_2 }} USER_ID_3: ${{ secrets.USER_ID_3 }} + - name: Ballerina Tests + uses: ballerina-platform/ballerina-action/@nightly + with: + args: + test --test-report --code-coverage --coverage-format=xml + env: + JAVA_HOME: /usr/lib/jvm/default-jvm + WORKING_DIR: ./teams + REFRESH_URL: ${{ secrets.REFRESH_URL }} + REFRESH_TOKEN: ${{ secrets.REFRESH_TOKEN }} + CLIENT_ID: ${{ secrets.CLIENT_ID }} + CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} + USER_ID_1: ${{ secrets.USER_ID_1 }} + USER_ID_2: ${{ secrets.USER_ID_2 }} + USER_ID_3: ${{ secrets.USER_ID_3 }} + + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v3 + # Send notification when build fails - name: Notify failure if: ${{ failure() }} diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 4450988..42b9484 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -21,4 +21,22 @@ jobs: CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} USER_ID_1: ${{ secrets.USER_ID_1 }} USER_ID_2: ${{ secrets.USER_ID_2 }} - USER_ID_3: ${{ secrets.USER_ID_3 }} \ No newline at end of file + USER_ID_3: ${{ secrets.USER_ID_3 }} + - name: Ballerina Tests + # tests will be skipped if the PR is from a forked repository (as the secrets are not available) + if: ${{ github.event.pull_request.head.repo.full_name == github.repository }} + uses: ballerina-platform/ballerina-action/@nightly + with: + args: + test --test-report --code-coverage --coverage-format=xml ./teams + env: + REFRESH_URL: ${{ secrets.REFRESH_URL }} + REFRESH_TOKEN: ${{ secrets.REFRESH_TOKEN }} + CLIENT_ID: ${{ secrets.CLIENT_ID }} + CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} + USER_ID_1: ${{ secrets.USER_ID_1 }} + USER_ID_2: ${{ secrets.USER_ID_2 }} + USER_ID_3: ${{ secrets.USER_ID_3 }} + + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v3 diff --git a/README.md b/README.md index 85a27f2..6a91ae9 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ Ballerina Microsoft Teams Connector =================== [![Build Status](https://github.com/ballerina-platform/module-ballerinax-microsoft.teams/workflows/CI/badge.svg)](https://github.com/ballerina-platform/module-ballerinax-msgraph-teams/actions?query=workflow%3ACI) +[![codecov](https://codecov.io/gh/ballerina-platform/module-ballerinax-microsoft.teams/branch/main/graph/badge.svg)](https://codecov.io/gh/ballerina-platform/module-ballerinax-microsoft.teams) [![GitHub Last Commit](https://img.shields.io/github/last-commit/ballerina-platform/module-ballerinax-microsoft.teams.svg)](https://github.com/ballerina-platform/module-ballerinax-msgraph-teams/commits/master) [![GraalVM Check](https://github.com/ballerina-platform/module-ballerinax-microsoft.teams/actions/workflows/build-with-bal-test-native.yml/badge.svg)](https://github.com/ballerina-platform/module-ballerinax-microsoft.teams/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)