diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 2fe7fa20..f20c8617 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -134,6 +134,40 @@ jobs: with: token: ${{ secrets.CODECOV_TOKEN }} + ui_test_suite: + name: ui:${{ matrix.environment }}:${{ matrix.os }} + needs: [pre_commit, setup, pixi_lock] + runs-on: ${{ matrix.os }} + if: needs.setup.outputs.code_change == 'true' + strategy: + fail-fast: false + matrix: + os: ["ubuntu-latest"] + environment: ["test-ui"] + timeout-minutes: 60 + env: + PANEL_LOG_LEVEL: info + steps: + - uses: holoviz-dev/holoviz_tasks/pixi_install@v0 + with: + environments: ${{ matrix.environment }} + - name: Test UI + run: | + # Create a .uicoveragerc file to set the concurrency library to greenlet + # https://github.com/microsoft/playwright-python/issues/313 + echo "[run]\nconcurrency = greenlet" > .uicoveragerc + FAIL="--screenshot only-on-failure --full-page-screenshot --output ui_screenshots --tracing retain-on-failure" + pixi run -e ${{ matrix.environment }} test-ui $COV --cov-config=.uicoveragerc $FAIL + - uses: actions/upload-artifact@v4 + if: always() + with: + name: ui_screenshots_${{ runner.os }} + path: ./ui_screenshots + if-no-files-found: ignore + - uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} + core_test_suite: name: core:${{ matrix.environment }}:${{ matrix.os }} needs: [pre_commit, setup, pixi_lock] diff --git a/geoviews/tests/conftest.py b/geoviews/tests/conftest.py index 0e0bbaa9..8d29ff23 100644 --- a/geoviews/tests/conftest.py +++ b/geoviews/tests/conftest.py @@ -2,6 +2,42 @@ import geoviews as gv +CUSTOM_MARKS = ("ui",) + + +def pytest_addoption(parser): + for marker in CUSTOM_MARKS: + parser.addoption( + f"--{marker}", + action="store_true", + default=False, + help=f"Run {marker} related tests", + ) + + +def pytest_configure(config): + for marker in CUSTOM_MARKS: + config.addinivalue_line("markers", f"{marker}: {marker} test marker") + + +def pytest_collection_modifyitems(config, items): + skipped, selected = [], [] + markers = [m for m in CUSTOM_MARKS if config.getoption(f"--{m}")] + empty = not markers + for item in items: + if empty and any(m in item.keywords for m in CUSTOM_MARKS): + skipped.append(item) + elif empty: + selected.append(item) + elif not empty and any(m in item.keywords for m in markers): + selected.append(item) + else: + skipped.append(item) + + config.hook.pytest_deselected(items=skipped) + items[:] = selected + + with suppress(Exception): gv.extension("bokeh") diff --git a/geoviews/tests/ui/test_example.py b/geoviews/tests/ui/test_example.py new file mode 100644 index 00000000..e7d4254b --- /dev/null +++ b/geoviews/tests/ui/test_example.py @@ -0,0 +1,7 @@ +import pytest + +pytestmark = pytest.mark.ui + + +def test_ui_example(page): + assert True diff --git a/pixi.toml b/pixi.toml index f0c4e05d..2c75f545 100644 --- a/pixi.toml +++ b/pixi.toml @@ -13,10 +13,11 @@ USE_PYGEOS = "0" DASK_DATAFRAME__QUERY_PLANNING = "False" [environments] -test-310 = ["py310", "test-core", "test", "example", "test-example", "download-data"] -test-311 = ["py311", "test-core", "test", "example", "test-example", "download-data"] -test-312 = ["py312", "test-core", "test", "example", "test-example", "download-data"] -test-core = ["py312", "test-core"] +test-310 = ["py310", "test-core", "test-unit-task", "test", "example", "test-example", "download-data"] +test-311 = ["py311", "test-core", "test-unit-task", "test", "example", "test-example", "download-data"] +test-312 = ["py312", "test-core", "test-unit-task", "test", "example", "test-example", "download-data"] +test-core = ["py312", "test-unit-task", "test-core"] +test-ui = ["py312", "test-core", "test", "test-ui"] docs = ["py311", "example", "doc", "download-data"] build = ["py311", "build"] lint = ["py311", "lint"] @@ -82,7 +83,7 @@ pytest-cov = "*" pytest-github-actions-annotate-failures = "*" pytest-xdist = "*" -[feature.test-core.tasks] +[feature.test-unit-task.tasks] # So it is not showing up in the test-ui environment test-unit = 'pytest geoviews/tests -n logical --dist loadgroup' [feature.test.dependencies] @@ -90,6 +91,7 @@ cftime = "*" datashader = "*" filelock = "*" fiona = "*" +gdal = "!=3.9.3" # Crashes CI geopandas-base = "*" iris = ">=3.5" matplotlib-base = ">2.2" @@ -108,6 +110,20 @@ test-example = 'pytest -n logical --dist loadscope --nbval-lax examples' [feature.test-example.dependencies] nbval = "*" +[feature.test-ui] +channels = ["microsoft"] + +[feature.test-ui.dependencies] +playwright = { version = "*", channel = "microsoft" } +pytest-playwright = { version = "*", channel = "microsoft" } + +[feature.test-ui.tasks] +_install-ui = 'playwright install chromium' + +[feature.test-ui.tasks.test-ui] +cmd = 'pytest geoviews/tests/ui --ui --browser chromium' +depends_on = ["_install-ui"] + # ============================================= # =================== DOCS ==================== # =============================================