-
Notifications
You must be signed in to change notification settings - Fork 92
170 lines (163 loc) · 5.01 KB
/
ci.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
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
name: build
on:
push:
branches: [master]
pull_request:
branches: [master]
schedule:
- cron: "0 2 * * *"
jobs:
static-analysis:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: "3.9"
- uses: pre-commit/[email protected]
with:
extra_args: --all-files
compatibility-tests:
runs-on: ubuntu-latest
continue-on-error: true
strategy:
matrix:
python-version:
- "3.7"
- "3.8"
- "3.9"
- "3.10"
#- "3.11" # TODO: Enable once 3.11 is released
steps:
- uses: actions/checkout@v2
- name: Mongo Service
id: mongo-service
uses: art049/mongodb-cluster-action@v0
with:
version: "4.4"
mode: standalone
- name: "Set up Python ${{ matrix.python-version }}"
uses: actions/setup-python@v2
with:
python-version: "${{ matrix.python-version }}"
- name: Cache environment
uses: actions/cache@v2
with:
path: |
.venv
.tox
key: env-compatibility-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }}
- name: Install tox
run: pip install "tox~=3.27.1" flit
- name: Run compatibility checks.
run: |
export VERSION_STR=$(echo ${{ matrix.python-version }} | sed -e "s/\.//g")
export TOX_SKIP_ENV=$(printf '^(?!py%s-)' $VERSION_STR)
tox --parallel auto
tests:
runs-on: ubuntu-latest
continue-on-error: true
strategy:
matrix:
python-version:
- "3.7"
- "3.8"
- "3.9"
- "3.10"
#- "3.11" # TODO: Enable once 3.11 is released
mongo-version:
- "4.4"
- "5"
- "6"
mongo-mode:
- standalone
include:
- python-version: 3.8
mongo-version: 4.0
mongo-mode: replicaSet
- python-version: 3.8
mongo-version: 4.2
mongo-mode: sharded
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: "pyproject.toml"
- name: Mongo Service
id: mongo-service
uses: art049/mongodb-cluster-action@v0
with:
version: ${{ matrix.mongo-version }}
mode: ${{ matrix.mongo-mode }}
- name: Install dependencies
run: |
pip install flit
pip install ".[test]"
- name: Run all tests
run: |
set -e
coverage run -m pytest -v
coverage report -m
coverage xml
env:
TEST_MONGO_URI: ${{ steps.mongo-service.outputs.connection-string }}
TEST_MONGO_MODE: ${{ matrix.mongo-mode }}
- uses: codecov/codecov-action@v1
if: github.event_name != 'schedule' # Don't report coverage for nightly builds
with:
file: ./coverage.xml
flags: tests-${{ matrix.python-version }}-${{ matrix.mongo-version }}-${{ matrix.mongo-mode }}
fail_ci_if_error: true
integrated-realworld-test:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v3
with:
path: odmantic-current
- uses: actions/checkout@v3
with:
repository: art049/fastapi-odmantic-realworld-example
submodules: recursive
path: fastapi-odmantic-realworld-example
- name: Install poetry and flit
run: |
pipx install poetry
pipx install flit
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: "poetry"
- name: Install dependencies (w/o ODMantic)
working-directory: fastapi-odmantic-realworld-example
run: |
echo "$(grep -v 'odmantic =' ./pyproject.toml)" > pyproject.toml
poetry install
- name: Install current ODMantic version
working-directory: fastapi-odmantic-realworld-example
run: poetry run pip install ../odmantic-current/
- name: Start the MongoDB instance
uses: art049/mongodb-cluster-action@v0
id: mongodb-cluster-action
- name: Start the FastAPI server
working-directory: fastapi-odmantic-realworld-example
run: |
./scripts/start.sh &
# Wait for the server
while ! curl "http://localhost:8000/health" > /dev/null 2>&1
do
sleep 1;
done
echo "Server ready."
env:
MONGO_URI: ${{ steps.mongodb-cluster-action.outputs.connection-string }}
- name: Run realworld backend tests
working-directory: fastapi-odmantic-realworld-example
run: ./realworld/api/run-api-tests.sh
env:
APIURL: http://localhost:8000