Skip to content

Commit 29e3c85

Browse files
committed
Add GitHub Actions CI workflow
1 parent 3ba03ed commit 29e3c85

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

.github/workflows/ci.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
python-version: ["3.9", "3.10", "3.11", "3.12"]
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Set up Python ${{ matrix.python-version }}
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
25+
- name: Install dependencies
26+
run: |
27+
python -m pip install --upgrade pip
28+
pip install -e ".[dev]"
29+
30+
- name: Lint with ruff
31+
run: |
32+
ruff check .
33+
ruff format --check .
34+
35+
- name: Type check with mypy
36+
run: |
37+
mypy pydantic_prompt
38+
39+
- name: Test with pytest
40+
run: |
41+
pytest --cov=pydantic_prompt --cov-report=xml
42+
43+
- name: Upload coverage to Codecov
44+
uses: codecov/codecov-action@v3
45+
with:
46+
file: ./coverage.xml
47+
fail_ci_if_error: false
48+
49+
publish:
50+
needs: test
51+
if: startsWith(github.ref, 'refs/tags/')
52+
runs-on: ubuntu-latest
53+
54+
steps:
55+
- uses: actions/checkout@v4
56+
57+
- name: Set up Python
58+
uses: actions/setup-python@v5
59+
with:
60+
python-version: "3.10"
61+
62+
- name: Install build dependencies
63+
run: |
64+
python -m pip install --upgrade pip
65+
pip install build twine
66+
67+
- name: Build and check package
68+
run: |
69+
python -m build
70+
twine check dist/*
71+
72+
- name: Publish to PyPI
73+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
74+
uses: pypa/gh-action-pypi-publish@release/v1
75+
with:
76+
password: ${{ secrets.PYPI_API_TOKEN }}

0 commit comments

Comments
 (0)