From fed5f3ab4f2c60ea57cab44bb742d9f2b6caab4a Mon Sep 17 00:00:00 2001 From: affonsoBQ <67347924+affonsoBQ@users.noreply.github.com> Date: Wed, 26 Oct 2022 10:27:19 -0700 Subject: [PATCH] Add Code Coverage Badge (#129) * code coverage test * fixing yml file * testing variable * fixing yml * fixing badge extract * fix extract url * fixing build * adding checkout ref * Commit Code Coverage Badge * adding badge for others platforms * Commit Code Coverage Badge * fix mac and linux build * fix badge dir * Commit Code Coverage Badge * adding git pull before commit badge * removing mkdir * Commit Code Coverage Badge * Commit Code Coverage Badge * Commit Code Coverage Badge * Apply suggestions from code review Co-authored-by: Bruce Irschick * fix commit * fix commit badge * Commit Code Coverage Badge * fixing commit badge * adding git folder * Commit Code Coverage Badge * Commit Code Coverage Badge * Commit Code Coverage Badge * Commit Code Coverage Badge Co-authored-by: affonsoBQ Co-authored-by: Bruce Irschick --- .github/badges/coverage_badge_linux.svg | 1 + .github/badges/coverage_badge_macOS.svg | 1 + .github/badges/coverage_badge_windows.svg | 1 + .github/workflows/linux-build.yml | 32 +++++++++++++++++++++ .github/workflows/mac-debug-build.yml | 32 +++++++++++++++++++++ .github/workflows/win-build.yml | 35 +++++++++++++++++++++-- README.md | 3 ++ 7 files changed, 103 insertions(+), 2 deletions(-) create mode 100644 .github/badges/coverage_badge_linux.svg create mode 100644 .github/badges/coverage_badge_macOS.svg create mode 100644 .github/badges/coverage_badge_windows.svg diff --git a/.github/badges/coverage_badge_linux.svg b/.github/badges/coverage_badge_linux.svg new file mode 100644 index 000000000..139189473 --- /dev/null +++ b/.github/badges/coverage_badge_linux.svg @@ -0,0 +1 @@ +Linux Code Coverage: 38%Linux Code Coverage38% \ No newline at end of file diff --git a/.github/badges/coverage_badge_macOS.svg b/.github/badges/coverage_badge_macOS.svg new file mode 100644 index 000000000..dfa1348c1 --- /dev/null +++ b/.github/badges/coverage_badge_macOS.svg @@ -0,0 +1 @@ +macOS Code Coverage: 37%macOS Code Coverage37% \ No newline at end of file diff --git a/.github/badges/coverage_badge_windows.svg b/.github/badges/coverage_badge_windows.svg new file mode 100644 index 000000000..335381e2a --- /dev/null +++ b/.github/badges/coverage_badge_windows.svg @@ -0,0 +1 @@ +Windows Code Coverage: 33%Windows Code Coverage33% \ No newline at end of file diff --git a/.github/workflows/linux-build.yml b/.github/workflows/linux-build.yml index b3979aeb8..c90c7001a 100644 --- a/.github/workflows/linux-build.yml +++ b/.github/workflows/linux-build.yml @@ -182,6 +182,10 @@ jobs: runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 + with: + ref: ${{ github.event.pull_request.head.ref }} + fetch-depth: 0 + - name: Get Java distribution run: | sudo apt-get -y install software-properties-common @@ -310,6 +314,34 @@ jobs: ./build/odbc/bin/documentdb-odbc-tests --catch_system_errors=false gcovr --exclude-directories cmake-build64/odbc-test/CMakeFiles/documentdb-odbc-tests.dir$ --cobertura --output coverage.cobertura.xml + - name: Update Repository Before Commit Badge + run: | + git pull + + - name: Code Coverage Badge + uses: irongut/CodeCoverageSummary@v1.2.0 + with: + filename: coverage.cobertura.xml + badge: true + format: text + indicators: true + output: both + + - name: Extract Code Coverage Badge + run: | + COVERAGE_BADGE=$(head -1 code-coverage-results.txt ) + COVERAGE_BADGE="${COVERAGE_BADGE/'Code%20Coverage'/'Linux%20Code%20Coverage'}" + curl $COVERAGE_BADGE > .github/badges/coverage_badge_linux.svg + + - name: Commit Coverage Badge + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_options: '--allow-empty --no-verify' + commit_message: Commit Code Coverage Badge + file_pattern: '*.svg' + skip_fetch: true + skip_dirty_check: true + - name: Code Coverage Summary Report uses: irongut/CodeCoverageSummary@v1.2.0 with: diff --git a/.github/workflows/mac-debug-build.yml b/.github/workflows/mac-debug-build.yml index d9a67d318..5b54baaac 100644 --- a/.github/workflows/mac-debug-build.yml +++ b/.github/workflows/mac-debug-build.yml @@ -159,12 +159,44 @@ jobs: needs: build-mac-debug steps: - uses: actions/checkout@v2 + with: + ref: ${{ github.event.pull_request.head.ref }} + fetch-depth: 0 + - name: Retrieve coverage uses: actions/download-artifact@v2 with: name: code-coverage + - name: Code Coverage Badge + uses: irongut/CodeCoverageSummary@v1.2.0 + with: + filename: coverage.cobertura.xml + badge: true + format: text + indicators: true + output: both + + - name: Extract Code Coverage Badge + run: | + COVERAGE_BADGE=$(head -1 code-coverage-results.txt ) + COVERAGE_BADGE="${COVERAGE_BADGE/'Code%20Coverage'/'macOS%20Code%20Coverage'}" + curl $COVERAGE_BADGE > .github/badges/coverage_badge_macOS.svg + + - name: Update Repository Before Commit Badge + run: | + git pull + + - name: Commit Coverage Badge + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_options: '--allow-empty --no-verify' + commit_message: Commit Code Coverage Badge + file_pattern: '*.svg' + skip_fetch: true + skip_dirty_check: true + - name: Code Coverage Summary Report uses: irongut/CodeCoverageSummary@v1.2.0 with: diff --git a/.github/workflows/win-build.yml b/.github/workflows/win-build.yml index 2926ba745..4b8b9b61a 100644 --- a/.github/workflows/win-build.yml +++ b/.github/workflows/win-build.yml @@ -516,6 +516,9 @@ jobs: needs: build-windows64_coverage steps: - uses: actions/checkout@v2 + with: + ref: ${{ github.event.pull_request.head.ref }} + fetch-depth: 0 - name: Retrieve coverage uses: actions/download-artifact@v2 @@ -531,11 +534,39 @@ jobs: indicators: true output: both + - name: Code Coverage Badge + uses: irongut/CodeCoverageSummary@v1.2.0 + with: + filename: coverage.cobertura.xml + badge: true + format: text + indicators: true + output: both + + - name: Extract Code Coverage Badge + run: | + COVERAGE_BADGE=$(head -1 code-coverage-results.txt ) + COVERAGE_BADGE="${COVERAGE_BADGE/'Code%20Coverage'/'Windows%20Code%20Coverage'}" + curl $COVERAGE_BADGE > .github/badges/coverage_badge_windows.svg + + - name: Update Repository Before Commit Badge + run: | + git pull + + - name: Commit Coverage Badge + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_options: '--allow-empty --no-verify' + commit_message: Commit Code Coverage Badge + file_pattern: '*.svg' + skip_fetch: true + skip_dirty_check: true + - name: Add Header for Code Coverage Summary Report run: | - echo "## Windows 2022 (x32) Debug Build Unit Test Results Check" > coverage-cobertura.md + echo "## Windows 2022 (x64) Debug Build Unit Test Results Check" > coverage-cobertura.md cat code-coverage-results.md >> coverage-cobertura.md - + - name: Add Coverage PR Comment uses: marocchino/sticky-pull-request-comment@v2 if: github.event_name == 'pull_request' diff --git a/README.md b/README.md index c8f68d76c..b6ab2237b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,7 @@ # Amazon DocumentDB ODBC Driver +![Code Coverage Windows](./.github/badges/coverage_badge_windows.svg) +![Code Coverage macOS](./.github/badges/coverage_badge_macOS.svg) +![Code Coverage Linux](./.github/badges/coverage_badge_linux.svg) ## Overview