-
Notifications
You must be signed in to change notification settings - Fork 2
128 lines (121 loc) · 3.32 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
name: main
on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Hatch
run: pipx install hatch
- name: Set up python 3.8
uses: actions/setup-python@v5
with:
python-version: "3.8"
cache: "pip"
cache-dependency-path: "pyproject.toml"
- name: Check formatting with black
run: hatch run black --check
- name: Check docstrings with darglint
run: hatch run darglint
- name: Type check with mypy
run: hatch run mypy
- name: Lint with ruff
run: hatch run ruff
test:
runs-on: ${{ matrix.os }}-latest
strategy:
matrix:
os: [ubuntu, macos, windows]
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "pypy3.8"
- "pypy3.9"
- "pypy3.10"
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Install Hatch
run: pipx install hatch
- name: Set up python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
cache: "pip"
cache-dependency-path: "pyproject.toml"
- name: Test with pytest
run: hatch run pytest-ci ${{ matrix.python-version }}
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Hatch
run: pipx install hatch
- name: Build project
run: hatch build
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: artifacts
path: dist/*
if-no-files-found: error
pypi-publish:
runs-on: ubuntu-latest
needs:
- lint
- test
- build
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
environment: pypi-publish
permissions:
id-token: write
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: artifacts
path: dist
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
lint-spec-parser:
runs-on: ubuntu-latest
defaults:
run:
working-directory: spec_parser
steps:
- uses: actions/checkout@v4
- name: Install Poetry
run: pipx install poetry
- name: Set up python 3.8
uses: actions/setup-python@v5
with:
python-version: "3.8"
cache: "poetry"
cache-dependency-path: "spec_parser/poetry.lock"
- name: Install dependencies
run: poetry install --sync
- name: Check formatting with black
run: poetry run poe black --check
- name: Type check with mypy
run: poetry run poe mypy
- name: Lint with ruff
run: poetry run poe ruff
dummy-required-job:
runs-on: ubuntu-latest
needs:
- lint
- test
- build
- lint-spec-parser
if: always()
steps:
- run: exit 1
if: ${{ contains( needs.*.result, 'failure' ) || contains( needs.*.result, 'cancelled' ) }}