CICD: make 'test' stage require 'lint' passes, change coveralls actio… #94
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI/CD | |
on: | |
push: | |
pull_request: | |
jobs: | |
lint: | |
name: Lint code with ruff | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: astral-sh/ruff-action@v1 | |
with: | |
src: ./pydantic2ts | |
test: | |
name: Run unit tests | |
needs: lint | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest, macOS-latest] | |
python-version: ["3.9"] | |
include: | |
- os: ubuntu-latest | |
python-version: "3.8" | |
- os: ubuntu-latest | |
python-version: "3.10" | |
- os: ubuntu-latest | |
python-version: "3.11" | |
- os: ubuntu-latest | |
python-version: "3.12" | |
- os: ubuntu-latest | |
python-version: "3.13" | |
steps: | |
- name: Check out repo | |
uses: actions/checkout@v4 | |
- name: Install node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Install json-schema-to-typescript | |
run: npm i -g json-schema-to-typescript | |
- name: Install uv | |
uses: astral-sh/setup-uv@v3 | |
with: | |
version: "0.5.2" | |
- name: Run tests against 'pydantic@latest' | |
run: | | |
uv python install ${{ matrix.python-version }} | |
uv sync --all-extras --dev | |
uv run pytest --cov=pydantic2ts | |
- name: (ubuntu 3.9) Run tests against 'pydantic==1.8.2' and generate an LCOV file for Coveralls | |
if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.9' }} | |
run: | | |
uv add 'pydantic==1.8.2' | |
uv run pytest --cov=pydantic2ts --cov-append | |
uv run coverage lcov | |
- name: (ubuntu 3.9) Upload to Coveralls | |
if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.9' }} | |
uses: coverallsapp/github-action@2 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
path-to-lcov: coverage.lcov | |
deploy: | |
name: Deploy to PyPi | |
needs: test | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') | |
steps: | |
- name: Check out repo | |
uses: actions/checkout@v4 | |
- name: Set up Python 3.9 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.9 | |
- name: Install dependencies | |
run: | | |
python -m pip install -U pip wheel | |
- name: Build dist | |
run: | | |
python setup.py sdist bdist_wheel bdist_egg | |
- name: Publish package | |
uses: pypa/[email protected] | |
with: | |
user: __token__ | |
password: ${{ secrets.pypi_password }} |