-
Notifications
You must be signed in to change notification settings - Fork 10
95 lines (86 loc) · 2.91 KB
/
python-somacore.yaml
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
84
85
86
87
88
89
90
91
92
93
94
95
name: python-somacore
on:
pull_request:
branches: ["*"]
push:
branches: [main]
release:
types: [published]
jobs:
format-check:
runs-on: ubuntu-latest
env:
PYTHON_VERSION: "3.8"
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: pip
cache-dependency-path: "python-spec/requirements-py${{ env.PYTHON_VERSION }}*.txt"
- name: Install static analysis packages
working-directory: python-spec
run: pip install -r requirements-py${PYTHON_VERSION}.txt -r requirements-py${PYTHON_VERSION}-lint.txt
- name: Restore pre-commit cache
uses: actions/cache@v3
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
- name: Run mypy
run: mypy ./python-spec/src
# We maintain this full mypy step since running mypy in pre-commit is
# somewhat limited (cf. comments in .pre-commit-config.yaml).
- name: Pre-commit check
run: pre-commit run -a -v
run-tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
with:
# setuptools-scm needs a deep clone so it can look through history
# to find a relevant tag.
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: python-spec/requirements-py${{ matrix.python-version }}.txt
- name: Install prereqs
run: |
pip install --upgrade pip wheel pytest pytest-cov setuptools
pip install -r python-spec/requirements-py${{ matrix.python-version }}.txt
pip install .
- name: Run tests
working-directory: ./python-spec
run: |
pytest -s -v --junitxml=junit/test-results.xml --cov somacore --cov-report=xml --cov-report=html
upload-to-pypi:
needs:
- format-check
- run-tests
# Run only when tagging a release that starts with `python-`.
if: >
github.event_name == 'release'
&& github.event.action == 'published'
&& startsWith(github.event.release.tag_name, 'python-')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
cache: pip
cache-dependency-path: python-spec/requirements-py3.10.txt
python-version: "3.10"
- name: Set up environment
run: |
pip install --upgrade build pip wheel setuptools setuptools-scm
python -m build .
- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
packages_dir: dist