Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 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
6729112
Update ubuntu.yml slipcover help
echoix Jul 25, 2024
a1c24d0
Update ubuntu.yml comment out coveragepy
echoix Jul 25, 2024
860b6a2
Update ubuntu.yml use slipcover
echoix Jul 25, 2024
23b8bcd
DEBUG: Update ubuntu.yml add db
echoix Jul 25, 2024
a6df577
Update ubuntu.yml if not cancelled codecov
echoix Jul 25, 2024
6f0d862
Update ubuntu.yml adjust comments
echoix Jul 25, 2024
473f2bf
Update ubuntu.yml slipcover json output
echoix Jul 25, 2024
68ca446
Update ubuntu.yml slipcover add source
echoix Jul 25, 2024
be409fe
Update ubuntu.yml slipcover outputfile
echoix Jul 25, 2024
b542829
Update ubuntu.yml do not add coverage from py
echoix Jul 25, 2024
4ffa54b
Update ubuntu.yml output file name
echoix Jul 25, 2024
c00427b
Update ubuntu.yml ls -la
echoix Jul 25, 2024
ad8ec1b
Update ubuntu.yml remove json
echoix Jul 25, 2024
469998d
Update ubuntu.yml add source .
echoix Jul 25, 2024
0e8e705
Update ubuntu.yml add more sources
echoix Jul 26, 2024
630996a
utils: New script to convert slipcover's output to coverage data file
echoix Jul 29, 2024
524be9c
CI(ubuntu): Convert slipcover's output to use coverage.py reporting
echoix Jul 29, 2024
3410a5f
Update slipcover_to_coverage.py
echoix Jul 29, 2024
5a10112
DEBUG: show slipcover.json data
echoix Jul 29, 2024
c5b673d
Update ubuntu.yml slipcover scripts
echoix Jul 29, 2024
f5e0ac1
Update ubuntu.yml
echoix Jul 29, 2024
735b582
Update ubuntu.yml
echoix Jul 29, 2024
9423ceb
Update ubuntu.yml continue-on-error: true
echoix Jul 29, 2024
fc0c3d4
Add symbolic links to scripts to files with .py extensions
echoix Aug 3, 2024
cf186e5
CI: Send slipcover source argument as a single comma delimited list
echoix Sep 26, 2024
caff68a
Disable replacing scripts with symbolic links
echoix Sep 26, 2024
8af3f61
Fix: SIM115 Use a context manager for opening files in utils/slipcove…
echoix Jul 26, 2025
943ef67
CI: Use only one flag for codecov uploads
echoix Jul 26, 2025
588c49e
Merge branch 'main' into gunittest-coverage-slipcover-01
echoix Jul 26, 2025
c939ff6
CI: Make slipcover output file absolute
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
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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 $@
127 changes: 121 additions & 6 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
# newlines with spaces, and strip newline at end.
# See https://yaml-multiline.info/
- temporal
- db
- >-
db display doc docker general gui
imagery lib misc ps python raster raster3d scripts
Expand Down Expand Up @@ -76,21 +77,41 @@
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 +128,9 @@
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 tools
run: pip install coverage slipcover
- run: python -m slipcover --help

- name: Create installation directory
run: |
Expand Down Expand Up @@ -139,13 +163,35 @@
run: |
echo "$HOME/install/bin" >> $GITHUB_PATH

- name: Replace scripts with symbolic links to have files with .py extensions
if: ${{ false }}
run: |
cd "$(grass --config path)"
cp -R scripts/ scrips_orig/
# Output first lines of files
head $(grass --config path)/scripts/* -n1 -q
# Rename files to have .py extension
ls | xargs -I fileName mv fileName fileName.py
# Copy with symbolic link
for old in scripts/*.py
do new=`echo $old | sed -e's/.py//'`
cp --symbolic-link "$old" "$new"
done
ls -la

- 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
# 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 +209,88 @@
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)"
export INITIAL_PWD="${PWD}"
#export PYTHON="${PYTHON} --source ${INITIAL_PWD}/ --source ${INITIAL_GISBASE}/"
#export PYTHON="${PYTHON} --source ${INITIAL_GISBASE}/scripts"
echo "$PYTHON"
export PYTHON="${PYTHON} --source .,${INITIAL_PWD}/,${INITIAL_GISBASE}/,${INITIAL_GISBASE}/scripts"
echo "$PYTHON"
.github/workflows/test_thorough.sh --config .gunittest.extra.cfg
env:
PYTHON: >-
python -m slipcover
--json
--out ${{ github.workspace }}/slipcover.json
#--source ${{ github.workspace }}

Check failure on line 232 in .github/workflows/ubuntu.yml

View workflow job for this annotation

GitHub Actions / Additional checks

232:12 [comments] missing starting space in comment
SAMPLE_DATA_URL: "file://${{ github.workspace }}/sample-data/\
nc_spm_full_v2alpha2.tar.gz"
- run: cat slipcover.json
- run: jq . slipcover.json
- name: Convert slipcover's output to coverage.py data file
run: python utils/slipcover_to_coverage.py slipcover.json .coverage.slipcover
- run: ls -la
- 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
continue-on-error: true
- 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
continue-on-error: true

- 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
if: ${{ !cancelled() }}
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
28 changes: 28 additions & 0 deletions utils/slipcover_to_coverage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from coverage import CoverageData
import json
from pathlib import Path
import sys


def convert_slipcover_json_to_coverage(input_path, output_path):
with Path(input_path).open("r") as input_fp:
input_json = json.load(input_fp)
data_file = CoverageData(output_path)
data_file.read()

line_data = {
str(Path().joinpath(file).resolve()): data["executed_lines"]
for file, data in input_json["files"].items()
}
data_file.add_lines(line_data)
data_file.write()


def main():
infile = sys.argv[1]
outfile = sys.argv[2]
convert_slipcover_json_to_coverage(infile, outfile)


if __name__ == "__main__":
main()
Loading