forked from unioslo/mreg
-
Notifications
You must be signed in to change notification settings - Fork 0
137 lines (134 loc) · 4 KB
/
test.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
on:
push:
paths-ignore:
- 'ci/**'
- 'README.md'
pull_request:
types: [opened, reopened, synchronize]
workflow_dispatch:
name: CI
jobs:
test:
name: Test
runs-on: ${{ matrix.os }}
services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: mreg
POSTGRES_PASSWORD: postgres
# Add health checks to wait until Postgres has started.
options: >-
--health-cmd "pg_isready && PGPASSWORD=$POSTGRES_PASSWORD psql -U mreg -c 'CREATE EXTENSION IF NOT EXISTS citext;' template1 || exit 1"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Map the containerized port to localhost.
- 5432:5432
strategy:
matrix:
os: [ubuntu-latest]
python-version:
- '3.7'
- '3.8'
- '3.9'
- '3.10'
- '3.11'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cache pip
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: v1-pip-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('requirements-*.txt') }}
restore-keys: |
v1-pip-${{ runner.os }}-${{ matrix.python-version }}
v1-pip-${{ runner.os }}
v1-pip-
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
# Needed to build the native python-ldap extension.
sudo apt-get update
sudo apt-get -y install libsasl2-dev libldap2-dev
pip install -r requirements.txt
pip install -r requirements-dev.txt
- name: Check migrations
run: python manage.py makemigrations --check
- name: Export OpenAPI schema
run: python manage.py generateschema > openapi.yml
- name: Test
run: coverage run manage.py test -v2
env:
MREG_DB_PASSWORD: postgres
- name: Upload OpenAPI schema
if: matrix.python-version == '3.10'
uses: actions/upload-artifact@v3
with:
name: openapi.yml
path: openapi.yml
- name: Upload coverage
uses: actions/upload-artifact@v3
with:
name: coverage-${{ matrix.python-version }}
path: .coverage
coveralls:
if: ${{ github.event_name == 'pull_request' || github.repository == 'unioslo/mreg' }}
name: Coveralls
needs: test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-version:
- '3.7'
- '3.8'
- '3.9'
- '3.10'
- '3.11'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cache pip
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: v1-pip-${{ runner.os }}-${{ matrix.python-version }}
restore-keys: |
v1-pip-${{ runner.os }}
v1-pip-
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Download coverage
uses: actions/download-artifact@v3
with:
name: coverage-${{ matrix.python-version }}
- name: Install Coveralls
run: pip install coveralls
- name: Run Coveralls
run: coveralls
env:
# Note: Set service name to work around
# https://github.com/TheKevJames/coveralls-python/issues/252
COVERALLS_SERVICE_NAME: github
COVERALLS_PARALLEL: true
COVERALLS_FLAG_NAME: python-${{ matrix.python-version }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
finish:
name: Coveralls Completed
needs: coveralls
runs-on: ubuntu-latest
container:
image: thekevjames/coveralls
steps:
- name: Coveralls Finish
run: coveralls --finish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}