Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
a53a02f
CI(ubuntu): Create a tag for artifact uploads with length limit for a…
echoix Jul 21, 2024
bf8edde
CI: Allow replacing python3 interpreter in test_thorough.sh script
echoix Jul 21, 2024
d0b8807
CI(ubuntu): Ignore testreport folders from code coverage
echoix Jul 21, 2024
7daf078
CI(ubuntu): Enable python code coverage for gunittest-based tests
echoix Jul 21, 2024
899e375
style: Fix lines too long in ubuntu.yml workflow
echoix Jul 21, 2024
1169f02
CI(ubuntu): Configure python coverage for subprocesses
echoix Jul 21, 2024
40a89a8
CI(ubuntu): Add COVERAGE_RCFILE env for subprocess
echoix Jul 21, 2024
f82c394
CI(ubuntu): Set INITIAL_PWD env var as export instead of inline
echoix Jul 21, 2024
1b4db7d
CI(Ubuntu): Use ${{ !cancelled() }} as step condition to allow cancel…
echoix Jul 25, 2024
c455913
Remove "Set COVERAGE_PROCESS_START env variable" step
echoix Aug 4, 2024
bb726c3
CI(ubuntu): Set INITIAL_PWD env var as export instead of inline
echoix Jul 21, 2024
616f3b1
CI(ubuntu): Un-ignore testreport folders
echoix Jul 21, 2024
5ab7420
Update ubuntu.yml
echoix Jul 22, 2024
697b7c8
Revert "CI(ubuntu): Un-ignore testreport folders"
echoix Jul 25, 2024
757ac57
Revert "CI(ubuntu): Set INITIAL_PWD env var as export instead of inline"
echoix Jul 25, 2024
dc93ef2
Remove unused setting of coverage env var in test step
echoix Jul 25, 2024
f15850a
CI(macOS): Enable code coverage for gunittest-based tests
echoix Jul 26, 2024
080a98f
CI(macOS): Generate JSON report
echoix Jul 26, 2024
4ffd5cd
tests: Use Coverage.py 7.10.0 "patch = subprocess" setting
echoix Jul 25, 2025
b760728
CI: Use only one flag for codecov uploads
echoix Jul 26, 2025
6b65994
CI(ubuntu): Disable placing usercustomize for coverage
echoix Jul 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
[run]
; branch = True
; dynamic_context = test_function
patch = subprocess
concurrency = multiprocessing,thread
parallel = True
data_file = ${INITIAL_PWD-.}/.coverage
omit =
${INITIAL_PWD-.}/testreport
**/testreport/*
${INITIAL_PWD-.}/.github/*
${INITIAL_PWD-.}/bin.*/*
${INITIAL_PWD-.}/dist.*/*
Expand Down
67 changes: 64 additions & 3 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,17 @@ jobs:
if: ${{ !cancelled() }}
shell: micromamba-shell {0}
run: source ./.github/workflows/print_versions.sh
- name: Place a usercustomize.py file enabling subprocess code coverage
shell: bash -el {0}
run: |
mkdir -p $(python -m site --user-site)
printf "import coverage\ncoverage.process_startup()" \
> "$(python -m site --user-site)/usercustomize.py"
- name: Set COVERAGE_PROCESS_START env variable
shell: bash -el {0}
run: |
echo "COVERAGE_PROCESS_START=${PWD}/.coveragerc" >> $GITHUB_ENV
echo "COVERAGE_RCFILE=${PWD}/.coveragerc" >> $GITHUB_ENV

- name: Run pytest with multiple workers in parallel
shell: micromamba-shell {0}
Expand Down Expand Up @@ -135,15 +146,65 @@ jobs:

- name: Run gunittest tests
shell: micromamba-shell {0}
run: .github/workflows/test_thorough.sh --config .github/workflows/macos_gunittest.cfg
run: |
export INITIAL_GISBASE="$(grass --config path)"
export INITIAL_PWD="${PWD}"
grass --tmp-project XY --exec \
g.download.location url=${{ env.SAMPLE_DATA_URL }} path=$HOME
grass --tmp-project XY --exec \
${PYTHON} -m grass.gunittest.main \
--grassdata $HOME --location nc_spm_full_v2alpha2 --location-type nc \
--min-success 100 --config .github/workflows/macos_gunittest.cfg
env:
SAMPLE_DATA_URL: "file://${{ github.workspace }}/sample-data/\
nc_spm_full_v2alpha2.tar.gz"

PYTHON: coverage run
- name: Fix non-standard installed script paths in coverage data
shell: bash -el {0}
run: |
export PYTHONPATH=`grass --config python_path`:$PYTHONPATH
# export LD_LIBRARY_PATH=$(grass --config path)/lib:$LD_LIBRARY_PATH
export INITIAL_GISBASE="$(grass --config path)"
export INITIAL_PWD="${PWD}"
coverage combine
python utils/coverage_mapper.py
coverage combine
- name: Show python coverage report summary
shell: bash -el {0}
run: |
export PYTHONPATH=`grass --config python_path`:$PYTHONPATH
# export LD_LIBRARY_PATH=$(grass --config path)/lib:$LD_LIBRARY_PATH
export INITIAL_GISBASE="$(grass --config path)"
export INITIAL_PWD="${PWD}"
coverage report
coverage json
- name: Generate HTML coverage report
shell: bash -el {0}
run: |
export PYTHONPATH=`grass --config python_path`:$PYTHONPATH
# export LD_LIBRARY_PATH=$(grass --config path)/lib:$LD_LIBRARY_PATH
export INITIAL_GISBASE="$(grass --config path)"
export INITIAL_PWD="${PWD}"
coverage html
- name: Make HTML test report available
if: ${{ !cancelled() }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: testreport-macOS
name: testreport-${{ runner.os }}
path: testreport
retention-days: 3
- name: Make python-only code coverage test report available
if: ${{ !cancelled() }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: >-
python-codecoverage-report-${{ 'macos-14' }}
path: coverage_html_report
retention-days: 1
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5.4.3
with:
verbose: true
flags: gunittest-${{ 'macos-14' }}
name: gunittest-${{ 'macos-14' }}
token: ${{ secrets.CODECOV_TOKEN }}
8 changes: 7 additions & 1 deletion .github/workflows/test_thorough.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@ set -e

SAMPLE_DATA_URL=${SAMPLE_DATA_URL:-"https://grass.osgeo.org/sampledata/north_carolina/nc_spm_full_v2alpha2.tar.gz"}

if [[ -z "${PYTHON}" ]]; then
PYTHON="python3"
else
PYTHON="${PYTHON}"
fi

grass --tmp-project XY --exec \
g.download.project url=$SAMPLE_DATA_URL path=$HOME

grass --tmp-project XY --exec \
python3 -m grass.gunittest.main \
${PYTHON} -m grass.gunittest.main \
--grassdata $HOME --location nc_spm_full_v2alpha2 --location-type nc \
--min-success 100 $@
92 changes: 86 additions & 6 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,41 @@ jobs:
echo "${delete[@]}"
for target in "${delete[@]}"; do
for i in "${!array[@]}"; do
if [[ ${array[i]} = $target ]]; then
if [[ ${array[i]} = "$target" ]]; then
unset 'array[i]'
fi
done
done
unset new_array
for i in "${!array[@]}"; do
new_array+=( "${array[i]}" )
new_array+=( "${array[i]}" )
done
echo "Excluded folders:"
echo "${new_array[@]}"
printf -v extra_exclude './%s/* ' "${new_array[@]}"
echo "Exclusion string to add to gunittest config"
echo "${extra_exclude}"
echo "extra-exclude=${extra_exclude}" >> "${GITHUB_OUTPUT}"
echo "Inclusion string for tags"
printf -v extra_include_tag ' %s' "${delete[@]}"
extra_include_tag="${extra_include_tag:1}" # trim extra first space
extra_include_tag=${extra_include_tag// /-} # replace spaces by hyphens
echo "${extra_include_tag}"
echo "extra-include-tag=${extra_include_tag}" >> "${GITHUB_OUTPUT}"
echo "Truncated string for codecov upload"
max_flag_len=45
max_flag_prefix_len=33 # gunittest-ubuntu-22.04_without_x-
max_flag_suffix_len=$((max_flag_len - max_flag_prefix_len))
extra_include_tag_len=${#extra_include_tag} # string's length
extra_include_tag_len_len=${#extra_include_tag_len} # length of string's length
if [[ "${extra_include_tag_len}" -gt "${max_flag_suffix_len}" ]]; then
# Extra include too long
extra_include_tag_trunc="${extra_include_tag:0:$max_flag_suffix_len-1-$extra_include_tag_len_len}.${extra_include_tag_len}"
else
extra_include_tag_trunc="${extra_include_tag}"
fi
echo "${extra_include_tag_trunc}"
echo "extra-include-tag-trunc=${extra_include_tag_trunc}" >> "${GITHUB_OUTPUT}"
env:
DELETE_ARRAY: ${{ matrix.extra-include }}

Expand All @@ -107,6 +127,8 @@ jobs:
sudo apt-get install -y wget git gawk findutils
xargs -a <(awk '! /^ *(#|$)/' ".github/workflows/apt.txt") -r -- \
sudo apt-get install -y --no-install-recommends --no-install-suggests
- name: Install python coverage tool
run: pip install coverage

- name: Create installation directory
run: |
Expand Down Expand Up @@ -140,12 +162,19 @@ jobs:
echo "$HOME/install/bin" >> $GITHUB_PATH

- name: Print installed versions
if: always()
if: ${{ !cancelled() }}
run: .github/workflows/print_versions.sh

- name: Test executing of the grass command
run: .github/workflows/test_simple.sh

- name: Place a usercustomize.py file enabling subprocess code coverage
if: false
run: |
mkdir -p $(python -m site --user-site)
printf "import coverage\ncoverage.process_startup()" \
> "$(python -m site --user-site)/usercustomize.py"

- name: Cache GRASS Sample Dataset
id: cached-data
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
Expand All @@ -163,19 +192,70 @@ jobs:
SAMPLE_DATA: "https://grass.osgeo.org/sampledata/north_carolina/\
nc_spm_full_v2alpha2.tar.gz"

- name: Set COVERAGE_PROCESS_START env variable
run: |
echo "COVERAGE_PROCESS_START=${PWD}/.coveragerc" >> $GITHUB_ENV
echo "COVERAGE_RCFILE=${PWD}/.coveragerc" >> $GITHUB_ENV

- name: Run tests
run: .github/workflows/test_thorough.sh --config .gunittest.extra.cfg
run: |
export INITIAL_GISBASE="$(grass --config path)"
INITIAL_PWD="${PWD}" .github/workflows/test_thorough.sh --config .gunittest.extra.cfg
env:
PYTHON: coverage run
SAMPLE_DATA_URL: "file://${{ github.workspace }}/sample-data/\
nc_spm_full_v2alpha2.tar.gz"
- name: Fix non-standard installed script paths in coverage data
run: |
export PYTHONPATH=`grass --config python_path`:$PYTHONPATH
export LD_LIBRARY_PATH=$(grass --config path)/lib:$LD_LIBRARY_PATH
export INITIAL_GISBASE="$(grass --config path)"
export INITIAL_PWD="${PWD}"
coverage combine
python utils/coverage_mapper.py
coverage combine

- name: Show python coverage report summary
run: |
export PYTHONPATH=`grass --config python_path`:$PYTHONPATH
export LD_LIBRARY_PATH=$(grass --config path)/lib:$LD_LIBRARY_PATH
export INITIAL_GISBASE="$(grass --config path)"
export INITIAL_PWD="${PWD}"
coverage report
- name: Generate HTML coverage report
run: |
export PYTHONPATH=`grass --config python_path`:$PYTHONPATH
export LD_LIBRARY_PATH=$(grass --config path)/lib:$LD_LIBRARY_PATH
export INITIAL_GISBASE="$(grass --config path)"
export INITIAL_PWD="${PWD}"
coverage html

- name: Make HTML test report available
if: ${{ always() }}
if: ${{ !cancelled() }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: testreport-${{ matrix.os }}-${{ matrix.config }}-${{ matrix.extra-include }}
name: >-
testreport-${{ matrix.os }}-${{ matrix.config }}-${{
'' }}${{ steps.get-exclude.outputs.extra-include-tag }}
path: testreport
retention-days: 3
- name: Make python-only code coverage test report available
if: ${{ !cancelled() }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: >-
python-codecoverage-report-${{ matrix.os }}-${{ matrix.config }}-${{
'' }}${{ steps.get-exclude.outputs.extra-include-tag }}
path: coverage_html_report
retention-days: 1

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5.4.3
with:
verbose: true
flags: gunittest-${{ matrix.config }}-${{ steps.get-exclude.outputs.extra-include-tag-trunc }}
name: gunittest-${{ matrix.config }}-${{ steps.get-exclude.outputs.extra-include-tag-trunc }}
token: ${{ secrets.CODECOV_TOKEN }}

build-and-test-success:
name: Build & Test Result
Expand Down
1 change: 1 addition & 0 deletions macos/files/conda-requirements-dev-arm64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ cairo
clangxx_osx-arm64
clang_osx-arm64
cmake
coverage
expat
fftw
flex
Expand Down
Loading