forked from unioslo/mreg
-
Notifications
You must be signed in to change notification settings - Fork 0
125 lines (120 loc) · 3.62 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
on:
push:
paths-ignore:
- 'ci/**'
- 'README.md'
pull_request:
types: [opened, reopened, synchronize]
workflow_dispatch:
env:
UV_FROZEN: 1
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.10"
- "3.11"
- "3.12"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v3
- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ 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
uv sync --group ci
- name: Test with tox
run: uv run tox -r
env:
MREG_DB_PASSWORD: postgres
- name: Check migrations
run: |
export MREG_DB_NAME=mreg MREG_DB_USER=mreg MREG_DB_PASSWORD=postgres
uv run manage.py makemigrations --check
# - name: Export OpenAPI schema
# run: uv run manage.py generateschema > openapi.yml
# - name: Upload OpenAPI schema
# if: matrix.python-version == '3.10'
# uses: actions/upload-artifact@v4
# with:
# name: openapi.yml
# path: openapi.yml
- name: Upload coverage
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.python-version }}
path: .coverage
if-no-files-found: error
include-hidden-files: true
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.10"
- "3.11"
- "3.12"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v3
- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
- name: Download coverage
uses: actions/download-artifact@v4
with:
name: coverage-${{ matrix.python-version }}
- name: Install Coveralls
run: |
uv venv --no-project
uv pip install coveralls
- name: Run Coveralls
run: uv run --no-project 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 }}