-
Notifications
You must be signed in to change notification settings - Fork 1
125 lines (106 loc) · 3.21 KB
/
cicd.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
#
# Example GitHub Actions config for UW-IT AXD2 app testing and publishing to PyPi
#
# Preconditions:
#
# 1) Application contains a setup.py file
#
# 2) Application repo has access to the required secret
# at https://github.com/organizations/uw-it-aca/settings/secrets:
#
# PYPI_API_TOKEN
#
# To adapt this config to a specific Python app:
#
# 1) Set APP_NAME to the name of the package name/directory.
#
# 2) Set CONF_PATH to a path containing a urls.py and/or settings.py file
# used by the test suite, if any
#
# 3) Verify that the lists of branches for push/pull_request is appropriate,
# and add other branch names if needed.
#
# 4) Update the matrix of django versions to test, if necessary.
#
---
name: tests
env:
APP_NAME: blti
CONF_PATH: conf
COVERAGE_DJANGO_VERSION: '4.2'
COVERAGE_PYTHON_VERSION: '3.10'
on:
push:
branches: [main, master, qa, develop]
pull_request:
branches: [main, master, qa, develop]
types: [opened, reopened, synchronize]
release:
branches: [main, master]
types: [published]
jobs:
test:
runs-on: ubuntu-22.04
strategy:
matrix:
python-version:
- '3.8'
- '3.10'
django-version:
- '3.2'
- '4.2'
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -e .
pip install coverage coveralls==3.3.1
- name: Upgrade Django ${{ matrix.django-version }}
run: pip install "Django~=${{ matrix.django-version }}.0"
- name: Setup Django
run: |
django-admin startproject project .
test -f ${CONF_PATH}/urls.py && cp ${CONF_PATH}/urls.py project/
test -f ${CONF_PATH}/settings.py && cat ${CONF_PATH}/settings.py >> project/settings.py
- name: Run Python Linters
uses: uw-it-aca/actions/python-linters@main
with:
app_name: ${APP_NAME}
exclude_paths: 'migrations'
- name: Run Migrations
run: python manage.py migrate
- name: Run Tests
run: |
python -m compileall ${APP_NAME}/
coverage run --source=${APP_NAME}/ manage.py test ${APP_NAME}
- name: Report Test Coverage
if: |
matrix.django-version == env.COVERAGE_DJANGO_VERSION &&
matrix.python-version == env.COVERAGE_PYTHON_VERSION
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: coveralls
publish:
if: github.event_name == 'release' && startsWith(github.ref, 'refs/tags')
needs: test
runs-on: ubuntu-22.04
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Publish to PyPi
uses: uw-it-aca/actions/publish-pypi@main
with:
app_name: ${APP_NAME}
tag_name: ${{ github.event.release.tag_name }}
api_token: ${{ secrets.PYPI_API_TOKEN }}