Skip to content

Commit d3b7a9e

Browse files
Yang JingYang Jing
authored andcommitted
Add CI/CD workflow for lint, test, and PyPI publish
1 parent 6d7e96e commit d3b7a9e

1 file changed

Lines changed: 75 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
tags: ["v*"]
7+
pull_request:
8+
branches: [main]
9+
10+
jobs:
11+
lint:
12+
name: Lint
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- uses: actions/setup-python@v5
18+
with:
19+
python-version: "3.12"
20+
cache: pip
21+
22+
- name: Install dependencies
23+
run: pip install ruff
24+
25+
- name: Ruff check
26+
run: ruff check .
27+
28+
- name: Ruff format check
29+
run: ruff format --check .
30+
31+
test:
32+
name: Test (Python ${{ matrix.python-version }})
33+
runs-on: ubuntu-latest
34+
strategy:
35+
fail-fast: false
36+
matrix:
37+
python-version: ["3.8", "3.11", "3.12", "3.13"]
38+
steps:
39+
- uses: actions/checkout@v4
40+
41+
- uses: actions/setup-python@v5
42+
with:
43+
python-version: ${{ matrix.python-version }}
44+
cache: pip
45+
46+
- name: Install package with dev dependencies
47+
run: pip install -e ".[dev]"
48+
49+
- name: Run tests
50+
run: pytest --tb=short -q
51+
52+
publish:
53+
name: Publish to PyPI
54+
needs: [lint, test]
55+
if: startsWith(github.ref, 'refs/tags/v')
56+
runs-on: ubuntu-latest
57+
environment: pypi
58+
permissions:
59+
id-token: write
60+
steps:
61+
- uses: actions/checkout@v4
62+
63+
- uses: actions/setup-python@v5
64+
with:
65+
python-version: "3.12"
66+
cache: pip
67+
68+
- name: Install build tools
69+
run: pip install build
70+
71+
- name: Build package
72+
run: python -m build
73+
74+
- name: Publish to PyPI
75+
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)