From fa96542dc6da1712f5a9330a00162fea0127bc5e Mon Sep 17 00:00:00 2001 From: Stefan Wang <1fannnw@gmail.com> Date: Mon, 16 Sep 2024 17:16:29 -0700 Subject: [PATCH] add github actions codecov workflow for test coverage report check and comment --- .github/workflows/codecov.yml | 44 ++++++++++++++++++++++++++++++++ .gitignore | 3 ++- codecov.yml | 47 +++++++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/codecov.yml create mode 100644 codecov.yml diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml new file mode 100644 index 000000000..15da0a69b --- /dev/null +++ b/.github/workflows/codecov.yml @@ -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 diff --git a/.gitignore b/.gitignore index 9264fd73c..b8ea8dd41 100644 --- a/.gitignore +++ b/.gitignore @@ -18,4 +18,5 @@ ligradle .DS_Store *.patch */metastore_db -.pyc \ No newline at end of file +.pyc +.vscode \ No newline at end of file diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 000000000..d643a2d58 --- /dev/null +++ b/codecov.yml @@ -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"