1- name : Code Coverage
1+ name : E2E Tests and Code Coverage
22
33permissions :
44 contents : read
5+ id-token : write
56
6- on : [pull_request, workflow_dispatch]
7+ on :
8+ push :
9+ branches :
10+ - main
11+ pull_request :
12+ workflow_dispatch :
713
814jobs :
915 test-with-coverage :
10- runs-on : ubuntu-latest
16+ runs-on :
17+ group : databricks-protected-runner-group
18+ labels : linux-ubuntu-latest
1119 environment : azure-prod
1220 env :
1321 DATABRICKS_SERVER_HOSTNAME : ${{ secrets.DATABRICKS_HOST }}
@@ -16,91 +24,29 @@ jobs:
1624 DATABRICKS_CATALOG : peco
1725 DATABRICKS_USER : ${{ secrets.TEST_PECO_SP_ID }}
1826 steps :
19- # ----------------------------------------------
20- # check-out repo and set-up python
21- # ----------------------------------------------
2227 - name : Check out repository
2328 uses : actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
2429 with :
2530 fetch-depth : 0
26- - name : Set up python
27- id : setup-python
28- uses : actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
29- with :
30- python-version : " 3.10"
31- # ----------------------------------------------
32- # ----- install system dependencies -----
33- # ----------------------------------------------
3431 - name : Install system dependencies
3532 run : |
3633 sudo apt-get update
3734 sudo apt-get install -y libkrb5-dev
38- # ----------------------------------------------
39- # ----- install & configure poetry -----
40- # ----------------------------------------------
41- - name : Install Poetry
42- uses : snok/install-poetry@76e04a911780d5b312d89783f7b1cd627778900a # v1
43- with :
44- version : " 2.2.1"
45- virtualenvs-create : true
46- virtualenvs-in-project : true
47- installer-parallel : true
48-
49- # ----------------------------------------------
50- # load cached venv if cache exists
51- # ----------------------------------------------
52- - name : Load cached venv
53- id : cached-poetry-dependencies
54- uses : actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
35+ - name : Setup Poetry
36+ uses : ./.github/actions/setup-poetry
5537 with :
56- path : .venv
57- key : venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ github.event.repository.name }}-${{ hashFiles('**/poetry.lock') }}
58- # ----------------------------------------------
59- # install dependencies if cache does not exist
60- # ----------------------------------------------
61- - name : Install dependencies
62- if : steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
63- run : poetry install --no-interaction --no-root
64- # ----------------------------------------------
65- # install your root project, if required
66- # ----------------------------------------------
67- - name : Install Kerberos system dependencies
68- run : |
69- sudo apt-get update
70- sudo apt-get install -y libkrb5-dev
71- - name : Install library
72- run : poetry install --no-interaction --all-extras
73- # ----------------------------------------------
74- # run parallel tests with coverage
75- # ----------------------------------------------
76- - name : Run parallel tests with coverage
38+ python-version : " 3.10"
39+ install-args : " --all-extras"
40+ - name : Run all tests with coverage
7741 continue-on-error : false
7842 run : |
7943 poetry run pytest tests/unit tests/e2e \
80- -m "not serial" \
81- -n auto \
44+ -n 4 \
45+ --dist=loadgroup \
8246 --cov=src \
8347 --cov-report=xml \
8448 --cov-report=term \
8549 -v
86-
87- # ----------------------------------------------
88- # run telemetry tests with coverage (isolated)
89- # ----------------------------------------------
90- - name : Run telemetry tests with coverage (isolated)
91- continue-on-error : false
92- run : |
93- # Run test_concurrent_telemetry.py separately for isolation
94- poetry run pytest tests/e2e/test_concurrent_telemetry.py \
95- --cov=src \
96- --cov-append \
97- --cov-report=xml \
98- --cov-report=term \
99- -v
100-
101- # ----------------------------------------------
102- # check for coverage override
103- # ----------------------------------------------
10450 - name : Check for coverage override
10551 id : override
10652 env :
11662 echo "override=false" >> $GITHUB_OUTPUT
11763 echo "No coverage override found"
11864 fi
119- # ----------------------------------------------
120- # check coverage percentage
121- # ----------------------------------------------
12265 - name : Check coverage percentage
12366 if : steps.override.outputs.override == 'false'
12467 run : |
@@ -127,40 +70,29 @@ jobs:
12770 echo "ERROR: Coverage file not found at $COVERAGE_FILE"
12871 exit 1
12972 fi
130-
131- # Install xmllint if not available
13273 if ! command -v xmllint &> /dev/null; then
13374 sudo apt-get update && sudo apt-get install -y libxml2-utils
13475 fi
135-
13676 COVERED=$(xmllint --xpath "string(//coverage/@lines-covered)" "$COVERAGE_FILE")
13777 TOTAL=$(xmllint --xpath "string(//coverage/@lines-valid)" "$COVERAGE_FILE")
13878 PERCENTAGE=$(python3 -c "covered=${COVERED}; total=${TOTAL}; print(round((covered/total)*100, 2))")
139-
14079 echo "Branch Coverage: $PERCENTAGE%"
14180 echo "Required Coverage: 85%"
142-
143- # Use Python to compare the coverage with 85
14481 python3 -c "import sys; sys.exit(0 if float('$PERCENTAGE') >= 85 else 1)"
14582 if [ $? -eq 1 ]; then
14683 echo "ERROR: Coverage is $PERCENTAGE%, which is less than the required 85%"
14784 exit 1
14885 else
14986 echo "SUCCESS: Coverage is $PERCENTAGE%, which meets the required 85%"
15087 fi
151-
152- # ----------------------------------------------
153- # coverage enforcement summary
154- # ----------------------------------------------
15588 - name : Coverage enforcement summary
15689 env :
15790 OVERRIDE : ${{ steps.override.outputs.override }}
15891 REASON : ${{ steps.override.outputs.reason }}
15992 run : |
16093 if [ "$OVERRIDE" == "true" ]; then
161- echo "⚠️ Coverage checks bypassed: $REASON"
94+ echo "Coverage checks bypassed: $REASON"
16295 echo "Please ensure this override is justified and temporary"
16396 else
164- echo "✅ Coverage checks enforced - minimum 85% required"
97+ echo "Coverage checks enforced - minimum 85% required"
16598 fi
166-
0 commit comments