From 1b504d95eb4260f70a594476eca6facc35c0deb5 Mon Sep 17 00:00:00 2001 From: Stefan VanBuren Date: Mon, 15 Sep 2025 08:40:48 -0400 Subject: [PATCH 1/4] Cleanup repository * Remove CEL_SPEC_VERSION from testdata file (we should only ever need one version of this) * Use direct `uv run ` instead of `uv -- run python -m ` * Consolidate workflows * Move conformance tests to CI workflow * Use shared buf PR Title workflow * Remove excess from .gitignore --- .github/workflows/ci.yaml | 6 +- .github/workflows/conformance.yaml | 36 ---- .github/workflows/pr-hygiene.yaml | 32 ---- .github/workflows/pr-title.yaml | 18 ++ .gitignore | 166 +----------------- Makefile | 10 +- test/test_format.py | 6 +- ...v0.24.0.textproto => string_ext.textproto} | 0 8 files changed, 32 insertions(+), 242 deletions(-) delete mode 100644 .github/workflows/conformance.yaml delete mode 100644 .github/workflows/pr-hygiene.yaml create mode 100644 .github/workflows/pr-title.yaml rename test/testdata/{string_ext_v0.24.0.textproto => string_ext.textproto} (100%) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 589ba420..884b9f00 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -37,10 +37,12 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies run: make install - - name: Execute tests - run: make test - name: Lint run: make lint + - name: Execute tests + run: make test + - name: Test conformance + run: make conformance - name: Format run: make format # When running with matrix.resolution == highest, we expect uv.lock to change, but we don't want that file checked in. diff --git a/.github/workflows/conformance.yaml b/.github/workflows/conformance.yaml deleted file mode 100644 index 205943cd..00000000 --- a/.github/workflows/conformance.yaml +++ /dev/null @@ -1,36 +0,0 @@ -name: Conformance -on: - pull_request: - push: - tags: - - 'v*.*.*' - branches: - - 'main' - -permissions: - contents: read - -jobs: - conformance: - name: Conformance Testing - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] - resolution: ["highest", "lowest-direct"] - steps: - - name: Checkout code - uses: actions/checkout@v5 - with: - fetch-depth: 1 - - name: Install Go - uses: actions/setup-go@v6 - with: - go-version: stable - cache: false - - uses: astral-sh/setup-uv@v6 - with: - python-version: ${{ matrix.python-version }} - - name: Test conformance - run: UV_RESOLUTION=${{ matrix.resolution }} make conformance diff --git a/.github/workflows/pr-hygiene.yaml b/.github/workflows/pr-hygiene.yaml deleted file mode 100644 index 79e9a19d..00000000 --- a/.github/workflows/pr-hygiene.yaml +++ /dev/null @@ -1,32 +0,0 @@ -name: PR Hygiene -# Prevent writing to the repository using the CI token. -# Ref: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#permissions -permissions: - pull-requests: read -on: - workflow_call: - pull_request: - # By default, a workflow only runs when a pull_request's activity type is opened, - # synchronize, or reopened. We explicity override here so that PR titles are - # re-linted when the PR text content is edited. - types: - - opened - - edited - - reopened - - synchronize -jobs: - lint-title: - name: Lint title - runs-on: ubuntu-latest - steps: - - name: Lint title - uses: morrisoncole/pr-lint-action@v1.7.1 - with: - repo-token: "${{ secrets.GITHUB_TOKEN }}" - # https://regex101.com/r/I6oK5v/1 - title-regex: "^[A-Z].*[^.?!,\\-;:]$" - on-failed-regex-fail-action: true - on-failed-regex-create-review: false - on-failed-regex-request-changes: false - on-failed-regex-comment: "PR titles must start with a capital letter and not end with punctuation." - on-succeeded-regex-dismiss-review-comment: "Thanks for helping keep our PR titles consistent!" diff --git a/.github/workflows/pr-title.yaml b/.github/workflows/pr-title.yaml new file mode 100644 index 00000000..b1146033 --- /dev/null +++ b/.github/workflows/pr-title.yaml @@ -0,0 +1,18 @@ +name: Lint PR Title +# Prevent writing to the repository using the CI token. +# Ref: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#permissions +permissions: + pull-requests: read +on: + pull_request: + # By default, a workflow only runs when a pull_request's activity type is opened, + # synchronize, or reopened. We explicity override here so that PR titles are + # re-linted when the PR text content is edited. + types: + - opened + - edited + - reopened + - synchronize +jobs: + lint: + uses: bufbuild/base-workflows/.github/workflows/pr-title.yaml@main diff --git a/.gitignore b/.gitignore index 845efbd4..e4079c9d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,162 +1,8 @@ -.tmp/ +# tools, see ./Makefile +/.tmp/ -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class +# python writes compiled bytecode to .pyc files in __pycache__ directories +__pycache__ -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ -cover/ - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -.pybuilder/ -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -# For a library or package, you might want to ignore these files since the code is -# intended to run in multiple environments; otherwise, check them in: -# .python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# poetry -# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. -# This is especially recommended for binary packages to ensure reproducibility, and is more -# commonly ignored for libraries. -# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control -#poetry.lock - -# pdm -# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. -#pdm.lock -# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it -# in version control. -# https://pdm.fming.dev/#use-with-ide -.pdm.toml - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# pytype static type analyzer -.pytype/ - -# Cython debug symbols -cython_debug/ - -# PyCharm -# JetBrains specific template is maintained in a separate JetBrains.gitignore that can -# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore -# and can be added to the global gitignore or merged into this file. For a more nuclear -# option (not recommended) you can uncomment the following to ignore the entire idea folder. -#.idea/ -.vscode/ +# VS Code configuration +/.vscode/ diff --git a/Makefile b/Makefile index 93d289e9..3454acbf 100644 --- a/Makefile +++ b/Makefile @@ -18,9 +18,8 @@ ADD_LICENSE_HEADER := $(BIN)/license-header \ # This version should be kept in sync with the version in buf.yaml PROTOVALIDATE_VERSION ?= v1.0.0 # Version of the cel-spec that this implementation is conformant with -# This should be kept in sync with the version in test/test_format.py CEL_SPEC_VERSION ?= v0.24.0 -TESTDATA_FILE := test/testdata/string_ext_$(CEL_SPEC_VERSION).textproto +TESTDATA_FILE := test/testdata/string_ext.textproto .PHONY: help help: ## Describe useful make targets @@ -51,12 +50,12 @@ format: install $(BIN)/buf $(BIN)/license-header ## Format code uv run -- ruff check --fix protovalidate test .PHONY: test -test: generate install gettestdata ## Run unit tests +test: generate install $(TESTDATA_FILE) ## Run unit tests uv run -- pytest .PHONY: conformance conformance: $(BIN)/protovalidate-conformance generate install ## Run conformance tests - protovalidate-conformance $(CONFORMANCE_ARGS) uv -- run python3 -m test.conformance.runner + protovalidate-conformance $(CONFORMANCE_ARGS) uv run test/conformance/runner.py .PHONY: lint lint: install $(BIN)/buf ## Lint code @@ -75,9 +74,6 @@ checkgenerate: generate @# Used in CI to verify that `make generate` doesn't produce a diff. test -z "$$(git status --porcelain | tee /dev/stderr)" -.PHONY: gettestdata -gettestdata: $(TESTDATA_FILE) - $(TESTDATA_FILE): mkdir -p $(dir @) curl -fsSL -o $@ https://raw.githubusercontent.com/google/cel-spec/refs/tags/$(CEL_SPEC_VERSION)/tests/simple/testdata/string_ext.textproto diff --git a/test/test_format.py b/test/test_format.py index 092a698e..8673bbaa 100644 --- a/test/test_format.py +++ b/test/test_format.py @@ -26,10 +26,6 @@ from protovalidate.internal import extra_func from protovalidate.internal.cel_field_presence import InterpretedRunner -# Version of the cel-spec that this implementation is conformant with. -# This should be kept in sync with the version in ../Makefile. -CEL_SPEC_VERSION = "v0.24.0" - skipped_tests = [ # cel-python seems to have a bug with ints and booleans in the same map which evaluate to the same value # which the test data for this test has. For example: {1: 'value1', true: 'value2'}]). @@ -83,7 +79,7 @@ def get_eval_error_message(test: simple_pb2.SimpleTest) -> Optional[str]: # The test data from the cel-spec conformance tests -cel_test_data = load_test_data(f"test/testdata/string_ext_{CEL_SPEC_VERSION}.textproto") +cel_test_data = load_test_data("test/testdata/string_ext.textproto") # Our supplemental tests of functionality not in the cel conformance file, but defined in the spec. supplemental_test_data = load_test_data("test/testdata/string_ext_supplemental.textproto") diff --git a/test/testdata/string_ext_v0.24.0.textproto b/test/testdata/string_ext.textproto similarity index 100% rename from test/testdata/string_ext_v0.24.0.textproto rename to test/testdata/string_ext.textproto From 24d170220e57df99e80398373660bf82d67cb52e Mon Sep 17 00:00:00 2001 From: Stefan VanBuren Date: Wed, 17 Sep 2025 09:58:21 -0400 Subject: [PATCH 2/4] Change job name to reflect usage --- .github/workflows/ci.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 884b9f00..7f1405f1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -11,8 +11,8 @@ on: permissions: contents: read jobs: - test: - name: Unit tests + ci: + name: CI runs-on: ubuntu-latest strategy: fail-fast: false From abf4d9f90c68d3deb954de1dfdccad706a7ee0f5 Mon Sep 17 00:00:00 2001 From: Stefan VanBuren Date: Wed, 17 Sep 2025 10:03:28 -0400 Subject: [PATCH 3/4] Try out dropping name from workflow step Might render without duplicates. --- .github/workflows/ci.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7f1405f1..c63502af 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -12,7 +12,6 @@ permissions: contents: read jobs: ci: - name: CI runs-on: ubuntu-latest strategy: fail-fast: false From 5d3a473bfea8c0801d755875a0d0c1364a402ed7 Mon Sep 17 00:00:00 2001 From: Stefan VanBuren Date: Wed, 17 Sep 2025 10:04:32 -0400 Subject: [PATCH 4/4] Revert "Try out dropping name from workflow step" This reverts commit abf4d9f90c68d3deb954de1dfdccad706a7ee0f5. --- .github/workflows/ci.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c63502af..7f1405f1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -12,6 +12,7 @@ permissions: contents: read jobs: ci: + name: CI runs-on: ubuntu-latest strategy: fail-fast: false