Skip to content

Commit dbdbaa3

Browse files
committed
CI(macOS): Enable code coverage for gunittest-based tests
1 parent f3163d4 commit dbdbaa3

File tree

2 files changed

+65
-3
lines changed

2 files changed

+65
-3
lines changed

.github/workflows/macos.yml

Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,17 @@ jobs:
8989
if: ${{ !cancelled() }}
9090
shell: micromamba-shell {0}
9191
run: source ./.github/workflows/print_versions.sh
92+
- name: Place a usercustomize.py file enabling subprocess code coverage
93+
shell: bash -el {0}
94+
run: |
95+
mkdir -p $(python -m site --user-site)
96+
printf "import coverage\ncoverage.process_startup()" \
97+
> "$(python -m site --user-site)/usercustomize.py"
98+
- name: Set COVERAGE_PROCESS_START env variable
99+
shell: bash -el {0}
100+
run: |
101+
echo "COVERAGE_PROCESS_START=${PWD}/.coveragerc" >> $GITHUB_ENV
102+
echo "COVERAGE_RCFILE=${PWD}/.coveragerc" >> $GITHUB_ENV
92103
93104
- name: Run pytest with multiple workers in parallel
94105
shell: micromamba-shell {0}
@@ -135,15 +146,65 @@ jobs:
135146

136147
- name: Run gunittest tests
137148
shell: micromamba-shell {0}
138-
run: .github/workflows/test_thorough.sh --config .github/workflows/macos_gunittest.cfg
149+
run: |
150+
export INITIAL_GISBASE="$(grass --config path)"
151+
export INITIAL_PWD="${PWD}"
152+
grass --tmp-project XY --exec \
153+
g.download.location url=${{ env.SAMPLE_DATA_URL }} path=$HOME
154+
grass --tmp-project XY --exec \
155+
${PYTHON} -m grass.gunittest.main \
156+
--grassdata $HOME --location nc_spm_full_v2alpha2 --location-type nc \
157+
--min-success 100 --config .github/workflows/macos_gunittest.cfg
139158
env:
140159
SAMPLE_DATA_URL: "file://${{ github.workspace }}/sample-data/\
141160
nc_spm_full_v2alpha2.tar.gz"
142-
161+
PYTHON: coverage run
162+
- name: Fix non-standard installed script paths in coverage data
163+
shell: bash -el {0}
164+
run: |
165+
export PYTHONPATH=`grass --config python_path`:$PYTHONPATH
166+
# export LD_LIBRARY_PATH=$(grass --config path)/lib:$LD_LIBRARY_PATH
167+
export INITIAL_GISBASE="$(grass --config path)"
168+
export INITIAL_PWD="${PWD}"
169+
coverage combine
170+
python utils/coverage_mapper.py
171+
coverage combine
172+
- name: Show python coverage report summary
173+
shell: bash -el {0}
174+
run: |
175+
export PYTHONPATH=`grass --config python_path`:$PYTHONPATH
176+
# export LD_LIBRARY_PATH=$(grass --config path)/lib:$LD_LIBRARY_PATH
177+
export INITIAL_GISBASE="$(grass --config path)"
178+
export INITIAL_PWD="${PWD}"
179+
coverage report
180+
- name: Generate HTML coverage report
181+
shell: bash -el {0}
182+
run: |
183+
export PYTHONPATH=`grass --config python_path`:$PYTHONPATH
184+
# export LD_LIBRARY_PATH=$(grass --config path)/lib:$LD_LIBRARY_PATH
185+
export INITIAL_GISBASE="$(grass --config path)"
186+
export INITIAL_PWD="${PWD}"
187+
coverage html
143188
- name: Make HTML test report available
144189
if: ${{ !cancelled() }}
145190
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
146191
with:
147-
name: testreport-macOS
192+
name: testreport-${{ runner.os }}
148193
path: testreport
149194
retention-days: 3
195+
- name: Make python-only code coverage test report available
196+
if: ${{ !cancelled() }}
197+
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4
198+
with:
199+
name: >-
200+
python-codecoverage-report-${{ 'macos-14' }}
201+
path: coverage_html_report
202+
retention-days: 1
203+
- name: Upload coverage reports to Codecov
204+
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0
205+
with:
206+
verbose: true
207+
flags: >-
208+
gunittest,gunittest-${{ 'macos-14' }}
209+
name: gunittest-${{ 'macos-14' }}
210+
token: ${{ secrets.CODECOV_TOKEN }}

macos/files/conda-requirements-dev-arm64.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ cairo
33
clangxx_osx-arm64
44
clang_osx-arm64
55
cmake
6+
coverage
67
expat
78
fftw
89
flex

0 commit comments

Comments
 (0)