-
Notifications
You must be signed in to change notification settings - Fork 0
83 lines (81 loc) · 2.43 KB
/
main.yml
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
name: Main pipeline
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
jobs:
validate:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.10" ]
env:
POETRY_HOME: /opt/poetry
PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Check Python version
run: python --version
- name: Install poetry
run: |
python -m venv $POETRY_HOME
$POETRY_HOME/bin/pip install "poetry~=1.7.1"
$POETRY_HOME/bin/poetry --version
- name: Install package
run: |
$POETRY_HOME/bin/poetry install --with dev
- name: Validate
run: |
$POETRY_HOME/bin/poetry run ruff check
$POETRY_HOME/bin/poetry run ruff format --check
$POETRY_HOME/bin/poetry run mypy src/ tests/
- name: Run tests
run: |
$POETRY_HOME/bin/poetry run pytest tests/
build-and-publish:
needs: validate
# Only run if it's on main branch.
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10"]
env:
POETRY_HOME: /opt/poetry
PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Check Python version
run: python --version
- name: Install poetry
run: |
python -m venv $POETRY_HOME
$POETRY_HOME/bin/pip install "poetry~=1.7.1"
$POETRY_HOME/bin/poetry --version
- name: Install package
run: |
$POETRY_HOME/bin/poetry install --with dev
- name: Validate
run: |
$POETRY_HOME/bin/poetry run ruff check
$POETRY_HOME/bin/poetry run ruff format --check
$POETRY_HOME/bin/poetry run mypy src/ tests/
- name: Run tests
run: |
$POETRY_HOME/bin/poetry run pytest tests/
- name: Build
run: |
$POETRY_HOME/bin/poetry build
- name: Publish to PyPI
run: |
$POETRY_HOME/bin/poetry publish -u __token__ -p $PYPI_API_TOKEN