From c643f989d9b3a8999f803cc187a66d0d95a9db7b 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 | 15 +++++++++++++++ .github/workflows/pull-request.yml | 18 +++++++++++++++++- README.md | 1 + 4 files changed, 47 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index be0aa2d..a0cde1c 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:wa - 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..238e6ed 100644 --- a/.github/workflows/daily-build.yml +++ b/.github/workflows/daily-build.yml @@ -33,6 +33,21 @@ jobs: 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:wa + # 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..3340b11 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -21,4 +21,20 @@ 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 }} + 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:wa 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)