diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index e9e693e57c3..786ae453370 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -23,6 +23,7 @@ jobs: runs-on: macos-14 env: PYTHONWARNINGS: always + # LLVM_PROFILE_FILE: "grass-prof-%9m.profraw" steps: - name: Info run: | @@ -55,8 +56,17 @@ jobs: - name: Prepare Conda environment file env: test_dependencies: | + compiler-rt + coverage ipython + libllvm20 + lit + llvm + llvm-tools + llvm-tools-20 + llvmdev pytest + pytest-cov pytest-github-actions-annotate-failures pytest-timeout pytest-xdist @@ -72,7 +82,8 @@ jobs: environment-name: grass-env # Persist on the same period (date). cache-environment-key: environment-${{ steps.date.outputs.date }} - + - name: Set profile file name env var + run: echo "LLVM_PROFILE_FILE=${{ github.workspace }}/grass-prof-%9m.profraw" >> $GITHUB_ENV - name: Environment info shell: bash -el {0} run: | @@ -89,7 +100,10 @@ jobs: if: ${{ !cancelled() }} shell: micromamba-shell {0} run: source ./.github/workflows/print_versions.sh - + - run: ls -la bin.*-*-* + - run: ls -la dist.*-*-*/bin + - run: ls -la "$HOME/install" + - run: ls -la "$HOME/install/bin" - name: Run pytest with multiple workers in parallel shell: micromamba-shell {0} run: | @@ -104,8 +118,11 @@ jobs: 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}" pytest \ @.github/workflows/pytest_args_ci.txt \ + @.github/workflows/pytest_args_cov.txt \ @.github/workflows/pytest_args_not_parallel.txt \ -k 'not testsuite' - name: Run pytest with a single worker (for gunittest-based tests) @@ -115,6 +132,85 @@ jobs: export LD_LIBRARY_PATH=$(grass --config path)/lib:$LD_LIBRARY_PATH pytest \ @.github/workflows/pytest_args_gunittest.txt + - name: Fix non-standard installed script paths in coverage data + shell: micromamba-shell {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}" + python utils/coverage_mapper.py + coverage combine + coverage html + coverage json + - name: Merge and index profile data + shell: micromamba-shell {0} + run: llvm-profdata merge -sparse *.profraw -o merged.profdata + - name: Show merged profile data + shell: micromamba-shell {0} + continue-on-error: true + run: llvm-profdata show merged.profdata + - run: ls -la "$HOME/install" + - run: ls -la "$HOME/install/bin" + - name: Create a line-oriented coverage report + shell: micromamba-shell {0} + continue-on-error: true + run: | + llvm-cov show -use-color -instr-profile=merged.profdata \ + /Users/runner/install/grass85/lib/libgrass_gis.8.5.dylib + - name: Create a line-oriented coverage report + shell: micromamba-shell {0} + continue-on-error: true + run: | + llvm-cov show -use-color -instr-profile=merged.profdata \ + /Users/runner/install/grass85/lib/*.dylib + - name: Export coverage report with llvm-cov export + if: false + shell: micromamba-shell {0} + continue-on-error: true + run: llvm-cov export -format=text -instr-profile=merged.profdata /Users/runner/install/grass85/lib/libgrass_gis.8.5.dylib | tee coverage.libgrass_gis.json + - name: Export coverage report with llvm-cov export + if: false + shell: micromamba-shell {0} + continue-on-error: true + run: llvm-cov export -format=text -instr-profile=merged.profdata /Users/runner/install/grass85/lib/*.dylib | tee coverage.libs.json + - name: Export coverage report with llvm-cov export + shell: micromamba-shell {0} + continue-on-error: true + run: llvm-cov export -format=lcov -instr-profile=merged.profdata /Users/runner/install/grass85/lib/*.dylib | tee coverage.libs.lcov + - name: Make profile data available + if: ${{ !cancelled() }} + uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4 + with: + name: >- + profile-data-${{ 'macos-14' }} + path: | + *.prof* + *coverage* + retention-days: 1 + - run: /usr/bin/find . -type f \( -name "*.o" -or -name "*.prof*" \) + - run: /usr/bin/find . -type f \( -name "*.profraw" -or -name "*.profdata" \) + - run: /usr/bin/find $HOME/install -type f \( -name "*.o" -or -name "*.prof*" \) + - run: ls -la + - run: ls -la "$HOME/install" + - run: ls -la "$HOME/install/bin" + - run: ls -la -R "$HOME/install" + - run: ls -la -R . + - name: Make python-only code coverage test report available + if: ${{ !cancelled() }} + uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4 + with: + name: >- + python-codecoverage-report-${{ 'macos-14' }} + path: coverage_html_report + retention-days: 1 + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@ad3126e916f78f00edff4ed0317cf185271ccc2d # v5.4.2 + with: + verbose: true + flags: pytest-macos-14 + name: pytest-macos-14 + token: ${{ secrets.CODECOV_TOKEN }} - name: Cache GRASS Sample Dataset id: cached-data diff --git a/.github/workflows/macos_install.sh b/.github/workflows/macos_install.sh index 4f340c73f9e..bcc95072368 100755 --- a/.github/workflows/macos_install.sh +++ b/.github/workflows/macos_install.sh @@ -59,11 +59,17 @@ CONFIGURE_FLAGS="\ --without-x \ " +# export EXTRA_COV_FLAGS="-fprofile-instr-generate -fcoverage-mapping -mllvm -runtime-counter-relocation" +export EXTRA_COV_FLAGS="-fprofile-instr-generate -fcoverage-mapping" export CFLAGS="-O2 -pipe -ffp-contract=off -arch ${CONDA_ARCH} -DGL_SILENCE_DEPRECATION -Wall -Wextra -Wpedantic -Wvla" export CXXFLAGS="-O2 -pipe -ffp-contract=off -stdlib=libc++ -arch ${CONDA_ARCH} -Wall -Wextra -Wpedantic" export CPPFLAGS="-isystem${CONDA_PREFIX}/include" -./configure $CONFIGURE_FLAGS +# export LDFLAGS="-v -fprofile-instr-generate -fcoverage-mapping" +export CFLAGS="$EXTRA_COV_FLAGS $CFLAGS" +export CXXFLAGS="$EXTRA_COV_FLAGS $CXXFLAGS" + +LDFLAGS="-v -fprofile-instr-generate -fcoverage-mapping $LDFLAGS" ./configure $CONFIGURE_FLAGS EXEMPT="" make -j$(sysctl -n hw.ncpu) CFLAGS="$CFLAGS -Werror $EXEMPT" \ diff --git a/.github/workflows/print_versions.sh b/.github/workflows/print_versions.sh index 68b359c1b96..28cbd7d98ef 100755 --- a/.github/workflows/print_versions.sh +++ b/.github/workflows/print_versions.sh @@ -13,3 +13,5 @@ grass --version grass --tmp-project XY --exec g.version -ergb # Detailed Python version info (in one line thanks to echo) grass --tmp-project XY --exec bash -c "echo Python: \$(\$GRASS_PYTHON -c 'import sys; print(sys.version)')" + +grass --config \ No newline at end of file