Skip to content

Commit

Permalink
add github actions codecov workflow for test coverage report check an…
Browse files Browse the repository at this point in the history
…d comment
  • Loading branch information
1fanwang committed Sep 17, 2024
1 parent 4f63ee4 commit fa96542
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 1 deletion.
44 changes: 44 additions & 0 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# GitHub Actions workflow for Codecov integration
# This workflow builds the project, generates a coverage report, and uploads it to Codecov

name: Codecov

# Define when this workflow should run
on:
push:
branches: ['master'] # Run on every push to the master branch
pull_request:
branches: ['**'] # Run on every pull request, regardless of target branch

# Define the jobs to run
jobs:
codecov:
runs-on: ubuntu-latest # Use the latest Ubuntu runner
steps:
# Step 1: Check out the repository code
- name: Checkout code
uses: actions/checkout@v2 # Use v2 of the checkout action
with:
fetch-depth: '0' # Fetch all history for all branches and tags

# Step 2: Set up Java Development Kit
- name: Set up JDK
uses: actions/setup-java@v1 # Use v1 of the setup-java action
with:
java-version: 1.8 # Use Java 8 (adjust if your project uses a different version)

# Step 3: Build the project and generate coverage report
- name: Build and generate coverage report
run: ./gradlew clean build jacocoTestReport --no-daemon
# This runs a clean build, runs tests, and generates a JaCoCo coverage report

# Step 4: Upload the coverage report to Codecov
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3 # Use v3 of the Codecov GitHub Action
with:
file: ./build/reports/jacoco/jacocoRootReport/jacocoRootReport.xml # Path to the coverage report
flags: unittests # Label these results as coming from unit tests
fail_ci_if_error: true # Fail the workflow if there's an error uploading to Codecov

# Note: No token is required for public repositories
# Codecov will automatically detect that this is a public repo and process the report
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ ligradle
.DS_Store
*.patch
*/metastore_db
.pyc
.pyc
.vscode
47 changes: 47 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Codecov configuration file
# This file controls how Codecov behaves when processing coverage reports

codecov:
# Require all other CI tasks to pass before considering Codecov status
require_ci_to_pass: yes

coverage:
status:
# Settings for overall project coverage
project:
default:
# 'auto' sets the target to the coverage of the base commit
target: auto
# Coverage can drop up to 1% without failing
threshold: 1%
# Compare coverage to the base branch (usually master)
base: auto

# Settings for coverage of new/changed code in PRs
patch:
default:
# 'auto' requires new/changed code to match the base branch coverage
target: auto
# New/changed code coverage can be up to 1% lower without failing
threshold: 1%
# Compare to the base branch of the PR
base: auto

# Configuration for Codecov comments on PRs
comment:
# Elements to include in the comment
# reach: overall coverage
# diff: coverage diff to base
# flags: coverage for specific flags
# files: file-level coverage
# footer: links to more details
layout: "reach,diff,flags,files,footer"
# Use default comment behavior
behavior: default
# Comment even if coverage hasn't changed
require_changes: no

# Ignore these directories/files when calculating coverage
ignore:
- "coral-common"
- "coral-hive"

0 comments on commit fa96542

Please sign in to comment.