-
Notifications
You must be signed in to change notification settings - Fork 141
240 lines (208 loc) · 6.5 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
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
name: Django Datatable View Tests
on:
push:
schedule:
- cron: '0 1 * * 5'
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
jobs:
outdated:
name: Outdated packages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .
pip install .[test]
- name: outdated
run: pip list --outdated --not-required --user | grep . && echo "There are outdated packages" && exit 1 || echo "All packages up to date"
black:
name: Black
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .
pip install .[test]
- name: Black
run: black --check .
ruff:
name: Ruff
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .
pip install .[test]
- name: Ruff
run: ruff check
pre-commit:
name: Pre-Commit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .
pip install .[test]
pre-commit install
- name: Pre-Commit
run: pre-commit run --all-files --show-diff-on-failure
security:
name: Bandit Security
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: 'pip'
- name: Install dependencies
run: |
pip install .
pip install .[test]
- name: Bandit
run: bandit -c pyproject.toml -r -f json -o report.json .
- name: Show report
if: ${{ success() || failure() }}
run: cat report.json
- name: "Upload Coverage Results"
if: ${{ success() || failure() }}
uses: actions/upload-artifact@v4
with:
name: Bandit Security Report
path: report.json
tests:
name: Python ${{ matrix.python-version }} / ${{ matrix.db }} / Django ${{ matrix.django-version}}
runs-on: ubuntu-latest
# continue-on-error: ${{ matrix.django-version == '~=5.0' }}
strategy:
max-parallel: 4
matrix:
db: [ sqlite, mariadb ]
django-version: ["~=4.2.0", "~=5.0"]
python-version: [ "3.12" ]
services:
mariadb:
image: mariadb:latest
env:
MARIADB_ROOT_PASSWORD: password
ports:
- 3306:3306
options: >-
--health-cmd="mariadb-admin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=3
steps:
- name: Verify MySQL connection from host
if: matrix.db == 'mariadb'
run: |
mysql --host 127.0.0.1 --port 3306 -uroot -ppassword -e "SHOW DATABASES" 2>&1 > /dev/null
mysql --host 127.0.0.1 --port 3306 -uroot -ppassword -V
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install dependencies
run: |
pip install .
pip install .[test]
pip uninstall -y Django
pip install Django${{ matrix.django-version }}
- name: Run ${{ matrix.db }} Django ${{ matrix.django-version }} Tests
env:
PYTHONWARNINGS: once::DeprecationWarning
DB_TYPE: ${{ matrix.db }}
run: export PYTHONPATH=`pwd` && coverage run
- name: "Upload Coverage Results for PY:${{ matrix.python-version }} DB:${{ matrix.db}} DJ:${{ matrix.django-version }}"
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.python-version }}-${{ matrix.db}}-${{ matrix.django-version }}
path: .coverage
retention-days: 1
- name: Django Check
run: python demo_app/manage.py check
coverage:
name: Upload Coverage to Codecov
needs: [ tests ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: |
pip install .
pip install .[test]
- uses: actions/download-artifact@v4
with:
path: .
- name: Combine Report Coverage
run: |
coverage combine coverage-*/.coverage
coverage report
coverage xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
directory: .
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
release:
name: Release
if: ${{ github.event_name != 'schedule' }}
runs-on: ubuntu-latest
needs: ['outdated', 'black', 'pre-commit', 'security', 'tests', 'coverage' ]
permissions: write-all
outputs:
bumped: ${{ steps.release.outputs.bumped }}
bump_version: ${{ steps.release.outputs.bump_version }}
bump_sha: ${{ steps.release.outputs.bump_sha }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: |
pip install git+https://${{ secrets.ORGANIZATIONAL_REPO_TOKEN }}@github.com/pivotal-energy-solutions/tensor-infrastructure@master#egg=infrastructure
- name: Release
id: release
env:
PYTHONWARNINGS: once::DeprecationWarning
GITHUB_TOKEN: ${{ secrets.ORGANIZATIONAL_REPO_TOKEN }}
run: |
bumper -P
echo "bumped=$(jq '.bumped' out.json)" >> $GITHUB_OUTPUT
echo "bump_version=$(jq '.bump_version' out.json)" >> $GITHUB_OUTPUT
echo "bump_sha=$(jq '.bump_sha' out.json)" >> $GITHUB_OUTPUT