Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 14 additions & 17 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,22 @@ on:

jobs:
deploy:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
environment:
name: pypi
url: https://pypi.org/p/widgetastic.patternfly4
permissions:
id-token: write # For trusted publishing
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Install dependencies
run: pip install twine
run: pip install pip twine -U
- name: Build a wheel
run: pip wheel --no-deps -w dist .
- name: Test package
run: twine check dist/*
Comment thread
mshriver marked this conversation as resolved.
- name: Deploy to PyPI
uses: pypa/gh-action-pypi-publish@v1.4.1
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
- name: Create a release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
uses: pypa/gh-action-pypi-publish@release/v1
43 changes: 19 additions & 24 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,55 +10,50 @@ on:

jobs:
test:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
browser: [chrome, firefox]
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install -U pip wheel
pip install .[dev]
- name: Install Hatch
run: pip install -U pip hatch
- name: Fetch selenium image
run: podman pull selenium/standalone-${{ matrix.browser }}:4.9.0-20230421
- name: Test with pytest
env:
BROWSER: ${{ matrix.browser }}
run: |
pytest -v -n 5 --no-cov-on-fail \
--cov=widgetastic_patternfly4 \
--cov-append
hatch run test.py${{ matrix.python-version }}-${{ matrix.browser }}:test-cov -v -n 5
mv .coverage ${{ strategy.job-index }}_coverage
- name: Upload coverage artifact
uses: "actions/upload-artifact@v3"
uses: "actions/upload-artifact@v4"
with:
name: ${{ strategy.job-index }}_coverage
path: ${{ strategy.job-index }}_coverage

submit_coverage:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
needs: test
steps:
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: "3.8"
- uses: actions/checkout@v3
- name: Install coverage
run: pip install coverage
python-version: "3.10"
- uses: actions/checkout@v4
- name: Install Hatch
run: pip install -U pip hatch
- name: Download coverage artifacts
uses: actions/download-artifact@v4.1.7
uses: actions/download-artifact@v4
with:
path: /tmp/coverage
- name: Combine coverage data files
run: |
coverage combine -a $(find /tmp/coverage -type f)
coverage xml -o /tmp/coverage.xml
hatch run coverage:combine -a $(find /tmp/coverage -type f)
hatch run coverage:xml -o /tmp/coverage.xml
- name: Publish coverage
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v5
with:
files: /tmp/coverage.xml
35 changes: 6 additions & 29 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,37 +1,14 @@
repos:
- repo: https://github.com/asottile/reorder-python-imports
rev: v3.10.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.16.0
hooks:
- id: reorder-python-imports
language_version: python3
- id: ruff
args:
- --application-directories=.:src
- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
- id: black
args: [--safe, --quiet, --line-length, "100"]
language_version: python3
require_serial: true
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
language_version: python3
args:
- --max-line-length=100
- --ignore=W503,E203
- '--fix'
- id: ruff-format
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v6.0.0
hooks:
- id: trailing-whitespace
language_version: python3
- id: end-of-file-fixer
language_version: python3
- id: debug-statements
language_version: python3
- repo: https://github.com/asottile/pyupgrade
rev: v3.9.0
hooks:
- id: pyupgrade
language_version: python3
51 changes: 51 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,54 @@ of workers:
```bash
BROWSER=firefox pytest -v testing -n 4
```

### Running tests with Hatch

Tests can also be run through [Hatch](https://hatch.pypa.io/) managed environments, which take care of
installing the `dev` extras (`pytest`, `pytest-cov`, `pytest-xdist`) in an isolated virtual environment.

Run the test suite against the default environment (`BROWSER=firefox` by default):

```bash
hatch run test
```

Run tests in parallel:

```bash
hatch run test-parallel
```

Run tests with coverage (extra flags, e.g. `-n 5`, are appended after the `testing` target):

```bash
BROWSER=chrome hatch run test-cov -v -n 5
```

Run a single test file:

```bash
BROWSER=chrome hatch run test testing/test_button.py -v
```

A `test` matrix environment is also defined, covering the same Python (3.10-3.13) and browser
(chrome, firefox) combinations exercised in CI - this is what `.github/workflows/tests.yaml` uses.
Run a single combination:

```bash
hatch run test.py3.10-chrome:test-cov -v -n 5
```

Or run the full matrix:

```bash
hatch run test:test-cov
```

Coverage data from multiple runs can be combined/reported using the detached `coverage` environment
(also used by the `submit_coverage` CI job):

```bash
hatch run coverage:combine
hatch run coverage:xml
```
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import os
import sys

from sphinx.ext.apidoc import main as apidoc_main
Comment thread
mshriver marked this conversation as resolved.

modules_path = os.path.abspath("../src/widgetastic_patternfly4")

sys.path.insert(0, modules_path)
Expand Down Expand Up @@ -53,8 +55,6 @@


def run_apidoc(_):
from sphinx.ext.apidoc import main as apidoc_main

cur_dir = os.path.abspath(".")
output_path = os.path.join(cur_dir, "source")
apidoc_main(["-e", "-f", "-o", output_path, modules_path, "--force"])
Expand Down
57 changes: 53 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Software Development :: Quality Assurance",
"Topic :: Software Development :: Testing",
Expand All @@ -16,13 +17,14 @@ license = {file = "LICENSE"}
maintainers = [
{name = "Nikhil Dhandre", email = "ndhandre@redhat.com"},
{name = "Egor Shamardin", email = "eshamard@redhat.com"},
{name = "Mike Shriver", email = "mshriver@redhat.com"},
]
name = "widgetastic.patternfly4"
readme = "README.md"
requires-python = ">=3.8"
requires-python = ">=3.10"

dependencies = [
"widgetastic.core>=1.0.0",
"widgetastic.core>=1.0.0,<2.0.0",
]

[project.optional-dependencies]
Expand All @@ -32,6 +34,7 @@ dev = [
"pytest-cov",
"pytest-xdist",
"codecov",
"selenium",
]
doc = ["sphinx"]

Expand All @@ -48,3 +51,49 @@ strict-naming = false

[tool.hatch.version]
source = "vcs"

[tool.hatch.envs.default]
features = ["dev"]

[tool.hatch.envs.default.env-vars]
BROWSER = "firefox"

[tool.hatch.envs.default.scripts]
test = "pytest {args:testing}"
test-parallel = "pytest -n auto {args:testing}"
test-cov = "pytest --no-cov-on-fail --cov=widgetastic_patternfly4 --cov-append testing {args}"

[[tool.hatch.envs.test.matrix]]
python = ["3.10", "3.11", "3.12", "3.13"]
browser = ["chrome", "firefox"]

[tool.hatch.envs.test.overrides]
matrix.browser.env-vars = "BROWSER"

[tool.hatch.envs.coverage]
detached = true
dependencies = ["coverage[toml]"]

[tool.hatch.envs.coverage.scripts]
combine = "coverage combine {args}"
report = "coverage report {args}"
xml = "coverage xml {args}"

[tool.hatch.envs.lint]
dependencies = ["pre-commit"]

[tool.hatch.envs.lint.scripts]
check = "pre-commit run --all-files"

[tool.pytest.ini_options]
testpaths = ["testing"]

[tool.ruff]
line-length = 100

[tool.ruff.lint]
select = ["F", "I", "PL", "UP"]
# PLR0913/PLR0917: widgetastic widgets conventionally take several positional
# constructor args (parent, locator, ...); PLW1641: pre-existing __eq__-without-
# __hash__ classes kept as-is to avoid changing equality/hashing semantics.
extend-ignore = ["PLR2004", "PLE0643", "PLR0913", "PLR0917", "PLW1641"]
Loading
Loading