-
-
Notifications
You must be signed in to change notification settings - Fork 5
205 lines (202 loc) · 6.52 KB
/
workflow.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
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
name: CI/CD
on:
pull_request:
push:
branches: [ main ]
schedule:
# run every day at midnight
- cron: "0 0 * * *"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
name: Run Linters
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install and configure Poetry
uses: snok/[email protected]
with:
version: 1.1.13
- name: Lint
run: make lint
test:
name: Run Tests
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# test python versions
- python: "3.7"
os: ubuntu-latest
starlette-version: "lockfile"
pydantic-version: "lockfile"
- python: "3.8"
os: ubuntu-latest
starlette-version: "lockfile"
pydantic-version: "lockfile"
- python: "3.9"
os: ubuntu-latest
starlette-version: "lockfile"
pydantic-version: "lockfile"
- python: "3.10"
os: ubuntu-latest
starlette-version: "lockfile"
pydantic-version: "lockfile"
# test OSs
- python: "3.x"
os: macos-latest
starlette-version: "lockfile"
pydantic-version: "lockfile"
- python: "3.x"
os: windows-latest
starlette-version: "lockfile"
pydantic-version: "lockfile"
# test Starlette
- python: "3.x"
os: ubuntu-latest
starlette-version: "starlette==0.21.0"
pydantic-version: "lockfile"
- python: "3.x"
os: ubuntu-latest
starlette-version: "git+https://github.com/encode/starlette.git@master"
pydantic-version: "lockfile"
# test Pydantic
- python: "3.x"
os: ubuntu-latest
starlette-version: "lockfile"
pydantic-version: "pydantic==1.10.2"
# Disabling because of high churn for Pydantic v2
# - python: "3.x"
# os: ubuntu-latest
# starlette-version: "lockfile"
# pydantic-version: "git+https://github.com/samuelcolvin/pydantic.git@main"
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- name: Install and configure Poetry
uses: snok/[email protected]
with:
version: 1.1.13
- name: Test
env:
STARLETTE: ${{ matrix.starlette-version }}
PYDANTIC: ${{ matrix.pydantic-version }}
run: |
if [ "$STARLETTE" != "lockfile" ]
then
poetry remove --dev fastapi || true
poetry remove starlette
poetry add ${STARLETTE}
fi
if [ "$PYDANTIC" != "lockfile" ]
then
poetry remove pydantic
poetry add ${PYDANTIC}
poetry lock --no-update
fi
make test
- name: Export Coverage Report
run: |
poetry run pip install "coverage[toml]"
poetry run coverage xml
- name: Upload code coverage
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
name: xpresso
env_vars: OS,PYTHON
fail_ci_if_error: true
version-check:
name: Check Version Bump
if: github.ref != 'refs/heads/main'
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v2
with:
path: current
- uses: actions/checkout@v2
with:
ref: main
path: main
- name: Install and configure Poetry
uses: snok/[email protected]
with:
version: 1.1.13
- name: Check version bump
run: |
cd $GITHUB_WORKSPACE/current
NEW_VERSION=$(poetry version -s)
cd $GITHUB_WORKSPACE/main
OLD_VERSION=$(poetry version -s)
python -c "from packaging import version;assert version.parse(\"${NEW_VERSION}\") > version.parse(\"${OLD_VERSION}\"), \"❌ Bad version bump detected: you must bump the version in pyproject.toml\""
python -c "print(\"✅ Version will be bumped from ${OLD_VERSION} to ${NEW_VERSION}\")"
docs:
if: github.ref == 'refs/heads/main' && github.event_name != 'schedule'
concurrency: docs-branch
name: 🚀 Deploy Docs 📄
runs-on: ubuntu-latest
needs: ["test", "lint"]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # fetch all commits/branches
- name: Set up Python
uses: actions/setup-python@v2
- name: Install and configure Poetry
uses: snok/[email protected]
with:
version: 1.1.13
- name: Deploy docs
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
make docs-deploy
pypi:
if: github.ref == 'refs/heads/main' && github.event_name != 'schedule'
name: 🚀 PyPi Release 📦
runs-on: ubuntu-latest
needs: ["test", "lint"]
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
- name: Install and configure Poetry
uses: snok/[email protected]
with:
version: 1.1.13
- name: Release on PyPi
continue-on-error: true # allow pushes to main that don't release
id: pypi
run: |
PACKAGE_VERSION=$(poetry version -s)
echo "package_version=$PACKAGE_VERSION" >> $GITHUB_ENV
printf "\nSee this release on GitHub: [v$PACKAGE_VERSION](https://github.com/$GITHUB_REPOSITORY/releases/tag/$PACKAGE_VERSION)\n" >> README.md
poetry config pypi-token.pypi "${{ secrets.PYPI_TOKEN }}"
poetry publish --build
- name: 🚀 Create GitHub Release 😺
uses: ncipollo/release-action@v1
if: steps.pypi.outcome == 'success'
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ env.package_version }}
generateReleaseNotes: true