-
-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add messages implementation for python #165
base: main
Are you sure you want to change the base?
Changes from all commits
88ec5b6
3389a62
3da9e8f
af36ce3
614d55c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
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 | ||
|
||
- name: Generate code | ||
working-directory: ./python | ||
run: | | ||
make clean-real | ||
make generate-real | ||
|
||
- uses: cucumber/[email protected] | ||
with: | ||
working-directory: "python" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
--- | ||
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" | ||
luke-hill marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- "pypy3.9" | ||
- "pypy3.10" | ||
os: | ||
- ubuntu-latest | ||
- windows-latest | ||
- macos-latest | ||
elchupanebrej marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There has to be a more efficient way to run run all versions on ubuntu and exclude osx and windows. |
||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Generate code | ||
working-directory: ./python | ||
run: | | ||
make clean-real | ||
make generate-real | ||
- 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 |
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 |
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] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
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: ## Stub for the ancestor Makefile | ||
echo "Skipping code generation - code is generated by Python" | ||
|
||
generate-real: require install-deps | ||
datamodel-codegen \ | ||
mpkorstanje marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it be possible to move this into pythons build process? |
||
--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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Python should not be required. This can be a stub too. |
||
|
||
clean: ## Stub for the ancestor Makefile | ||
echo "Skipping code cleanup - code cleanup is done by Python" | ||
|
||
clean-real: ## 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] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Messages | ||
|
||
Cucumber Messages for Python https://github.com/cucumber/messages |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks unnecessary.