diff --git a/.github/workflows/osgeo4w.yml b/.github/workflows/osgeo4w.yml index 96b5a6bb9aa..44fcd4f5803 100644 --- a/.github/workflows/osgeo4w.yml +++ b/.github/workflows/osgeo4w.yml @@ -129,6 +129,7 @@ jobs: python -m pip install ^ pytest ^ pytest-timeout ^ + pytest-cov ^ pytest-xdist ^ pytest-randomly # Obfuscated usage of GitHub Actions features, Windows CMD shell limits analysis @@ -138,8 +139,11 @@ jobs: call %OSGEO4W_ROOT%\opt\grass\etc\env.bat set PYTHONPATH=%GISBASE%\etc\python;%PYTHONPATH% path %GISBASE%\lib;%GISBASE%\bin;%PATH% + set INITIAL_GISBASE=%GISBASE% + set INITIAL_PWD=%CD% pytest ^ @.github/workflows/pytest_args_ci.txt ^ + @.github/workflows/pytest_args_cov.txt ^ @.github/workflows/pytest_args_parallel.txt ^ --junitxml=pytest.xdist.junit.xml ^ -k "not testsuite" @@ -152,8 +156,11 @@ jobs: call %OSGEO4W_ROOT%\opt\grass\etc\env.bat set PYTHONPATH=%GISBASE%\etc\python;%PYTHONPATH% path %GISBASE%\lib;%GISBASE%\bin;%PATH% + set INITIAL_GISBASE=%GISBASE% + set INITIAL_PWD=%CD% pytest ^ @.github/workflows/pytest_args_ci.txt ^ + @.github/workflows/pytest_args_cov.txt ^ @.github/workflows/pytest_args_not_parallel.txt ^ --junitxml=pytest.needs_solo_run.junit.xml ^ -k "not testsuite" @@ -164,13 +171,30 @@ jobs: call %OSGEO4W_ROOT%\opt\grass\etc\env.bat set PYTHONPATH=%GISBASE%\etc\python;%PYTHONPATH% path %GISBASE%\lib;%GISBASE%\bin;%PATH%;%OSGEO4W_ROOT%\opt\grass + set INITIAL_GISBASE=%GISBASE% + set INITIAL_PWD=%CD% pytest ^ @.github/workflows/pytest_args_ci.txt ^ + @.github/workflows/pytest_args_cov.txt ^ @.github/workflows/pytest_args_deselect.txt ^ @.github/workflows/pytest_args_gunittest.txt ^ --junitxml=pytest.gunittest.junit.xml # Obfuscated usage of GitHub Actions features, Windows CMD shell limits analysis shell: cmd /D /E:ON /V:OFF /S /C "CALL C:/OSGeo4W/OSGeo4W.bat "{0}"" # zizmor: ignore[misfeature] + - name: Fix non-standard installed script paths in coverage data + run: | + call %OSGEO4W_ROOT%\opt\grass\etc\env.bat + set PYTHONPATH=%GISBASE%\etc\python;%PYTHONPATH% + path %GISBASE%\lib;%GISBASE%\bin;%PATH% + set INITIAL_GISBASE=%GISBASE% + set INITIAL_PWD=%CD% + python utils/coverage_mapper.py + coverage combine + coverage html + coverage report + coverage json + # Obfuscated usage of GitHub Actions features, Windows CMD shell limits analysis + shell: cmd /D /E:ON /V:OFF /S /C "CALL C:/OSGeo4W/OSGeo4W.bat "{0}"" # zizmor: ignore[misfeature] - name: Upload test results to Codecov if: ${{ !cancelled() }} @@ -180,6 +204,20 @@ jobs: flags: ${{ matrix.os }}-pytest-python token: ${{ secrets.CODECOV_TOKEN }} report_type: test_results + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0 + with: + verbose: true + flags: pytest-osgeo4w + name: pytest-osgeo4w + token: ${{ secrets.CODECOV_TOKEN }} + - name: Make python-only code coverage test report available + if: ${{ !cancelled() }} + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: python-codecoverage-report-${{ matrix.os }} + path: coverage_html_report + retention-days: 1 - name: Run tests run: .github/workflows/test_thorough.bat '%O4WROOT%\opt\grass\grass86.bat' '%O4WROOT%\bin\python3' diff --git a/general/g.version/tests/conftest.py b/general/g.version/tests/conftest.py index e4357b2f672..9ed72d55038 100644 --- a/general/g.version/tests/conftest.py +++ b/general/g.version/tests/conftest.py @@ -3,11 +3,12 @@ import grass.script as gs -@pytest.fixture(scope="module") -def session(tmp_path_factory): +@pytest.fixture +def session(tmp_path_factory, monkeypatch): """Set up a GRASS session for the tests.""" tmp_path = tmp_path_factory.mktemp("grass_session") project = "test_project" + monkeypatch.delenv("GISBASE", raising=False) # Create a test location gs.create_project(tmp_path, project)