From bc305fbb2c0554e920c8f277e336b64679fdde1d Mon Sep 17 00:00:00 2001 From: nearlyforget Date: Wed, 11 Feb 2026 00:55:23 +0000 Subject: [PATCH 1/5] chore: add pre-commit configuration and CI --- .github/workflows/linter.yml | 17 +++++++++++++++++ .pre-commit-config.yaml | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 .github/workflows/linter.yml create mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml new file mode 100644 index 0000000..317d0c5 --- /dev/null +++ b/.github/workflows/linter.yml @@ -0,0 +1,17 @@ +name: Lint + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.x' + - uses: pre-commit/action@v3.0.1 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..9fdc00f --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,33 @@ +exclude: '^(\.github/|\.vscode/|node_modules/).*|CODE_OF_CONDUCT\.md|CHANGELOG\.md' + +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v6.0.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + args: [--unsafe] + - id: check-json + - id: check-added-large-files + - id: check-shebang-scripts-are-executable + - id: check-executables-have-shebangs +- repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.14.13 + hooks: + - id: ruff + args: [--fix, --exit-non-zero-on-fix, --ignore, "D,E501"] + - id: ruff-format +- repo: https://github.com/pre-commit/mirrors-prettier + rev: v4.0.0-alpha.8 + hooks: + - id: prettier + files: \.(md|yaml|yml|json)$ +- repo: https://github.com/koalaman/shellcheck-precommit + rev: v0.10.0 + hooks: + - id: shellcheck +- repo: https://github.com/codespell-project/codespell + rev: v2.4.1 + hooks: + - id: codespell From ab330e1554c8ccd225fde17f3146774f9dd4ef6c Mon Sep 17 00:00:00 2001 From: nearlyforget Date: Wed, 11 Feb 2026 05:10:41 +0000 Subject: [PATCH 2/5] chore: add license headers to config files --- .github/workflows/linter.yml | 14 ++++++++++++++ .pre-commit-config.yaml | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 317d0c5..102b38d 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -1,3 +1,17 @@ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + name: Lint on: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9fdc00f..1c90d26 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,3 +1,17 @@ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + exclude: '^(\.github/|\.vscode/|node_modules/).*|CODE_OF_CONDUCT\.md|CHANGELOG\.md' repos: From 291e34312ff7a618bdecf72f8a6d4b5cdabe7daf Mon Sep 17 00:00:00 2001 From: nearlyforget Date: Tue, 17 Feb 2026 21:24:35 +0000 Subject: [PATCH 3/5] chore: fix pre-commit issues --- .pre-commit-config.yaml | 34 +++++++++---------- ...85e70b53b965796398fcb6383a49f1dd8b6b5.json | 1 + 2 files changed, 18 insertions(+), 17 deletions(-) create mode 100644 node_modules/.cache/prettier/.prettier-caches/19c85e70b53b965796398fcb6383a49f1dd8b6b5.json diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1c90d26..649602f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,33 +15,33 @@ exclude: '^(\.github/|\.vscode/|node_modules/).*|CODE_OF_CONDUCT\.md|CHANGELOG\.md' repos: -- repo: https://github.com/pre-commit/pre-commit-hooks + - repo: https://github.com/pre-commit/pre-commit-hooks rev: v6.0.0 hooks: - - id: trailing-whitespace - - id: end-of-file-fixer - - id: check-yaml + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml args: [--unsafe] - - id: check-json - - id: check-added-large-files - - id: check-shebang-scripts-are-executable - - id: check-executables-have-shebangs -- repo: https://github.com/astral-sh/ruff-pre-commit + - id: check-json + - id: check-added-large-files + - id: check-shebang-scripts-are-executable + - id: check-executables-have-shebangs + - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.14.13 hooks: - - id: ruff + - id: ruff args: [--fix, --exit-non-zero-on-fix, --ignore, "D,E501"] - - id: ruff-format -- repo: https://github.com/pre-commit/mirrors-prettier + - id: ruff-format + - repo: https://github.com/pre-commit/mirrors-prettier rev: v4.0.0-alpha.8 hooks: - - id: prettier + - id: prettier files: \.(md|yaml|yml|json)$ -- repo: https://github.com/koalaman/shellcheck-precommit + - repo: https://github.com/koalaman/shellcheck-precommit rev: v0.10.0 hooks: - - id: shellcheck -- repo: https://github.com/codespell-project/codespell + - id: shellcheck + - repo: https://github.com/codespell-project/codespell rev: v2.4.1 hooks: - - id: codespell + - id: codespell diff --git a/node_modules/.cache/prettier/.prettier-caches/19c85e70b53b965796398fcb6383a49f1dd8b6b5.json b/node_modules/.cache/prettier/.prettier-caches/19c85e70b53b965796398fcb6383a49f1dd8b6b5.json new file mode 100644 index 0000000..a0ee5d4 --- /dev/null +++ b/node_modules/.cache/prettier/.prettier-caches/19c85e70b53b965796398fcb6383a49f1dd8b6b5.json @@ -0,0 +1 @@ +{"1d7b620d4732f62f2827a8097c96a5f75348f423":{"files":{".pre-commit-config.yaml":["LImXE1XEBUxgJ3X90Eua+yschG0=",true],".github/workflows/release.yml":["F/pdf27ZckFDngaoleKvRxk/WdE=",true],"SECURITY.md":["J52i8VInV3D4WipivUwPs2q1B+0=",true],"README.md":["k3XrB4jR3leLbMI4PzEx/bvP47M=",true]},"modified":1771363428507}} \ No newline at end of file From 5b3a0e461b3997356b5a4d800af13e5c01496748 Mon Sep 17 00:00:00 2001 From: nearlyforget Date: Tue, 17 Feb 2026 21:30:00 +0000 Subject: [PATCH 4/5] chore: ensure node_modules are ignored and removed from index --- .gitignore | 5 +++++ .../19c85e70b53b965796398fcb6383a49f1dd8b6b5.json | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 .gitignore delete mode 100644 node_modules/.cache/prettier/.prettier-caches/19c85e70b53b965796398fcb6383a49f1dd8b6b5.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2874c4a --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +node_modules/ +.ruff_cache/ +__pycache__/ +.venv/ +*.py[cod] diff --git a/node_modules/.cache/prettier/.prettier-caches/19c85e70b53b965796398fcb6383a49f1dd8b6b5.json b/node_modules/.cache/prettier/.prettier-caches/19c85e70b53b965796398fcb6383a49f1dd8b6b5.json deleted file mode 100644 index a0ee5d4..0000000 --- a/node_modules/.cache/prettier/.prettier-caches/19c85e70b53b965796398fcb6383a49f1dd8b6b5.json +++ /dev/null @@ -1 +0,0 @@ -{"1d7b620d4732f62f2827a8097c96a5f75348f423":{"files":{".pre-commit-config.yaml":["LImXE1XEBUxgJ3X90Eua+yschG0=",true],".github/workflows/release.yml":["F/pdf27ZckFDngaoleKvRxk/WdE=",true],"SECURITY.md":["J52i8VInV3D4WipivUwPs2q1B+0=",true],"README.md":["k3XrB4jR3leLbMI4PzEx/bvP47M=",true]},"modified":1771363428507}} \ No newline at end of file From e5a56eaf4425fe67325c6359f9d2ea2a38e342a0 Mon Sep 17 00:00:00 2001 From: nearlyforget Date: Wed, 18 Feb 2026 17:50:53 +0000 Subject: [PATCH 5/5] ci: add auto-generate workflow (configured for forks) --- .github/workflows/auto-generate.yml | 96 +++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 .github/workflows/auto-generate.yml diff --git a/.github/workflows/auto-generate.yml b/.github/workflows/auto-generate.yml new file mode 100644 index 0000000..4c0a1ea --- /dev/null +++ b/.github/workflows/auto-generate.yml @@ -0,0 +1,96 @@ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: Auto-Generate SDK +on: + repository_dispatch: + types: [spec-release] + +jobs: + generate: + runs-on: ubuntu-latest + steps: + - name: Checkout SDK Repo + uses: actions/checkout@v4 + with: + path: python-sdk + + - name: Checkout UCP Spec Repo + uses: actions/checkout@v4 + with: + repository: nearlyforget/ucp_nan + ref: ${{ github.event.client_payload.version }} + path: ucp-spec + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + + - name: Install uv + uses: astral-sh/setup-uv@v5 + with: + enable-cache: true + + - name: Generate Code + env: + UCP_SPEC_PATH: ${{ github.workspace }}/ucp-spec/spec + SDK_PATH: ${{ github.workspace }}/python-sdk + run: | + echo "Generating Pydantic models from $UCP_SPEC_PATH" + OUTPUT_DIR="$SDK_PATH/src/ucp_sdk/models" + rm -r -f "$OUTPUT_DIR" + mkdir -p "$OUTPUT_DIR" + + cd "$SDK_PATH" + uv run \ + --link-mode=copy \ + --extra-index-url https://pypi.org/simple python \ + -m datamodel_code_generator \ + --input "$UCP_SPEC_PATH" \ + --input-file-type jsonschema \ + --output "$OUTPUT_DIR" \ + --output-model-type pydantic_v2.BaseModel \ + --use-schema-description \ + --field-constraints \ + --use-field-description \ + --enum-field-as-literal all \ + --disable-timestamp \ + --use-double-quotes \ + --no-use-annotated \ + --allow-extra-fields \ + --formatters ruff-format ruff-check + + - name: Update `pyproject.toml` version + id: version_bump + run: | + # Get version from payload, e.g. "v1.2.0" + TAG_VERSION="${{ github.event.client_payload.version }}" + # Remove leading 'v' for PEP440 compliance, e.g. "1.2.0" + PY_VERSION=${TAG_VERSION#v} + # Use sed to find 'version = "..."' and replace it + sed -i "s/^version = \".*\"/version = \"$PY_VERSION\"/" python-sdk/pyproject.toml + echo "Updated pyproject.toml to version $PY_VERSION" + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v6 + with: + path: python-sdk + token: ${{ secrets.PAT_TOKEN }} + title: "feat: Update SDK to match UCP ${{ github.event.client_payload.version }}" + body: "This PR was auto-generated by the release of UCP ${{ github.event.client_payload.version }}. + +Includes updated models and version bump to `${{ github.event.client_payload.version }}`." + branch: "auto-update-sdk-${{ github.event.client_payload.version }}" + base: main