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
3 changes: 2 additions & 1 deletion .github/renovate.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"github>cucumber/renovate-config"
"github>cucumber/renovate-config",
":enablePreCommit"
]
}
30 changes: 12 additions & 18 deletions .github/workflows/release-pypi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ name: Release Python

on:
push:
branches: [ release/* ]
branches: [release/*]

jobs:
release:
name: Release
publish-pypi:
name: Publish PyPI Package
runs-on: ubuntu-latest
environment: Release
permissions:
Expand All @@ -15,23 +15,17 @@ jobs:
run:
working-directory: python
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Set up Python 3.10
uses: actions/setup-python@v6
- uses: actions/checkout@v5

- name: Install uv and set the python version
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
python-version: "3.14"

- name: Show Python version
run: python --version
version: "0.9.1"

- name: Build package
run: |
python -m pip install build twine
python -m build
twine check --strict dist/*
run: uv build

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: python/dist
- name: Publish package
run: uv publish
72 changes: 23 additions & 49 deletions .github/workflows/test-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,76 +11,50 @@ on:

jobs:
test-python-linting:
runs-on: "ubuntu-latest"
strategy:
fail-fast: false
defaults:
run:
working-directory: python
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
python-version: ["3.10"]
steps:
- uses: actions/checkout@v5
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6

- name: Install uv and set the python version
uses: astral-sh/setup-uv@v6
with:
python-version: ${{ matrix.python-version }}
enable-cache: true
python-version: "3.14"
version: "0.9.1"

- name: Linting
run: |
python -m pip install pre-commit
pre-commit run --all-files

run: uvx pre-commit run --all-files

test-python:
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: python
shell: bash
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
include:
- os: windows-latest
python-version: "3.10"
- os : macos-latest
python-version: "3.10"
defaults:
run:
working-directory: python
steps:
- uses: actions/checkout@v5
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6

- name: Install uv and set the python version
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
python-version: ${{ matrix.python-version }}
- name: Get full Python version
id: full-python-version
run: echo "version=$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")" >> $GITHUB_OUTPUT
- name: Bootstrap poetry
run: |
curl -sL https://install.python-poetry.org | python - -y ${{ matrix.bootstrap-args }}
- name: Update PATH
if: ${{ matrix.os != 'windows-latest' }}
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Update Path for Windows
if: ${{ matrix.os == 'windows-latest' }}
run: echo "$APPDATA\Python\Scripts" >> $GITHUB_PATH
- name: Configure poetry
run: poetry config virtualenvs.in-project true
- name: Set up cache
uses: actions/cache@v4
id: cache
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
- name: Ensure cache is healthy
if: steps.cache.outputs.cache-hit == 'true'
run: timeout 10s poetry rupoen pip --version || rm -rf .venv
- name: Install dependencies
run: poetry install
- name: Install pytest plugin
run: poetry run pip install pytest-github-actions-annotate-failures
version: "0.9.1"

- name: Run pytest
run: poetry run python -m pytest -p no:sugar -q tests/
run: uv run --with pytest-github-actions-annotate-failures pytest -p no:sugar --quiet tests/
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- [Ruby] Minor cosmetic / CI changes for development (Nothing front-facing)
- [Python] PEP 639 licence metadata specification ([#361](https://github.com/cucumber/cucumber-expressions/pull/361))

### Removed
- [Python] Remove support for end-of-life Python 3.8 and 3.9 ([#359](https://github.com/cucumber/cucumber-expressions/pull/359))

## [18.0.1] - 2024-10-28
### Fixed
- [Python] Release process didn't release to pypi correctly
Expand Down
18 changes: 11 additions & 7 deletions python/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
repos:
- repo: https://github.com/psf/black
rev: 22.3.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.0
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
- id: ruff-check
args: [--fix]
- id: ruff-format
- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.9.1
hooks:
- id: flake8
args: ['--max-line-length=130','--ignore=E203,W503']
# Ensure the uv lock file is up to date
- id: uv-lock
files: pyproject.toml
args: [--project, python]
27 changes: 27 additions & 0 deletions python/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Contributing

Thank you for your interest in contributing to `cucumber-expressions`, a simpler alternative to regular expressions! This guide will help you get set up and understand our development workflow.

## 🚀 Quick Start

Using [`uv`](https://docs.astral.sh/uv/) is recommended for contributing with this project, though you can also install dependencies via `pip` (use `pip install . --group dev` with v25.1+) or your preferred tool.

First change to the directory containing the Python implementation and install development dependencies.

```console
cd python
uv sync
```

At the root of the repository, install pre-commit hooks to automatically validate linting and formatting of your Python code with every commit.

```console
cd ..
uv run pre-commit install
```

Unit tests can run via `pytest`.

```console
uv run pytest
```
35 changes: 0 additions & 35 deletions python/README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,3 @@
# Cucumber Expressions for Python

[The main docs are here](https://github.com/cucumber/cucumber-expressions#readme).

## Build system

This project uses [Poetry](https://python-poetry.org/) as its build system.
In order to develop on this project, please install Poetry as per your system's instructions on the link above.

## Tests

The test suite uses `pytest` as its testing Framework.


### Preparing to run the tests

In order to set up your dev environment, run the following command from this project's directory:

``` python
poetry install
```
It will install all package and development requirements, and once that is done it will do a dev-install of the source code.

You only need to run it once, code changes will propagate directly and do not require running the install again.


### Running the tests

`pytest` automatically picks up files in the current directory or any subdirectories that have the prefix or suffix of `test_*.py`.
Test function names must start with `test*`.
Test class names must start with `Test*`.

To run all tests:

``` python
poetry run pytest
```

Loading