-
Notifications
You must be signed in to change notification settings - Fork 95
193 lines (160 loc) · 5.54 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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
name: CI
on:
- push
- pull_request
jobs:
lint:
runs-on: ubuntu-latest
name: Lint
steps:
- name: Git checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-py3.13-${{ hashFiles('poetry.lock') }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
- name: Lint with black
run: poetry run black --check --diff .
- name: Lint with flake8
run: poetry run flake8 --exclude .venv
- name: Lint with isort
run: poetry run isort --check --diff .
- name: Lint with pylint
run: poetry run pylint tests timezone_field
test:
runs-on: ubuntu-latest
name: Test py${{ matrix.python-version }}, dj${{ matrix.django-version }}, ${{ matrix.tz-engine}}, ${{ matrix.db-engine }}
strategy:
fail-fast: false
matrix:
# https://docs.djangoproject.com/en/5.1/faq/install/#what-python-version-can-i-use-with-django
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
django-version: ["4.2", "5.0", "5.1"]
db-engine: [sqlite, postgres]
tz-engine: [pytz, zoneinfo]
exclude:
- django-version: "4.2"
python-version: "3.13"
- django-version: "5.0"
python-version: "3.8"
- django-version: "5.0"
python-version: "3.9"
- django-version: "5.0"
python-version: "3.13"
- django-version: "5.0"
tz-engine: pytz
- django-version: "5.1"
python-version: "3.8"
- django-version: "5.1"
python-version: "3.9"
- django-version: "5.1"
tz-engine: pytz
env:
PYTHON_VERSION: ${{ matrix.python-version }}
DJANGO_VERSION: ${{ matrix.django-version }}
DB_ENGINE: ${{ matrix.db-engine }}
TZ_ENGINE: ${{ matrix.tz-engine }}
services:
postgres:
image: postgres
env:
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- name: Git checkout
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-py${{ matrix.python-version}}-dj${{ matrix.django-version }}-${{ matrix.tz-engine }}-${{ hashFiles('poetry.lock') }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
- name: Install django ${{ matrix.django-version }}
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: |
source .venv/bin/activate
pip install --pre "Django~=${{ matrix.django-version }}"
- name: Install pytz
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' && matrix.tz-engine == 'pytz'
run: |
source .venv/bin/activate
pip install pytz
- name: Remove pytz
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' && matrix.tz-engine != 'pytz'
run: |
source .venv/bin/activate
pip uninstall --yes pytz
- name: Test with coverage
env:
POSTGRES_HOST: localhost
POSTGRES_PORT: 5432
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
run: poetry run pytest --cov=timezone_field
- name: Generate coverage report
run: poetry run coverage xml
- name: Upload coverage report to codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
env_vars: PYTHON_VERSION,DJANGO_VERSION,DB_ENGINE
fail_ci_if_error: true
build:
runs-on: ubuntu-latest
name: Build
steps:
- name: Git checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-py3.13-${{ hashFiles('poetry.lock') }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
- name: Build with poetry
run: poetry build