Skip to content

Commit

Permalink
Add messages implementation for python
Browse files Browse the repository at this point in the history
� Conflicts:
�	CHANGELOG.md
  • Loading branch information
elchupanebrej committed Dec 8, 2024
1 parent 2e33e68 commit 3d5ec13
Show file tree
Hide file tree
Showing 67 changed files with 2,309 additions and 1 deletion.
31 changes: 31 additions & 0 deletions .github/workflows/release-pypi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Release Python

on:
push:
branches: [release/*]

jobs:
release:
name: Release
runs-on: ubuntu-latest
environment: Release
permissions:
id-token: write
defaults:
run:
working-directory: python
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"

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

- uses: cucumber/[email protected]
with:
working-directory: "python"
5 changes: 5 additions & 0 deletions .github/workflows/test-codegen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ jobs:
with:
ruby-version: '3.1'

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: generate code for all languages
run: |
make clean-all
Expand Down
82 changes: 82 additions & 0 deletions .github/workflows/test-python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
name: test-python

on: # yamllint disable-line rule:truthy
push:
branches:
- main
- renovate/**
pull_request:
branches:
- main
workflow_dispatch:

jobs:
build:

runs-on: ${{ matrix.os }}
timeout-minutes: 20
strategy:
matrix:
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "pypy3.8"
- "pypy3.9"
- "pypy3.10"
os:
- ubuntu-latest
- windows-latest
- macos-latest
exclude:
- python-version: "pypy3.8"
os: macos-latest
- python-version: "pypy3.9"
os: macos-latest
- python-version: "pypy3.10"
os: macos-latest
- python-version: "3.8"
os: macos-latest
- python-version: "3.9"
os: macos-latest
- python-version: "3.10"
os: macos-latest
- python-version: "3.11"
os: macos-latest
- python-version: "pypy3.8"
os: windows-latest
- python-version: "pypy3.9"
os: windows-latest
- python-version: "pypy3.10"
os: windows-latest
- python-version: "3.8"
os: windows-latest
- python-version: "3.9"
os: windows-latest
- python-version: "3.10"
os: windows-latest
- python-version: "3.11"
os: windows-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -U setuptools
pip install tox tox-gh-actions codecov
- name: Test with tox
working-directory: ./python
run: |
tox
- name: Gather codecov report
working-directory: ./python
run: |
codecov
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Added
- [cpp] use VERSION file to version ABI and shared libraries (#268](https://github.com/cucumber/messages/pull/268)

### Added
- [Python] Added Python implementation ([#165](https://github.com/cucumber/messages/pull/165))

## [27.0.2] - 2024-11-15
### Fixed
- [Elixir] Fix release process
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ schemas = \
./jsonschema/UndefinedParameterType.json \
./jsonschema/Envelope.json

languages = cpp go java javascript perl php ruby dotnet
languages = cpp dotnet go java javascript perl php python ruby

.DEFAULT_GOAL = help

Expand Down
Empty file modified cpp/cmake/cmate
100755 → 100644
Empty file.
55 changes: 55 additions & 0 deletions python/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
*.rej
*.py[cod]
/.env
*.orig
**/__pycache__

# C extensions
*.so

# Packages
*.egg
*.egg-info
dist
build
_build
eggs
parts
bin
var
sdist
develop-eggs
.installed.cfg
lib
lib64

# Installer logs
pip-log.txt

# Unit test / coverage reports
.coverage
.tox
nosetests.xml

# Translations
*.mo

# Mr Developer
.mr.developer.cfg
.project
.pydevproject
.pytest_cache
.ropeproject

# Sublime
/*.sublime-*

#PyCharm
/.idea

# virtualenv
/.Python
/lib
/include
/share
/local
48 changes: 48 additions & 0 deletions python/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
---
repos:
- repo: https://github.com/psf/black
rev: 24.8.0
hooks:
- id: black
args:
- "python/src"
- "python/tests"
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
name: isort (python)
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- id: check-toml
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.14.0
hooks:
- id: pretty-format-toml
args: [--autofix]
- repo: https://github.com/asottile/pyupgrade
rev: v3.17.0
hooks:
- id: pyupgrade
args: ["--py38-plus"]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.11.2
hooks:
- id: mypy
additional_dependencies: [types-setuptools, types-certifi]
- repo: https://github.com/tox-dev/tox-ini-fmt
rev: "1.3.2"
hooks:
- id: tox-ini-fmt
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.35.1
hooks:
- id: yamllint
args: [--format, parsable, --strict]
35 changes: 35 additions & 0 deletions python/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
schemas = $(shell find ../jsonschema -name "*.json")

.DEFAULT_GOAL = help

MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
HERE := $(dir $(MKFILE_PATH))

help: ## Show this help
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make <target>\n\nWhere <target> is one of:\n"} /^[$$()% a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

generate: require install-deps
datamodel-codegen \
--output-model-type "pydantic_v2.BaseModel" \
--input $(HERE)../jsonschema/Envelope.json \
--output $(HERE)src/cucumber_messages/messages.py \
--use-generic-container-types \
--allow-extra-fields \
--allow-population-by-field-name \
--snake-case-field \
--input-file-type=jsonschema \
--class-name Envelope \
--use-double-quotes \
--use-union-operator \
--disable-timestamp \
--target-python-version=3.8

require: ## Check requirements for the code generation (python is required)
@python --version >/dev/null 2>&1 || (echo "ERROR: python is required."; exit 1)

clean: ## Remove automatically generated files and related artifacts
rm -rf $(HERE)src/_messages.py

install-deps: ## Install generation dependencies
python -m ensurepip --upgrade
pip install $(HERE)[generation]
3 changes: 3 additions & 0 deletions python/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Messages

Cucumber Messages for Python https://github.com/cucumber/messages
Loading

0 comments on commit 3d5ec13

Please sign in to comment.