-
Notifications
You must be signed in to change notification settings - Fork 36
54 lines (50 loc) · 1.38 KB
/
python.yml
File metadata and controls
54 lines (50 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
name: Python Package
on:
push:
paths: ["python/**"]
branches: [main]
pull_request:
paths: ["python/**"]
merge_group:
defaults:
run:
working-directory: python
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: python/pyproject.toml
- name: Install package and test deps
run: pip install -e . && pip install pytest ruff
- name: Lint (fatal errors only)
run: ruff check . --select=E9,F63,F7,F82
- name: Run tests
run: python -m pytest tests/ -x -q --tb=short
publish:
needs: test
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Build
run: pip install build && python -m build
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
# working-directory default does NOT apply to uses actions;
# path is relative to $GITHUB_WORKSPACE
packages-dir: python/dist/