Skip to content

Commit 9bd0357

Browse files
Merge pull request #49 from phillipdupuis/v2-changes
v2
2 parents 83ec9e9 + 168104d commit 9bd0357

33 files changed

+1109
-274
lines changed

.github/workflows/cicd.yml

+67-47
Original file line numberDiff line numberDiff line change
@@ -4,78 +4,98 @@ on:
44
pull_request:
55
jobs:
66
lint:
7-
name: Lint code with black
7+
name: Lint code with ruff
88
runs-on: ubuntu-latest
99
steps:
10-
- uses: actions/checkout@v2
11-
- uses: psf/black@stable
10+
- uses: actions/checkout@v4
11+
- uses: astral-sh/ruff-action@v1
12+
with:
13+
src: ./pydantic2ts
1214
test:
1315
name: Run unit tests
1416
needs: lint
1517
runs-on: ${{ matrix.os }}
1618
strategy:
1719
matrix:
1820
os: [ubuntu-latest, windows-latest, macOS-latest]
19-
python-version: ["3.8"]
21+
python-version: ["3.9"]
2022
include:
2123
- os: ubuntu-latest
22-
python-version: "3.6"
24+
python-version: "3.8"
2325
- os: ubuntu-latest
24-
python-version: "3.7"
26+
python-version: "3.10"
2527
- os: ubuntu-latest
26-
python-version: "3.9"
28+
python-version: "3.11"
2729
- os: ubuntu-latest
28-
python-version: "3.10"
30+
python-version: "3.12"
31+
- os: ubuntu-latest
32+
python-version: "3.13"
2933
steps:
3034
- name: Check out repo
31-
uses: actions/checkout@v3
32-
- name: Set up Node.js 16
33-
uses: actions/setup-node@v3
34-
with:
35-
node-version: 16
36-
- name: Set up Python ${{ matrix.python-version }}
37-
uses: actions/setup-python@v4
35+
uses: actions/checkout@v4
36+
- name: Install node
37+
uses: actions/setup-node@v4
3838
with:
39-
python-version: ${{ matrix.python-version }}
39+
node-version: 20
4040
- name: Install json-schema-to-typescript
41+
run: npm i -g json-schema-to-typescript
42+
- name: Install uv
43+
uses: astral-sh/setup-uv@v3
44+
with:
45+
version: "0.5.2"
46+
- name: Run tests against 'pydantic@latest'
4147
run: |
42-
npm i -g json-schema-to-typescript
43-
- name: Install python dependencies
44-
run: |
45-
python -m pip install -U pip wheel pytest pytest-cov coverage
46-
python -m pip install -U .
47-
- name: Run tests
48-
run: |
49-
python -m pytest --cov=pydantic2ts
50-
- name: Generate LCOV File
51-
if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.8' }}
48+
uv python install ${{ matrix.python-version }}
49+
uv sync --all-extras --dev
50+
uv run pytest --cov=pydantic2ts
51+
- name: (ubuntu 3.9) Run tests against 'pydantic==1.8.2' and generate an LCOV file for Coveralls
52+
if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.9' }}
5253
run: |
53-
coverage lcov
54-
- name: Coveralls
55-
if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.8' }}
56-
uses: coverallsapp/github-action@master
54+
uv add 'pydantic==1.8.2'
55+
uv run pytest --cov=pydantic2ts --cov-append
56+
uv run coverage lcov
57+
- name: (ubuntu 3.9) Upload to Coveralls
58+
if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.9' }}
59+
uses: coverallsapp/github-action@v2
5760
with:
5861
github-token: ${{ secrets.GITHUB_TOKEN }}
5962
path-to-lcov: coverage.lcov
60-
deploy:
61-
name: Deploy to PyPi
62-
runs-on: ubuntu-latest
63+
build:
64+
name: Build pydantic2ts for distribution
6365
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
6466
needs: test
67+
runs-on: ubuntu-latest
6568
steps:
66-
- uses: actions/checkout@v3
67-
- name: Set up Python 3.8
68-
uses: actions/setup-python@v4
69+
- name: Check out repo
70+
uses: actions/checkout@v4
71+
- name: Install uv
72+
uses: astral-sh/setup-uv@v3
6973
with:
70-
python-version: 3.8
71-
- name: Install dependencies
72-
run: |
73-
python -m pip install -U pip wheel
74-
- name: Build dist
75-
run: |
76-
python setup.py sdist bdist_wheel bdist_egg
77-
- name: Publish package
78-
uses: pypa/[email protected]
74+
version: "0.5.2"
75+
- name: Install python 3.9
76+
run: uv python install 3.9
77+
- name: Build pydantic2ts
78+
run: uv build
79+
- name: Store the distribution
80+
uses: actions/upload-artifact@v4
81+
with:
82+
name: pydantic2ts-dist
83+
path: dist/
84+
publish-to-pypi:
85+
name: Publish pydantic2ts to PyPI
86+
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
87+
needs: build
88+
runs-on: ubuntu-latest
89+
environment:
90+
name: pypi
91+
url: https://pypi.org/p/pydantic-to-typescript
92+
permissions:
93+
id-token: write
94+
steps:
95+
- name: Download all the dists
96+
uses: actions/download-artifact@v4
7997
with:
80-
user: __token__
81-
password: ${{ secrets.pypi_password }}
98+
name: pydantic2ts-dist
99+
path: dist/
100+
- name: Publish distributions to PyPI
101+
uses: pypa/gh-action-pypi-publish@release/v1

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ celerybeat.pid
107107
# Environments
108108
.env
109109
.venv
110+
.venv-v1
110111
env/
111112
venv/
112113
ENV/
@@ -143,3 +144,7 @@ cython_debug/
143144

144145
# VS Code config
145146
.vscode
147+
148+
# test outputs
149+
output_debug.ts
150+
schema_debug.json

action.yml

+5-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ name: Pydantic to Typescript
22
description: |
33
Convert pydantic models into typescript definitions and ensure that your type definitions are in sync.
44
author: Phillip Dupuis
5-
65
inputs:
76
python-module:
87
required: true
@@ -44,17 +43,17 @@ runs:
4443
using: composite
4544
steps:
4645
- name: Set up Python
47-
uses: actions/setup-python@v4
46+
uses: actions/setup-python@v5
4847
with:
49-
python-version: ">=3.6 <=3.10"
48+
python-version: "3.x"
5049
- name: Install pydantic-to-typescript
5150
shell: bash
5251
run: |
5352
python -m pip install -U pip wheel pydantic-to-typescript
54-
- name: Set up Node.js 16
55-
uses: actions/setup-node@v3
53+
- name: Set up Node.js 20
54+
uses: actions/setup-node@v4
5655
with:
57-
node-version: 16
56+
node-version: 20
5857
- name: Install json-schema-to-typescript
5958
shell: bash
6059
run: |

pydantic2ts/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
from pydantic2ts.cli.script import generate_typescript_defs
2+
3+
__all__ = ("generate_typescript_defs",)

0 commit comments

Comments
 (0)