Skip to content

Commit 02b37bb

Browse files
committed
chore(ci): expand pre-commit hooks and update github actions
- Add format, lint, build, test, docs coverage, WASM build, and OAS/Swagger petstore checks to pre-commit config and script. - Ensure test dependencies and test harnesses are cloned in github actions CI to support updated hooks. - Ignore transient .tmp_oas3/ and .tmp_swagger/ directories. - Minor model format adjustment due to auto-format.
1 parent ded045c commit 02b37bb

6 files changed

Lines changed: 78 additions & 30 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,18 @@ jobs:
1616
uses: actions/setup-python@v5
1717
with:
1818
python-version: '3.11'
19+
- name: Checkout Test Harness
20+
uses: actions/checkout@v4
21+
with:
22+
repository: SamuelMarks/cdd-openapi-test-harness
23+
path: cdd-openapi-test-harness
1924
- name: Install dependencies
2025
run: |
2126
pip install uv
2227
make install_deps
2328
- name: Run pre-commit hooks
29+
env:
30+
TEST_HARNESS_DIR: ${{ github.workspace }}/cdd-openapi-test-harness
2431
run: |
2532
uv tool install pre-commit --with pre-commit-uv
2633
pre-commit run --all-files

‎.gitignore‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,3 +170,7 @@ celerybeat.pid
170170
/fix_*.py
171171

172172
/test_pydantic_v1.py
173+
174+
# Pre-commit test directories
175+
.tmp_swagger/
176+
.tmp_oas3/

‎.pre-commit-config.yaml‎

Lines changed: 49 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,50 @@
11
repos:
2-
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.5.0
4-
hooks:
5-
- id: trailing-whitespace
6-
- id: check-yaml
7-
- id: check-added-large-files
8-
- repo: https://github.com/astral-sh/ruff-pre-commit
9-
rev: v0.4.4
10-
hooks:
11-
- id: ruff
12-
args: [ --fix ]
13-
- id: ruff-format
14-
- repo: local
15-
hooks:
16-
- id: build
17-
name: Build
18-
entry: uv build
19-
language: system
20-
pass_filenames: false
21-
always_run: true
22-
- id: test-and-coverage-badges
23-
name: Run Tests and Update Coverage Badges
24-
entry: uv run python scripts/update_badges.py
25-
language: system
26-
pass_filenames: false
27-
always_run: true
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.5.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: check-yaml
7+
- id: check-added-large-files
8+
- repo: https://github.com/astral-sh/ruff-pre-commit
9+
rev: v0.4.4
10+
hooks:
11+
- id: ruff
12+
args:
13+
- --fix
14+
- id: ruff-format
15+
- repo: local
16+
hooks:
17+
- id: build
18+
name: Build
19+
entry: uv build
20+
language: system
21+
pass_filenames: false
22+
always_run: true
23+
- id: test-and-coverage-badges
24+
name: Run Tests and Update Coverage Badges
25+
entry: uv run python scripts/update_badges.py
26+
language: system
27+
pass_filenames: false
28+
always_run: true
29+
- id: swagger-2-0-petstore
30+
name: Swagger 2.0 Petstore Test
31+
entry: bash -c "TEST_HARNESS=${TEST_HARNESS_DIR:-/Users/samuel/repos/cdd-openapi-test-harness};
32+
uv run cdd-python from_openapi to_sdk_cli -i $TEST_HARNESS/petstore.json -o
33+
.tmp_swagger && rm -rf .tmp_swagger"
34+
language: system
35+
pass_filenames: false
36+
always_run: true
37+
- id: openapi-3-2-0-petstore
38+
name: OpenAPI 3.2.0 Petstore Test
39+
entry: bash -c "TEST_HARNESS=${TEST_HARNESS_DIR:-/Users/samuel/repos/cdd-openapi-test-harness};
40+
uv run cdd-python from_openapi to_sdk_cli -i $TEST_HARNESS/petstore_oas3.json
41+
-o .tmp_oas3 && rm -rf .tmp_oas3"
42+
language: system
43+
pass_filenames: false
44+
always_run: true
45+
- id: build-wasm
46+
name: Build WASM
47+
entry: make build_wasm
48+
language: system
49+
pass_filenames: false
50+
always_run: true

‎README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ cdd-python-all
22
==============
33
[![License](https://img.shields.io/badge/license-Apache--2.0%20OR%20MIT-blue.svg)](https://opensource.org/licenses/Apache-2.0)
44
[![CI](https://github.com/offscale/cdd-python-all/actions/workflows/ci.yml/badge.svg)](https://github.com/offscale/cdd-python-all/actions)
5-
[![Test Coverage](https://img.shields.io/badge/test_coverage-100%25-brightgreen.svg)](#)
6-
[![Doc Coverage](https://img.shields.io/badge/doc_coverage-100%25-brightgreen.svg)](#)
5+
[![Test Coverage](https://img.shields.io/badge/test_coverage-99%25-brightgreen.svg)](#)
6+
[![Doc Coverage](https://img.shields.io/badge/doc_coverage-99%25-brightgreen.svg)](#)
77

88
----
99

‎scripts/pre-commit‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,24 @@ echo "[pre-commit] Checking linting..."
1515
uv run ruff check .
1616

1717
echo "[pre-commit] Building project..."
18-
uv run python -m build
18+
uv build
1919

20-
echo "[pre-commit] Calculating coverage and updating badges..."
20+
echo "[pre-commit] Running tests and updating badges..."
2121
uv run python scripts/update_badges.py
2222

23+
TEST_HARNESS=${TEST_HARNESS_DIR:-/Users/samuel/repos/cdd-openapi-test-harness}
24+
25+
echo "[pre-commit] Running Swagger 2.0 Petstore test..."
26+
uv run cdd-python from_openapi to_sdk_cli -i "$TEST_HARNESS/petstore.json" -o .tmp_swagger
27+
rm -rf .tmp_swagger
28+
29+
echo "[pre-commit] Running OpenAPI 3.2.0 Petstore test..."
30+
uv run cdd-python from_openapi to_sdk_cli -i "$TEST_HARNESS/petstore_oas3.json" -o .tmp_oas3
31+
rm -rf .tmp_oas3
32+
33+
echo "[pre-commit] Building WASM..."
34+
make build_wasm
35+
2336
if git diff --name-only | grep -q "README.md"; then
2437
echo "[pre-commit] README.md was updated with new coverage badges. Staging changes..."
2538
git add README.md

‎src/openapi_client/models.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class OpenAPIBase(BaseModel):
1515
populate_by_name=True,
1616
)
1717
else:
18+
1819
class Config:
1920
extra = "allow"
2021
allow_population_by_field_name = True

0 commit comments

Comments
 (0)