diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 00000000000..fd29122492e --- /dev/null +++ b/.coveragerc @@ -0,0 +1,36 @@ +[run] +branch = True +dynamic_context = test_function +concurrency = multiprocessing,thread +parallel = True +data_file = ${INITIAL_PWD-.}/.coverage +omit = ${INITIAL_PWD-.}/testreport +source = + ${INITIAL_PWD-.}/ + ${INITIAL_GISBASE-/usr/local/grass84}/ + + +[report] +; Regexes for lines to exclude from consideration +exclude_also = + ; Don't complain about missing debug-only code: + def __repr__ + if self\.debug + + ; Don't complain if tests don't hit defensive assertion code: + raise AssertionError + raise NotImplementedError + + ; Don't complain if non-runnable code isn't run: + ; if 0: + ; if __name__ == .__main__.: + + ; Don't complain about abstract methods, they aren't run: + @(abc\.)?abstractmethod + +ignore_errors = True +precision = 2 + +[html] +directory = coverage_html_report +show_contexts = true diff --git a/.github/workflows/clang-format-check.yml b/.github/workflows/clang-format-check.yml index fb7409876cf..6d896fb1b69 100644 --- a/.github/workflows/clang-format-check.yml +++ b/.github/workflows/clang-format-check.yml @@ -1,25 +1,67 @@ --- -name: ClangFormat Check -on: - push: - branches: - - main - - releasebranch_* - pull_request: - branches: - - main - - releasebranch_* -concurrency: - group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} - cancel-in-progress: true -jobs: - formatting-check: - name: Formatting Check - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 - - name: Run clang-format style check for C/C++/Protobuf programs. - uses: jidicula/clang-format-action@v4.11.0 - with: - clang-format-version: '15' - check-path: . + name: ClangFormat Check + on: + push: + branches: + - main + - releasebranch_* + pull_request: + branches: + - main + - releasebranch_* + - "*" + concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref_protected != true }} + # permissions: {} + permissions: write-all + jobs: + formatting-check: + name: Formatting Check + runs-on: ubuntu-latest + # permissions: + # pull-requests: write + steps: + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - uses: DoozyX/clang-format-lint-action@11b773b1598aa4ae3b32f023701bca5201c3817d # v0.17 + with: + source: "." + clangFormatVersion: 15 + inplace: True + - name: Verify Changed files + uses: tj-actions/verify-changed-files@d774a4c7ebe335445d79c7b44138f56a76058ba0 # v19.0.0 + id: verify-changed-files + - run: echo '${{toJson(steps.verify-changed-files.outputs)}}' + - name: List all changed files tracked and untracked files + run: | + echo "Changed files: ${{ steps.verify-changed-files.outputs.changed_files }}" + - name: Add job summary without changed files + if: ${{ steps.verify-changed-files.outputs.files_changed == 'false' }} + run: | + { + echo "### Changed files:" + echo "No files were changed by clang-format" + } >> "$GITHUB_STEP_SUMMARY" + - name: Add job summary with changed files + if: ${{ steps.verify-changed-files.outputs.files_changed == 'true' }} + run: | + { + echo '### Changed files:' + echo '```' + echo '${{ steps.verify-changed-files.outputs.changed_files }}' + echo '```' + } >> "$GITHUB_STEP_SUMMARY" + - uses: parkerbxyz/suggest-changes@f5b10bcbfe35840153c0e823095d260d5abad1f9 # v1.0.0 + with: + comment: | + Please commit the suggested changes from clang-format. + + Suggestions can only be added to lines near lines changed in this PR. + - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 + if: always() + with: + name: my-artifact + path: | + .clang-format + ${{ steps.verify-changed-files.outputs.changed_files }} + \ No newline at end of file diff --git a/.github/workflows/osgeo4w.yml b/.github/workflows/osgeo4w.yml index cfbb0f6ca14..85f59c8e6c5 100644 --- a/.github/workflows/osgeo4w.yml +++ b/.github/workflows/osgeo4w.yml @@ -26,47 +26,250 @@ jobs: os: - windows-2019 fail-fast: false - steps: + - name: Collect Workflow Telemetry + uses: catchpoint/workflow-telemetry-action@v1 + with: + comment_on_pr: false - name: Set git to use LF run: | git config --global core.autocrlf false git config --global core.eol lf + - run: | + echo "PackageDir=OSGeo4W_v2-Packages" >> $env:GITHUB_ENV + - uses: actions/github-script@v7 + id: osgeo4w-pkgs + with: + result-encoding: string + script: >- + return process.env.Deps + .split(",").join(" ").split(" ") + .filter((x) => x != "") + // .join(","); + .join(" -P "); + env: + Deps: >- + proj-devel,gdal-devel,geos-devel,libtiff-devel,libpng-devel, + netcdf-devel,cairo-devel,fftw,freetype-devel,gdal-ecw, + gdal-mrsid,liblas-devel,libxdr,libpq-devel,pdcurses, + python3-matplotlib,python3-numpy,python3-ply,python3-pywin32, + python3-wxpython,zstd-devel + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 - uses: msys2/setup-msys2@v2 with: path-type: inherit - location: D:\ + # location: D:\ + msystem: mingw64 update: true - install: tar libintl make bison flex diffutils git dos2unix zip mingw-w64-x86_64-toolchain - mingw-w64-x86_64-fftw mingw-w64-x86_64-lapack mingw-w64-x86_64-pkgconf - mingw-w64-x86_64-gcc mingw-w64-x86_64-ccache mingw-w64-x86_64-zlib mingw-w64-x86_64-libiconv - mingw-w64-x86_64-bzip2 mingw-w64-x86_64-gettext mingw-w64-x86_64-libsystre - mingw-w64-x86_64-libtre-git mingw-w64-x86_64-libwinpthread-git mingw-w64-x86_64-libpng - mingw-w64-x86_64-pcre + # install: tar libintl bison flex git dos2unix zip + pacboy: >- + tar: libintl: bison: flex: git: dos2unix: zip: + make: diffutils:p toolchain:p + fftw:p lapack:p pkgconf:p gcc:p ccache:p zlib:p libiconv:p bzip2:p gettext:p + libsystre:p libtre-git:p libwinpthread-git:p libpng:p pcre:p + # not removed: mingw-w64-x86_64-libpng + + + # - name: Restore PROJ data cache + # id: restore-proj-data + # uses: actions/cache/restore@v3 + # with: + # # The key here will never match, it will always use the restore-keys. + # # Since we don't have a lockfile or a way of knowing which + # # version of proj-data is needed used, we cannot have a better key. + # key: OSGeo4W-proj-data-${{ env.PackageDir }}- + # restore-keys: | + # OSGeo4W-proj-data-${{ env.PackageDir }}- + # path: ${{ env.PackageDir }}/**/proj-data** + # - name: Restore OSGeo4W package cache + # id: restore-pkgs + # uses: actions/cache/restore@v3 + # with: + # # The key here will never match, it will always use the restore-keys. + # # Since we don't have a lockfile or a way of knowing which + # # dependencies were used, we cannot use hashfiles() on files that + # # don't exist yet. + # key: OSGeo4W-packages-cache-${{ env.PackageDir }}- + # restore-keys: | + # OSGeo4W-packages-cache-${{ env.PackageDir }}- + # path: | + # ${{ env.PackageDir }}/*/*/*/* + # !${{ env.PackageDir }}/*/*/*/proj/proj-data + # !${{ env.PackageDir }}/*/*/*/gdal/gdal-dev + # !${{ env.PackageDir }}/*/*/setup.ini + # - name: Save hashes of restored cache before update + # id: restored-cache-hash + # run: | + # echo "proj-data=${{ hashfiles( + # format('{0}/**/proj-data**', env.PackageDir) ) + # }}" >> "$env:GITHUB_OUTPUT" + # echo "packages=${{ hashfiles( + # format('{0}/**', env.PackageDir), + # format('!{0}/**/proj-data**', env.PackageDir), + # format('!{0}/**/gdal-dev/**', env.PackageDir), + # format('!{0}/**/setup.ini', env.PackageDir) ) + # }}" >> "$env:GITHUB_OUTPUT" + # - run: echo "${{ hashFiles( format('{0}{1}', env.PackageDir,'/**/proj-data**')) }}" + - name: Download OSGeo4W + run: Invoke-WebRequest -Uri "${{ env.BASE_URL }}/${{ env.FILE_NAME }}" -OutFile "${{ env.FILE_NAME }}" + env: + BASE_URL: https://download.osgeo.org/osgeo4w/v2 + FILE_NAME: osgeo4w-setup.exe - name: Install OSGeo4W run: | - $exe = 'osgeo4w-setup.exe' - $url = 'http://download.osgeo.org/osgeo4w/v2/' + $exe - (New-Object System.Net.WebClient).DownloadFile($url, $exe) - Start-Process ('.\'+$exe) -ArgumentList '-A -g -k -q \ - -s http://download.osgeo.org/osgeo4w/v2/ -P ${{ env.Deps }}' -Wait + .\"${{ env.FILE_NAME }}" -A -g -k -q --no-desktop --no-shortcuts --no-startmenu -s ${{ env.BASE_URL }} -P ${{ env.Deps }} -l "${{ env.PackageDir }}" | Out-Default env: - Deps: "proj-devel,gdal-devel,geos-devel,libtiff-devel,libpng-devel,\ - pdal-devel,netcdf-devel,cairo-devel,fftw,freetype-devel,gdal-ecw,\ - gdal-mrsid,liblas-devel,libxdr,libpq-devel,pdcurses,\ - python3-matplotlib,python3-numpy,python3-ply,python3-pywin32,\ - python3-wxpython,regex-devel,zstd-devel" + BASE_URL: https://download.osgeo.org/osgeo4w/v2 + FILE_NAME: osgeo4w-setup.exe + Deps: ${{ steps.osgeo4w-pkgs.outputs.result}} + # Deps: >- + # proj-devel,gdal-devel,geos-devel,libtiff-devel,libpng-devel,netcdf-devel,cairo-devel,fftw,freetype-devel,gdal-ecw,gdal-mrsid,liblas-devel,libxdr,libpq-devel,pdcurses,python3-matplotlib,python3-numpy,python3-ply,python3-pywin32,python3-wxpython,zstd-devel + + # removed: regex-devel,pdal-devel, + + # - name: Remove outdated OSGeo4W cached packages + # shell: msys2 {0} + # # First sed pattern: + # # Filters out the lines after the [prev] section until next blank line by + # # keeping lines between "@ osgeo4w-package-name" and "[prev]" or a blank line. + # # Adapted from: https://github.com/jef-n/OSGeo4W/blob/9b26e568b5660b9e18839076327cfdade769fcd9/scripts/build-helpers#L376 + # # Second sed pattern: + # # Keeps only the path subgroup of lines starting with `install:` or `license:` + # # Adapted from https://github.com/jef-n/OSGeo4W/blob/9b26e568b5660b9e18839076327cfdade769fcd9/scripts/build-inorder.pl#L22-L23 + # run: >- + # pwd \n + # find ${{ env.PackageDir }} -type f \( ! -name "setup.ini" $( + # sed -rne '/^@ .*$/,/^(\[prev\])?$/p' setup.ini | + # sed -nr 's/^(install|source|license):\s+(\S+)\s+[0-9]+\s+\S+/\2/p' | + # xargs printf ' -a ! -path ${{ env.PackageDir }}/http*/%s\n' + # ) \) + # continue-on-error: true + # env: + # PackageDir: ${{ env.PackageDir }} + + + # - name: Install OSGeo4W + # run: | + # $exe = 'osgeo4w-setup.exe' + # $url = 'http://download.osgeo.org/osgeo4w/v2/' + $exe + # (New-Object System.Net.WebClient).DownloadFile($url, $exe) + # Start-Process ('.\'+$exe) -ArgumentList '-A -g -k -q \ + # -s http://download.osgeo.org/osgeo4w/v2/ -P ${{ env.Deps }}' -Wait + # env: + # Deps: "proj-devel,gdal-devel,geos-devel,libtiff-devel,libpng-devel,\ + # pdal-devel,netcdf-devel,cairo-devel,fftw,freetype-devel,gdal-ecw,\ + # gdal-mrsid,liblas-devel,libxdr,libpq-devel,pdcurses,\ + # python3-matplotlib,python3-numpy,python3-ply,python3-pywin32,\ + # python3-wxpython,regex-devel,zstd-devel" + # shell: pwsh + + # - name: Get hashes of caches to save + # id: save-cache-hash + # run: | + # echo "proj-data=${{ hashfiles( + # format('{0}/**/proj-data**', env.PackageDir) ) + # }}" >> "$env:GITHUB_OUTPUT" + # echo "packages=${{ hashfiles( + # format('{0}/**', env.PackageDir), + # format('!{0}/**/proj-data**', env.PackageDir), + # format('!{0}/**/gdal-dev/**', env.PackageDir), + # format('!{0}/**/setup.ini', env.PackageDir) ) + # }}" >> "$env:GITHUB_OUTPUT" + # - name: Save proj-data cache + # if: ${{ steps.restored-cache-hash.outputs.proj-data != steps.save-cache-hash.outputs.proj-data }} + # uses: actions/cache/save@v3 + # with: + # key: OSGeo4W-proj-data-${{ env.PackageDir }}-${{ steps.save-cache-hash.outputs.proj-data }} + # path: ${{ env.PackageDir }}/**/proj-data** + # - name: Save OSGeo4W package cache + # if: ${{ steps.restored-cache-hash.outputs.packages != steps.save-cache-hash.outputs.packages }} + # uses: actions/cache/save@v3 + # with: + # key: OSGeo4W-packages-cache-${{ env.PackageDir }}-${{ steps.save-cache-hash.outputs.packages }} + # path: | + # ${{ env.PackageDir }}/*/*/*/* + # !${{ env.PackageDir }}/*/*/*/proj/proj-data + # !${{ env.PackageDir }}/*/*/*/gdal/gdal-dev + # !${{ env.PackageDir }}/*/*/setup.ini + + + - name: ccache + uses: hendrikmuhs/ccache-action@v1.2 + # - run: ccache -s -v -v + # if: ${{ always() }} + # shell: msys2 {0} + # - name: Configure ccache settings + # run: | + # ccache --set-config=cache_dir='${{ github.workspace }}/.ccache' + # ccache --set-config=max_size=500M + # ccache --set-config=compression=true + # echo "ccache config:" + # ccache --show-config + # ccache --zero-stats + # shell: msys2 {0} + # - name: Configure ccache settings + # run: | + # ccache --set-config=cache_dir='${{ github.workspace }}/.ccache' + # ccache --set-config=max_size=500M + # ccache --set-config=compression=true + # echo "ccache config:" + # ccache -p + # shell: msys2 {0} + - run: ls -la mswindows/osgeo4w/ + shell: msys2 {0} + - run: ls -la /c/OSGeo4W/bin/ + shell: msys2 {0} + - run: pwd + shell: msys2 {0} + - run: ls -la mswindows/osgeo4w/ + shell: msys2 {0} + - run: ls -la /c/OSGeo4W/bin/ + shell: msys2 {0} - name: Compile GRASS GIS - run: D:\msys64\usr\bin\bash.exe -l (''+(Get-Location)+'\.github\workflows\build_osgeo4w.sh') (Get-Location) + run: SRC="$(pwd)" ./mswindows/osgeo4w/build_osgeo4w.sh + shell: msys2 {0} + env: + MAKEFLAGS: -j 4 + OSGEO4W_ROOT_MSYS: /c/OSGeo4W + UNITTEST: 1 + GCC_COLORS: 'error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' + CC: 'ccache x86_64-w64-mingw32-gcc' + CXX: 'ccache x86_64-w64-mingw32-g++' + + - run: ls -la mswindows/osgeo4w/ + if: ${{ always() }} + shell: msys2 {0} + - run: ls -la /c/OSGeo4W/bin/ + if: ${{ always() }} + shell: msys2 {0} + # - run: mkdir -p .ccache && ls -la .ccache + # if: ${{ always() }} + # shell: msys2 {0} + # - run: ccache --show-stats -v -v + # if: ${{ always() }} + # shell: msys2 {0} + + + #- name: Compile GRASS GIS + #run: .github/workflows/build_osgeo4w.sh . + #shell: msys2 {0} + #env: + #MAKEFLAGS: -j0 + #run: D:\msys64\usr\bin\bash.exe -l (''+(Get-Location)+'\.github\workflows\build_osgeo4w.sh') (Get-Location) - name: Test executing of the grass command run: .github/workflows/test_simple.bat 'C:\OSGeo4W\opt\grass\grass84.bat' - + #shell: msys2 {0} + #- run: exit 1 - name: Test executing of the grass command in bash - run: D:\msys64\usr\bin\bash.exe .github/workflows/test_simple.sh + run: .github/workflows/test_simple.sh + shell: msys2 {0} + # run: D:\msys64\usr\bin\bash.exe .github/workflows/test_simple.sh - name: Run tests run: .github/workflows/test_thorough.bat 'C:\OSGeo4W\opt\grass\grass84.bat' 'C:\OSGeo4W\bin\python3' + #run: .github/workflows/test_thorough.bat 'C:\OSGeo4W\opt\grass\grass84.bat' 'C:\OSGeo4W\bin\python3' + \ No newline at end of file diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 9b8db8ae440..8ac2628d571 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -10,6 +10,7 @@ on: branches: - main - releasebranch_* + - '*' jobs: pytest: @@ -51,7 +52,7 @@ jobs: python -m pip install --upgrade pip pip install -r .github/workflows/python_requirements.txt pip install -r .github/workflows/optional_requirements.txt - pip install pytest pytest-timeout pytest-github-actions-annotate-failures pytest-xdist + pip install pytest pytest-timeout pytest-github-actions-annotate-failures pytest-xdist pytest-cov - name: Create installation directory run: | @@ -63,11 +64,19 @@ jobs: - name: Build run: .github/workflows/build_${{ matrix.os }}.sh $HOME/install + env: + CFLAGS: -fPIC --coverage -g -O0 -fprofile-abs-path + CXXFLAGS: -fPIC --coverage -g -O0 -fprofile-abs-path + LDFLAGS: --coverage - name: Add the bin directory to PATH run: | echo "$HOME/install/bin" >> $GITHUB_PATH + - name: Print installed versions + if: always() + run: .github/workflows/print_versions.sh + - name: Test executing of the grass command run: .github/workflows/test_simple.sh @@ -75,11 +84,19 @@ jobs: run: | export PYTHONPATH=`grass --config python_path`:$PYTHONPATH export LD_LIBRARY_PATH=$HOME/install/grass84/lib:$LD_LIBRARY_PATH - pytest --numprocesses auto . + INITIAL_PWD="${PWD}" pytest --verbose --color=yes --cov --cov-branch --numprocesses auto . --dist worksteal + env: + INITIAL_GISBASE: $HOME/install/grass84 + + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v4 + with: + verbose: true + # gcov: true + flags: pytest-python-${{ matrix.python-version }} + name: pytest-python-${{ matrix.python-version }} + token: ${{ secrets.CODECOV_TOKEN }} - - name: Print installed versions - if: always() - run: .github/workflows/print_versions.sh pytest-success: name: pytest Result needs: diff --git a/.github/workflows/test_thorough.sh b/.github/workflows/test_thorough.sh index 6c4d9e32b91..fd4c4f276cf 100755 --- a/.github/workflows/test_thorough.sh +++ b/.github/workflows/test_thorough.sh @@ -3,10 +3,17 @@ # fail on non-zero return code from a subprocess set -e +if [[ -z "${PYTHON}" ]]; then + PYTHON="python3" +else + PYTHON="${PYTHON}" +fi + grass --tmp-location XY --exec \ g.download.location url=https://grass.osgeo.org/sampledata/north_carolina/nc_spm_full_v2alpha2.tar.gz path=$HOME + grass --tmp-location 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 $@ diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 9e42b728089..23895cd6116 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -76,14 +76,14 @@ 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[@]}" @@ -91,6 +91,26 @@ jobs: 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 }} @@ -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: | @@ -119,6 +141,9 @@ jobs: - name: Set LD_LIBRARY_PATH for compilation run: | echo "LD_LIBRARY_PATH=$HOME/install/lib" >> $GITHUB_ENV + - name: Set COVERAGE_PROCESS_START env variable + run: | + echo "COVERAGE_PROCESS_START=${PWD}/.coveragerc" >> $GITHUB_ENV - name: Print build environment variables shell: bash -el {0} @@ -130,9 +155,10 @@ jobs: - name: Build env: # TODO: -pedantic-errors here won't go through ./configure (with GNU C) - CFLAGS: -fPIC -Wvla + CFLAGS: -fPIC -Wvla --coverage -g -O0 -fprofile-abs-path # TODO: -pedantic-errors here won't compile - CXXFLAGS: -fPIC + CXXFLAGS: -fPIC --coverage -g -O0 -fprofile-abs-path + LDFLAGS: --coverage run: .github/workflows/build_${{ matrix.config }}.sh $HOME/install -Werror - name: Add the bin directory to PATH @@ -146,16 +172,43 @@ jobs: - name: Test executing of the grass command run: .github/workflows/test_simple.sh + - name: Place a sitecustomize.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)/sitecustomize.py" - name: Run tests - run: .github/workflows/test_thorough.sh --config .gunittest.extra.cfg - + run: INITIAL_PWD="${PWD}" .github/workflows/test_thorough.sh --config .gunittest.extra.cfg + env: + PYTHON: coverage run --branch --parallel-mode --concurrency=multiprocessing,thread + INITIAL_GISBASE: $HOME/install/grass84 + - run: coverage combine + - name: Show python coverage report summary + run: coverage report + - run: coverage html - name: Make HTML test report available if: ${{ always() }} uses: actions/upload-artifact@v4 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: ${{ always() }} + uses: actions/upload-artifact@v4 + with: + name: python-codecoverage-report-${{ matrix.os }}-${{ matrix.config }}-${{ steps.get-exclude.outputs.extra-include-tag }} + path: coverage_html_report + retention-days: 3 + + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v4 + with: + verbose: true + # gcov: true + flags: gunittest,gunittest-${{ matrix.config }},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 diff --git a/.gitignore b/.gitignore index bc8ac301e89..6a0461193b9 100644 --- a/.gitignore +++ b/.gitignore @@ -49,3 +49,9 @@ test_keyvalue_result.txt # ignore paths generated by helper tools node_modules + +# Ignore code coverage files +*.gcov +*.gcno +*.gcda +.coverage diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 00000000000..0146fc8fc11 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,112 @@ +codecov: + notify: + # do not notify until at least 7 builds have been uploaded from the CI pipeline + # Change when more or less uploads are made, to not receive a GitHub + # comment notification too early after only pytest has uploaded coverage + after_n_builds: 7 +coverage: + status: + project: + default: + target: auto # auto compares coverage to the previous base commit + informational: true + patch: + default: + informational: true + +component_management: + individual_components: + - component_id: modules_database # this is an identifier that should not be changed + name: db # this is a display name, and can be changed freely + paths: + - db/** + - lib/db/** + - scripts/db.*/** + - component_id: modules_display + name: display + paths: + - display/** + - lib/display/** + - scripts/d.*/** + - component_id: modules_general + name: general + paths: + - general/** + - scripts/g.*/** + - component_id: gui + name: gui + paths: + - gui/** + - component_id: modules_imagery + name: imagery + paths: + - imagery/** + - lib/imagery/** + - scripts/i.*/** + - component_id: man + name: man + paths: + - man/** + - component_id: modules_misc + name: imagery + paths: + - misc/** + - scripts/m.*/** + - component_id: modules_postscript + name: ps + paths: + - ps/** + - component_id: modules_raster + name: raster + paths: + - raster/** + - lib/raster/** + - scripts/r.*/** + - component_id: modules_raster3d + name: raster3d + paths: + - raster3d/** + - lib/raster3d/** + - scripts/r3.*/** + - component_id: modules_temporal + name: temporal + paths: + - temporal/** + - lib/temporal/** + - scripts/t.*/** + - component_id: modules_vector + name: vector + paths: + - vector/** + - lib/vector/** + - scripts/v.*/** + - component_id: utils + paths: + - utils/** + - component_id: scripts + paths: + - scripts/** + - component_id: library + name: lib + paths: + - lib/** + - component_id: python_pygrass + name: pygrass + paths: + - python/grass/pygrass/** + - component_id: python_gunittest + name: gunittest + paths: + - python/grass/gunittest/** + - component_id: notebooks + name: notebooks (jupyter) + paths: + - python/grass/jupyter/** + - "**/*.ipynb" + - component_id: python_library + name: python library + paths: + - python/grass/** + +# When modifying this file, please validate using +# curl -X POST --data-binary @codecov.yml https://codecov.io/validate diff --git a/mswindows/osgeo4w/build_osgeo4w.sh b/mswindows/osgeo4w/build_osgeo4w.sh index ecb6e951f5c..0fdb27377b7 100644 --- a/mswindows/osgeo4w/build_osgeo4w.sh +++ b/mswindows/osgeo4w/build_osgeo4w.sh @@ -21,14 +21,19 @@ export C_INCLUDE_PATH=".:${OSGEO4W_ROOT_MSYS}/include:${SRC}/dist.${ARCH}/includ export PYTHONHOME=${OSGEO4W_ROOT_MSYS}/apps/Python39 export ARCH=x86_64-w64-mingw32 +echo "Pwd is $(pwd)" +echo "Print env follows" +printenv +echo "Print env done" + ./configure \ - --host=${ARCH} \ + --host="${ARCH}" \ --with-libs="${OSGEO4W_ROOT_MSYS}/lib ${OSGEO4W_ROOT_MSYS}/bin" \ - --with-includes=${OSGEO4W_ROOT_MSYS}/include \ - --libexecdir=${OSGEO4W_ROOT_MSYS}/bin \ - --prefix=${OSGEO4W_ROOT_MSYS}/apps/grass \ - --bindir=${OSGEO4W_ROOT_MSYS}/bin \ - --includedir=${OSGEO4W_ROOT_MSYS}/include \ + --with-includes="${OSGEO4W_ROOT_MSYS}/include" \ + --libexecdir="${OSGEO4W_ROOT_MSYS}/bin" \ + --prefix="${OSGEO4W_ROOT_MSYS}/apps/grass" \ + --bindir="${OSGEO4W_ROOT_MSYS}/bin" \ + --includedir="${OSGEO4W_ROOT_MSYS}/include" \ --without-x \ --with-cxx \ --enable-shared \ @@ -38,32 +43,31 @@ export ARCH=x86_64-w64-mingw32 --with-nls \ --with-readline \ --with-blas \ - --with-lapack-includes=/mingw64/include/lapack \ + --with-lapack-includes="/mingw64/include/lapack" \ --with-freetype \ - --with-freetype-includes=${OSGEO4W_ROOT_MSYS}/include/freetype2 \ - --with-proj-share=${OSGEO4W_ROOT_MSYS}/share/proj \ - --with-proj-includes=${OSGEO4W_ROOT_MSYS}/include \ - --with-proj-libs=${OSGEO4W_ROOT_MSYS}/lib \ + --with-freetype-includes="${OSGEO4W_ROOT_MSYS}/include/freetype2" \ + --with-proj-share="${OSGEO4W_ROOT_MSYS}/share/proj" \ + --with-proj-includes="${OSGEO4W_ROOT_MSYS}/include" \ + --with-proj-libs="${OSGEO4W_ROOT_MSYS}/lib" \ --with-postgres \ - --with-postgres-includes=${OSGEO4W_ROOT_MSYS}/include \ - --with-postgres-libs=${OSGEO4W_ROOT_MSYS}/lib \ - --with-gdal=${SRC}/mswindows/osgeo4w/gdal-config \ - --with-geos=${SRC}/mswindows/osgeo4w/geos-config \ + --with-postgres-includes="${OSGEO4W_ROOT_MSYS}/include" \ + --with-postgres-libs="${OSGEO4W_ROOT_MSYS}/lib" \ + --with-gdal="${SRC}/mswindows/osgeo4w/gdal-config" \ + --with-geos="${SRC}/mswindows/osgeo4w/geos-config" \ --with-sqlite \ - --with-sqlite-includes=${OSGEO4W_ROOT_MSYS}/include \ - --with-sqlite-libs=${OSGEO4W_ROOT_MSYS}/lib \ + --with-sqlite-includes="${OSGEO4W_ROOT_MSYS}/include" \ + --with-sqlite-libs="${OSGEO4W_ROOT_MSYS}/lib" \ --with-regex \ --with-nls \ --with-zstd \ --with-odbc \ --with-cairo \ - --with-cairo-includes=${OSGEO4W_ROOT_MSYS}/include \ - --with-cairo-libs=$OSGEO4W_ROOT_MSYS/lib \ + --with-cairo-includes="${OSGEO4W_ROOT_MSYS}/include" \ + --with-cairo-libs="${OSGEO4W_ROOT_MSYS}/lib" \ --with-cairo-ldflags="-L${SRC}/mswindows/osgeo4w/lib -lcairo" \ --with-opengl=windows \ --with-bzlib \ - --with-liblas=${SRC}/mswindows/osgeo4w/liblas-config \ - --with-netcdf=${OSGEO4W_ROOT_MSYS}/bin/nc-config \ + --with-netcdf="${OSGEO4W_ROOT_MSYS}/bin/nc-config" \ --without-pdal make diff --git a/mswindows/osgeo4w/package.sh b/mswindows/osgeo4w/package.sh index c638c40ee62..81c99411b49 100755 --- a/mswindows/osgeo4w/package.sh +++ b/mswindows/osgeo4w/package.sh @@ -17,13 +17,13 @@ fi # package patch number # e.g. 'r65400-1' for daily builds, '-1' for release -if [ -z $PACKAGE_PATCH ]; then +if [ -z "$PACKAGE_PATCH" ]; then PACKAGE_PATCH=1 fi # package name # eg. '-daily' -> 'grass-daily', empty for release -if [ -z $PACKAGE_POSTFIX ]; then +if [ -z "$PACKAGE_POSTFIX" ]; then PACKAGE_POSTFIX="" fi @@ -41,8 +41,8 @@ fetchenv() { args="$@" cmd.exe //c set >$srcenv cmd.exe //c "call `cygpath -sw $batch` $args \>nul 2\>nul \& set" >$dstenv - diff -u $srcenv $dstenv | sed -f mswindows/osgeo4w/envdiff.sed >$diffenv - . $diffenv + diff -u "$srcenv" "$dstenv" | sed -f mswindows/osgeo4w/envdiff.sed >"$diffenv" + . "$diffenv" PATH=$PATH:/usr/bin:/mingw64/bin/:$PWD/mswindows/osgeo4w/lib:$PWD/mswindows/osgeo4w:/c/windows32/system32:/c/windows:/c/windows32/system32:/c/windows rm -f $srcenv $dstenv $diffenv } @@ -149,18 +149,18 @@ if ! [ -f mswindows/osgeo4w/configure-stamp ]; then cp -uv $DLLS dist.x86_64-w64-mingw32/bin mkdir -p mswindows/osgeo4w/lib - cp -uv $OSGEO4W_ROOT_MSYS/lib/libpq.lib mswindows/osgeo4w/lib/pq.lib - cp -uv $OSGEO4W_ROOT_MSYS/lib/sqlite3_i.lib mswindows/osgeo4w/lib/sqlite3.lib + cp -uv ${OSGEO4W_ROOT_MSYS}/lib/libpq.lib mswindows/osgeo4w/lib/pq.lib + cp -uv ${OSGEO4W_ROOT_MSYS}/lib/sqlite3_i.lib mswindows/osgeo4w/lib/sqlite3.lib log configure ./configure \ --host=x86_64-w64-mingw32 \ - --with-libs="$OSGEO4W_ROOT_MSYS/lib" \ - --with-includes=$OSGEO4W_ROOT_MSYS/include \ - --libexecdir=$OSGEO4W_ROOT_MSYS/bin \ - --prefix=$OSGEO4W_ROOT_MSYS/apps/grass \ - --bindir=$OSGEO4W_ROOT_MSYS/bin \ - --includedir=$OSGEO4W_ROOT_MSYS/include \ + --with-libs="${OSGEO4W_ROOT_MSYS}/lib" \ + --with-includes="${OSGEO4W_ROOT_MSYS}/include" \ + --libexecdir="${OSGEO4W_ROOT_MSYS}/bin" \ + --prefix="${OSGEO4W_ROOT_MSYS}/apps/grass" \ + --bindir="${OSGEO4W_ROOT_MSYS}/bin" \ + --includedir="${OSGEO4W_ROOT_MSYS}/include" \ --with-opengl=windows \ --without-x \ --with-cxx \ @@ -168,29 +168,29 @@ if ! [ -f mswindows/osgeo4w/configure-stamp ]; then --enable-largefile \ --with-fftw \ --with-freetype \ - --with-freetype-includes=/mingw64/include/freetype2 \ - --with-proj-share=$OSGEO4W_ROOT_MSYS/share/proj \ - --with-proj-includes=$OSGEO4W_ROOT_MSYS/include \ - --with-proj-libs=$OSGEO4W_ROOT_MSYS/lib \ + --with-freetype-includes="/mingw64/include/freetype2" \ + --with-proj-share="${OSGEO4W_ROOT_MSYS}/share/proj" \ + --with-proj-includes="${OSGEO4W_ROOT_MSYS}/include" \ + --with-proj-libs="${OSGEO4W_ROOT_MSYS}/lib" \ --with-postgres \ - --with-postgres-includes=$OSGEO4W_ROOT_MSYS/include \ + --with-postgres-includes="${OSGEO4W_ROOT_MSYS}/include" \ --with-postgres-libs=$PWD/mswindows/osgeo4w/lib \ --with-gdal=$PWD/mswindows/osgeo4w/gdal-config \ --with-geos=$PWD/mswindows/osgeo4w/geos-config \ --with-sqlite \ - --with-sqlite-includes=$OSGEO4W_ROOT_MSYS/include \ - --with-sqlite-libs=$PWD/mswindows/osgeo4w/lib \ + --with-sqlite-includes="${OSGEO4W_ROOT_MSYS}/include" \ + --with-sqlite-libs="${OSGEO4W_ROOT_MSYS}/mswindows/osgeo4w/lib" \ --with-regex \ --with-nls \ --with-zstd \ --with-odbc \ - --with-netcdf=${OSGEO4W_ROOT_MSYS}/bin/nc-config \ + --with-netcdf="${OSGEO4W_ROOT_MSYS}/bin/nc-config" \ --with-blas \ --with-lapack \ - --with-lapack-includes=/mingw64/include \ + --with-lapack-includes="/mingw64/include" \ --with-openmp \ --with-cairo \ - --with-cairo-includes=$OSGEO4W_ROOT_MSYS/include \ + --with-cairo-includes="${OSGEO4W_ROOT_MSYS}/include" \ --with-cairo-ldflags="-L$PWD/mswindows/osgeo4w/lib -lcairo -lfontconfig" \ --with-bzlib \ --with-liblas=$PWD/mswindows/osgeo4w/liblas-config \ diff --git a/renovate.json b/renovate.json index fb46027c808..5db72dd6a94 100644 --- a/renovate.json +++ b/renovate.json @@ -1,7 +1,6 @@ { - "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "extends": [ - "config:base", - ":semanticCommitTypeAll(CI)" - ] + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": [ + "config:recommended" + ] } diff --git a/scripts/v.report/testsuite/data/test_1_report.ref b/scripts/v.report/testsuite/data/test_1_report.ref new file mode 100644 index 00000000000..cef50be84c7 --- /dev/null +++ b/scripts/v.report/testsuite/data/test_1_report.ref @@ -0,0 +1,45 @@ +cat|OBJECTID|WAKE_ZIPCO|PERIMETER|ZIPCODE_|ZIPCODE_ID|ZIPNAME|ZIPNUM|ZIPCODE|NAME|SHAPE_Leng|SHAPE_Area|area +1|1|262493461.286|80746.40038|2|27|CREEDMOOR|27522|CREEDMOOR 27522|CREEDMOOR|80777.650719|262372872.587|2437.53231278035 +2|2|31634621.1616|31064.35816|7|25|YOUNGSVILLE|27596|YOUNGSVILLE 27596|YOUNGSVILLE|31064.35845|31634622.1247|293.896432048061 +3|3|543964359.138|115252.44443|8|20|RALEIGH|27615|RALEIGH 27615|RALEIGH|115252.443861|543964358.996|5053.61542941077 +4|4|58736529.666|36836.75795|10|26|YOUNGSVILLE|27596|YOUNGSVILLE 27596|YOUNGSVILLE|36836.756996|58736530.8791|545.681548844361 +5|7|12788390.3938|32416.21157|15|157|DURHAM|27703|DURHAM 27703|DURHAM|30664.931929|12593277.3902|116.906610607967 +6|8|602469071.217|147112.36983|18|8|RALEIGH|27616|RALEIGH 27616|RALEIGH|147116.461058|602468668.316|5597.16187916719 +7|11|402520600.739|128456.89917|23|35|RALEIGH|27612|RALEIGH 27612|RALEIGH|128260.956758|402143653.823|3735.99083479836 +8|12|1319493933.22|252236.30916|24|9|WENDELL|27591|WENDELL 27591|WENDELL|252265.618847|1319493242|12258.5299612302 +9|13|313832905.094|80405.41507|25|19|RALEIGH|27609|RALEIGH 27609|RALEIGH|80405.413149|313832904.304|2915.61008490605 +10|14|632112227.725|154800.00031|28|15|RALEIGH|27604|RALEIGH 27604|RALEIGH|154801.611532|632113047.308|5872.54890089757 +11|15|873704032.742|198415.75507|29|22|KNIGHTDALE|27545|KNIGHTDALE 27545|KNIGHTDALE|207888.12556|854234759.151|7936.13127502539 +12|17|86718740.3594|47692.08248|34|1|RALEIGH|27608|RALEIGH 27608|RALEIGH|47692.081615|86718740.3587|805.649460196298 +13|19|1174353723.71|250639.52409|36|23|RALEIGH|27610|RALEIGH 27610|RALEIGH|260100.365867|1193825267.82|11091.0429399 +14|21|25495827.4688|25606.12087|38|2|RALEIGH|27605|RALEIGH 27605|RALEIGH|25606.118579|25495829.7998|236.864957031583 +15|23|48955772.0156|33100.96362|41|21|RALEIGH|27601|RALEIGH 27601|RALEIGH|33100.961138|48955771.7285|454.815936979609 +16|24|672983954.444|137789.66922|42|18|APEX|27502|APEX 27502|APEX|138402.016283|671745658.098|6240.75717514489 +17|25|1096882081.34|195776.53228|43|24|GARNER|27529|GARNER 27529|GARNER|195766.214382|1096940045.19|10190.9096697667 +18|26|785094011.315|125961.78982|45|4|NEW HILL|27562|NEW HILL 27562|NEW HILL|125964.20281|785117168.913|7293.96582281196 +19|27|74573603.2444|53026.74139|46|76|CLAYTON|27520|CLAYTON 27520|CLAYTON|53026.741222|74573603.668|692.840075781924 +20|29|14013604.9607|20227.39179|50|146|FUQUAY VARINA|27526|FUQUAY VARINA 27526|FUQUAY VARINA|20236.211152|14013892.9812|130.183906990786 +21|30|10825001.4179|18741.09609|51|5|WILLOW SPRING|27592|WILLOW SPRING 27592|WILLOW SPRING|18774.411343|10826786.022|100.594093362751 +22|32|595065.85534|3225.47552|53|147|ANGIER|27501|ANGIER 27501|ANGIER|3221.281589|594306.673565|5.52131175184301 +23|33|880659423.548|230219.75758|44|11|APEX|27539|APEX 27539|APEX|10758.608766|3709374.42305|34.4611971887922 +24|36|607850854.951|135414.36225|6|149|RALEIGH|27613|RALEIGH 27613|RALEIGH|135135.145707|610078059.502|5667.91258118316 +25|39|118820937.008|55979.83097|9|3|ROLESVILLE|27571|ROLESVILLE 27571|ROLESVILLE|60467.130446|128973370.856|1198.19931636245 +26|40|821009204.045|192414.44366|5|12|RALEIGH|27614|RALEIGH 27614|RALEIGH|193326.052701|821170463.631|7628.95617037341 +27|45|246107221.69|98230.55446|14|28|RALEIGH|27617|RALEIGH 27617|RALEIGH|96973.596277|242589284.931|2253.81817443235 +28|54|1380544316.71|223529.01406|13|14|ZEBULON|27597|ZEBULON 27597|ZEBULON|229111.795818|1389077516.66|12905.0077061186 +29|114|595719341.254|135382.61154|40|10|CARY|27518|CARY 27518|CARY|118402.346061|275997437.908|2564.07806207665 +30|212|352353219.773|137980.26455|35|18|APEX|27523|APEX 27523|APEX|126164.348014|325402958.569|3023.13341303491 +31|219|13347044.5484|17858.88115|52|147|ANGIER|27501|ANGIER 27501|ANGIER|20517.250079|16785459.3838|155.938983598546 +32|222|670507534.879|180573.69876|49|5|WILLOW SPRING|27592|WILLOW SPRING 27592|WILLOW SPRING|183229.723255|667072962.625|6197.33763122943 +33|231|897980333.539|201783.43174|47|6|HOLLY SPRINGS|27540|HOLLY SPRINGS 27540|HOLLY SPRINGS|232065.063395|914275342.706|8493.88834301634 +34|236|880659423.548|230219.75758|44|11|APEX|27539|APEX 27539|APEX|251643.611051|892646046.022|8292.96937628262 +35|244|595719341.254|135382.61154|40|10|CARY|27511|CARY 27511|CARY|88289.696983|325536306.021|3024.34350839371 +36|260|490635823.637|134946.66576|27|18|CARY|27519|CARY 27519|CARY|129180.587307|564062896.506|5240.38535324116 +37|275|2825789004.85|465259.10126|3|13|WAKE FOREST|27587|WAKE FOREST 27587|WAKE FOREST|477264.995577|2806740621.72|26075.6049760801 +38|276|504275401.693|157917.82636|30|18|CARY|27513|CARY 27513|CARY|164487.956602|509387886.317|4732.35211121798 +39|282|679964927.93|203429.0581|22|34|RALEIGH|27607|RALEIGH 27607|RALEIGH|182366.287225|552333204.751|5131.37138909183 +40|286|1285870010.66|282815.79339|37|66|RALEIGH|27603|RALEIGH 27603|RALEIGH|285693.495599|1408742751.36|13087.5884223387 +41|288|526570086.386|173734.20912|19|33|MORRISVILLE|27560|MORRISVILLE 27560|MORRISVILLE|169015.912917|643660203.58|5979.8016861835 +42|298|829874917.625|230773.26059|39|2|RALEIGH|27606|RALEIGH 27606|RALEIGH|212707.32257|679989401.948|6316.93565274211 +43|301|1073274000.75|252721.8937|48|7|FUQUAY VARINA|27526|FUQUAY VARINA 27526|FUQUAY VARINA|270514.968365|1061355345.52|9860.60875818323 +44|196|44695436.7135|43678.90844|26|150|DURHAM|27713|DURHAM 27713|DURHAM|19049.668725|7833481.75676|72.7592902311112 diff --git a/scripts/v.report/testsuite/test_v_report.sh b/scripts/v.report/testsuite/test_v_report.sh new file mode 100644 index 00000000000..1624cec88bf --- /dev/null +++ b/scripts/v.report/testsuite/test_v_report.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +set -e +set -x + +v.report zipcodes_wake option=area units=hectares > data/test_1_report.txt + +cd data + +for i in `ls *.txt` ; do + diff $i "`basename $i .txt`.ref" >> out.diff +done + +CHAR_NUM=`cat out.diff | wc -c` + +# Return as exit status 0 in case no diffs are found +exit $CHAR_NUM