Skip to content

Commit

Permalink
ci: Add UI tests (#760)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro authored Oct 28, 2024
1 parent 5f02c71 commit 1a3b1b3
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 5 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
36 changes: 36 additions & 0 deletions geoviews/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
7 changes: 7 additions & 0 deletions geoviews/tests/ui/test_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import pytest

pytestmark = pytest.mark.ui


def test_ui_example(page):
assert True
26 changes: 21 additions & 5 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -82,14 +83,15 @@ 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]
cftime = "*"
datashader = "*"
filelock = "*"
fiona = "*"
gdal = "!=3.9.3" # Crashes CI
geopandas-base = "*"
iris = ">=3.5"
matplotlib-base = ">2.2"
Expand All @@ -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 ====================
# =============================================
Expand Down

0 comments on commit 1a3b1b3

Please sign in to comment.