Skip to content

Commit d3ac112

Browse files
authored
build(coverage): fix carry-forward coverage (#12306)
1 parent 0d328f7 commit d3ac112

10 files changed

+110
-26
lines changed

.github/.codecov.yml

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
comment:
2+
layout: "header, files, footer" # remove "new" from "header" and "footer"
3+
hide_project_coverage: true # set to false
4+
require_changes: false # if true: only post the comment if coverage changes
5+
6+
codecov:
7+
#due to ci-optimization, reports for modules that have not changed may be quite old
8+
max_report_age: off
9+
10+
flag_management:
11+
default_rules: # the rules that will be followed for any flag added, generally
12+
carryforward: true
13+
statuses:
14+
- type: project
15+
target: auto
16+
threshold: 0% #Not enforcing project coverage yet.
17+
- type: patch
18+
target: 90%
19+
individual_flags: # exceptions to the default rules above, stated flag by flag
20+
- name: frontend
21+
paths:
22+
- "datahub-frontend/**"
23+
- "datahub-web-react/**"
24+
- name: backend
25+
paths:
26+
- "metadata-models/**"
27+
- "datahub-upgrade/**"
28+
- "entity-registry/**"
29+
- "li-utils/**"
30+
- "metadata-auth/**"
31+
- "metadata-dao-impl/**"
32+
- "metadata-events/**"
33+
- "metadata-jobs/**"
34+
- "metadata-service/**"
35+
- "metadata-utils/**"
36+
- "metadata-operation-context/**"
37+
- "datahub-graphql-core/**"
38+
- name: metadata-io
39+
paths:
40+
- "metadata-io/**"
41+
- name: ingestion
42+
paths:
43+
- "metadata-ingestion/**"
44+
- name: ingestion-airflow
45+
paths:
46+
- "metadata-ingestion-modules/airflow-plugin/**"
47+
- name: ingestion-dagster
48+
paths:
49+
- "metadata-ingestion-modules/dagster-plugin/**"
50+
- name: ingestion-gx-plugin
51+
paths:
52+
- "metadata-ingestion-modules/gx-plugin/**"
53+
- name: ingestion-prefect
54+
paths:
55+
- "metadata-ingestion-modules/prefect-plugin/**"
56+
coverage:
57+
status:
58+
project:
59+
default:
60+
target: 0% # no threshold enforcement yet
61+
only_pulls: true
62+
patch:
63+
default:
64+
target: 90% # for new code added in the patch
65+
only_pulls: true

.github/workflows/airflow-plugin.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,15 @@ jobs:
7777
**/build/test-results/test/**
7878
**/junit.*.xml
7979
!**/binary/**
80-
- name: Upload coverage to Codecov
80+
- name: Upload coverage to Codecov with ingestion flag
8181
if: always()
8282
uses: codecov/codecov-action@v5
8383
with:
8484
token: ${{ secrets.CODECOV_TOKEN }}
85-
directory: ./build/coverage-reports/
85+
directory: ./build/coverage-reports/metadata-ingestion-modules/airflow-plugin/
8686
fail_ci_if_error: false
87-
flags: airflow-${{ matrix.python-version }}-${{ matrix.extra_pip_extras }}
88-
name: pytest-airflow
87+
flags: ingestion-airflow
88+
name: pytest-airflow-${{ matrix.python-version }}-${{ matrix.extra_pip_requirements }}
8989
verbose: true
9090
- name: Upload test results to Codecov
9191
if: ${{ !cancelled() }}

.github/workflows/build-and-test.yml

+22-4
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ jobs:
113113
if: ${{ matrix.command == 'except_metadata_ingestion' && needs.setup.outputs.backend_change == 'true' }}
114114
run: |
115115
./gradlew -PjavaClassVersionDefault=8 :metadata-integration:java:spark-lineage:compileJava
116+
- name: Gather coverage files
117+
run: |
118+
echo "BACKEND_FILES=`find ./build/coverage-reports/ -type f | grep -E '(metadata-models|entity-registry|datahuyb-graphql-core|metadata-io|metadata-jobs|metadata-utils|metadata-service|medata-dao-impl|metadata-operation|li-utils|metadata-integration|metadata-events|metadata-auth|ingestion-scheduler|notifications|datahub-upgrade)' | xargs | sed 's/ /,/g'`" >> $GITHUB_ENV
119+
echo "FRONTEND_FILES=`find ./build/coverage-reports/ -type f | grep -E '(datahub-frontend|datahub-web-react).*\.(xml|json)$' | xargs | sed 's/ /,/g'`" >> $GITHUB_ENV
116120
- uses: actions/upload-artifact@v4
117121
if: always()
118122
with:
@@ -124,14 +128,28 @@ jobs:
124128
!**/binary/**
125129
- name: Ensure codegen is updated
126130
uses: ./.github/actions/ensure-codegen-updated
127-
- name: Upload coverage to Codecov
128-
if: always()
131+
- name: Upload backend coverage to Codecov
132+
if: ${{ matrix.command == 'except_metadata_ingestion' && needs.setup.outputs.backend_change == 'true' }}
133+
uses: codecov/codecov-action@v5
134+
with:
135+
token: ${{ secrets.CODECOV_TOKEN }}
136+
files: ${{ env.BACKEND_FILES }}
137+
disable_search: true
138+
#handle_no_reports_found: true
139+
fail_ci_if_error: false
140+
flags: backend
141+
name: ${{ matrix.command }}
142+
verbose: true
143+
- name: Upload frontend coverage to Codecov
144+
if: ${{ matrix.command == 'frontend' && needs.setup.outputs.frontend_change == 'true' }}
129145
uses: codecov/codecov-action@v5
130146
with:
131147
token: ${{ secrets.CODECOV_TOKEN }}
132-
directory: ./build/coverage-reports/
148+
files: ${{ env.FRONTEND_FILES }}
149+
disable_search: true
150+
#handle_no_reports_found: true
133151
fail_ci_if_error: false
134-
flags: ${{ matrix.timezone }}
152+
flags: frontend
135153
name: ${{ matrix.command }}
136154
verbose: true
137155
- name: Upload test results to Codecov

.github/workflows/dagster-plugin.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,14 @@ jobs:
6464
**/build/reports/tests/test/**
6565
**/build/test-results/test/**
6666
**/junit.*.xml
67-
- name: Upload coverage to Codecov
67+
- name: Upload coverage to Codecov with ingestion flag
6868
if: always()
6969
uses: codecov/codecov-action@v5
7070
with:
7171
token: ${{ secrets.CODECOV_TOKEN }}
72-
directory: ./build/coverage-reports/
72+
directory: ./build/coverage-reports/metadata-ingestion-modules/dagster-plugin/
7373
fail_ci_if_error: false
74-
flags: dagster-${{ matrix.python-version }}-${{ matrix.extraPythonRequirement }}
74+
flags: ingestion-dagster-plugin
7575
name: pytest-dagster
7676
verbose: true
7777
- name: Upload test results to Codecov

.github/workflows/gx-plugin.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,14 @@ jobs:
6868
**/build/reports/tests/test/**
6969
**/build/test-results/test/**
7070
**/junit.*.xml
71-
- name: Upload coverage to Codecov
71+
- name: Upload coverage to Codecov with ingestion flag
7272
if: always()
7373
uses: codecov/codecov-action@v5
7474
with:
7575
token: ${{ secrets.CODECOV_TOKEN }}
76-
directory: ./build/coverage-reports/
76+
directory: ./build/coverage-reports/metadata-ingestion-modules/gx-plugin/
7777
fail_ci_if_error: false
78-
flags: gx-${{ matrix.python-version }}-${{ matrix.extraPythonRequirement }}
78+
flags: ingestion-gx-plugin
7979
name: pytest-gx
8080
verbose: true
8181
- name: Upload test results to Codecov

.github/workflows/metadata-ingestion.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,15 @@ jobs:
8888
**/build/test-results/test/**
8989
**/junit.*.xml
9090
!**/binary/**
91-
- name: Upload coverage to Codecov
92-
if: ${{ always() }}
91+
- name: Upload coverage to Codecov with ingestion flag
92+
if: ${{ always() && matrix.python-version == '3.11' }}
9393
uses: codecov/codecov-action@v5
9494
with:
9595
token: ${{ secrets.CODECOV_TOKEN }}
96-
directory: ./build/coverage-reports/
96+
directory: ./build/coverage-reports/metadata-ingestion/
9797
fail_ci_if_error: false
98-
flags: ingestion-${{ matrix.python-version }}-${{ matrix.command }}
99-
name: pytest-ingestion
98+
flags: ingestion
99+
name: pytest-${{ matrix.python-version }}-${{ matrix.command }}
100100
verbose: true
101101
- name: Upload test results to Codecov
102102
if: ${{ !cancelled() }}

.github/workflows/metadata-io.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,9 @@ jobs:
8686
uses: codecov/codecov-action@v5
8787
with:
8888
token: ${{ secrets.CODECOV_TOKEN }}
89-
directory: ./build/coverage-reports/
89+
directory: ./build/coverage-reports/metadata-io/
9090
fail_ci_if_error: false
91+
flags: metadata-io
9192
name: metadata-io-test
9293
verbose: true
9394
- name: Upload test results to Codecov

.github/workflows/prefect-plugin.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ jobs:
6060
**/build/test-results/test/**
6161
**/junit.*.xml
6262
!**/binary/**
63-
- name: Upload coverage to Codecov
63+
- name: Upload coverage to Codecov with ingestion flag
6464
if: always()
6565
uses: codecov/codecov-action@v5
6666
with:
6767
token: ${{ secrets.CODECOV_TOKEN }}
68-
directory: ./build/coverage-reports/
68+
directory: ./build/coverage-reports/metadata-ingestion-modules/prefect-plugin/
6969
fail_ci_if_error: false
70-
flags: prefect-${{ matrix.python-version }}
71-
name: pytest-prefect
70+
flags: ingestion-prefect-plugin
71+
name: pytest-prefect-${{ matrix.python-version }}
7272
verbose: true
7373
- name: Upload test results to Codecov
7474
if: ${{ !cancelled() }}

gradle/coverage/java-coverage.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ afterEvaluate {
2222
Tools that aggregate and analyse coverage tools search for the coverage result files. Keeping them under one
2323
folder will minimize the time spent searching through the full source tree.
2424
*/
25-
outputLocation = rootProject.layout.buildDirectory.file("coverage-reports/jacoco-${project.name}.xml")
25+
outputLocation = rootProject.layout.buildDirectory.file("coverage-reports/${rootProject.relativePath(project.projectDir)}/jacoco-${project.name}.xml")
2626
}
2727
csv.required = false
2828
html.required = false

gradle/coverage/python-coverage.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ext.get_coverage_args = { test_name = "" ->
77
Tools that aggregate and analyse coverage tools search for the coverage result files. Keeping them under one folder
88
will minimize the time spent searching through the full source tree.
99
*/
10-
def base_path = "${rootProject.buildDir}/coverage-reports"
10+
def base_path = "${rootProject.buildDir}/coverage-reports/${rootProject.relativePath(project.projectDir)}/"
1111

1212
/*
1313
--cov=src was added via setup.cfg in many of the python projects but for some reason, was not getting picked up

0 commit comments

Comments
 (0)