Skip to content

Commit fa59c0d

Browse files
authored
Merge pull request #703 from drnlm/feature/rework_ci_yaml
Refactor into main workflow and reusable workflow for the tests
2 parents 032bae0 + 2333f8f commit fa59c0d

File tree

2 files changed

+96
-107
lines changed

2 files changed

+96
-107
lines changed

.github/workflows/django.yml

Lines changed: 5 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,7 @@ name: Django CI
33
on: [push, pull_request]
44

55
jobs:
6-
postgres:
7-
8-
runs-on: ubuntu-latest
9-
10-
services:
11-
postgres:
12-
image: postgres
13-
env:
14-
POSTGRES_PASSWORD: postgres
15-
# Set health checks to wait until postgres has started
16-
options: >-
17-
--health-cmd pg_isready
18-
--health-interval 10s
19-
--health-timeout 5s
20-
--health-retries 5
21-
ports:
22-
# Maps tcp port 5432 on service container to the host
23-
- 5432:5432
24-
25-
name: Postgres - Python ${{ matrix.python-version }}, Django ${{ matrix.django-version }} (Allowed Failures - ${{ matrix.django-version == 'main' }} )
6+
non-selenium-tests:
267
strategy:
278
max-parallel: 4
289
matrix:
@@ -49,93 +30,10 @@ jobs:
4930
python-version: '3.12'
5031
- django-version: '4.1.0'
5132
python-version: '3.12'
52-
steps:
53-
- uses: actions/checkout@v4
54-
- name: Set up Python ${{ matrix.python-version }}
55-
uses: actions/setup-python@v5
56-
with:
57-
python-version: ${{ matrix.python-version }}
58-
- name: Install Dependencies
59-
continue-on-error: ${{ matrix.django-version == 'main' }}
60-
run: |
61-
python -m pip install --upgrade pip
62-
pip install -r requirements.txt -r requirements-dev.txt
63-
- name: 'Install psycopg2'
64-
run: |
65-
pip install psycopg2
66-
- name: Install Django Release
67-
run: |
68-
pip install django~=${{ matrix.django-version }}
69-
if: matrix.django-version != 'main'
70-
- name: Install Django Main
71-
continue-on-error: ${{ matrix.django-version == 'main' }}
72-
run: |
73-
pip install 'https://github.com/django/django/archive/main.tar.gz'
74-
if: matrix.django-version == 'main'
75-
- name: Run Tests
76-
continue-on-error: ${{ matrix.django-version == 'main' }}
77-
env:
78-
TESTDB: postgres
79-
run: |
80-
export PYTHONWARNINGS=always
81-
coverage run --source='wafer' manage.py test --exclude-tag selenium && coverage report --skip-covered
82-
83-
sqlite:
84-
85-
runs-on: ubuntu-latest
86-
87-
name: SQLite - Python ${{ matrix.python-version }}, Django ${{ matrix.django-version }} (Allowed Failures - ${{ matrix.django-version == 'main'}} )
88-
strategy:
89-
max-parallel: 4
90-
matrix:
91-
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
92-
django-version: ['3.2.0', '4.0.0', '4.1.0', '4.2.0', '5.0.0', 'main']
93-
exclude:
94-
- django-version: '4.2.0'
95-
python-version: '3.8'
96-
- django-version: 'main'
97-
python-version: '3.8'
98-
- django-version: 'main'
99-
python-version: '3.9'
100-
- django-version: '5.0.0'
101-
python-version: '3.8'
102-
- django-version: '5.0.0'
103-
python-version: '3.9'
104-
- django-version: '3.2.0'
105-
python-version: '3.11'
106-
- django-version: '4.0.0'
107-
python-version: '3.11'
108-
- django-version: '3.2.0'
109-
python-version: '3.12'
110-
- django-version: '4.0.0'
111-
python-version: '3.12'
112-
- django-version: '4.1.0'
113-
python-version: '3.12'
114-
steps:
115-
- uses: actions/checkout@v4
116-
- name: Set up Python ${{ matrix.python-version }}
117-
uses: actions/setup-python@v5
118-
with:
119-
python-version: ${{ matrix.python-version }}
120-
- name: Install Dependencies
121-
continue-on-error: ${{ matrix.django-version == 'main' }}
122-
run: |
123-
python -m pip install --upgrade pip
124-
pip install -r requirements.txt -r requirements-dev.txt
125-
- name: Install Django Release
126-
run: |
127-
pip install django~=${{ matrix.django-version }}
128-
if: matrix.django-version != 'main'
129-
- name: Install Django Main
130-
continue-on-error: ${{ matrix.django-version == 'main' }}
131-
run: |
132-
pip install 'https://github.com/django/django/archive/main.tar.gz'
133-
if: matrix.django-version == 'main'
134-
- name: Run Tests
135-
continue-on-error: ${{ matrix.django-version == 'main' }}
136-
run: |
137-
export PYTHONWARNINGS=always
138-
coverage run --source='wafer' manage.py test --exclude-tag selenium && coverage report --skip-covered
33+
uses: ./.github/workflows/run_tests.yml
34+
with:
35+
python-version: ${{ matrix.python-version }}
36+
django-version: ${{ matrix.django-version }}
13937

14038
translations:
14139
runs-on: ubuntu-latest

.github/workflows/run_tests.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Run tests against postgres and sqlite
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
python-version:
7+
required: true
8+
type: string
9+
django-version:
10+
required: true
11+
type: string
12+
13+
jobs:
14+
run-postgres-tests:
15+
runs-on: ubuntu-latest
16+
17+
services:
18+
postgres:
19+
image: postgres
20+
env:
21+
POSTGRES_PASSWORD: postgres
22+
# Set health checks to wait until postgres has started
23+
options: >-
24+
--health-cmd pg_isready
25+
--health-interval 10s
26+
--health-timeout 5s
27+
--health-retries 5
28+
ports:
29+
# Maps tcp port 5432 on service container to the host
30+
- 5432:5432
31+
32+
name: Postgres - Python ${{ inputs.python-version }}, Django ${{ inputs.django-version }} (Allowed Failures - ${{ inputs.django-version == 'main' }} )
33+
steps:
34+
- uses: actions/checkout@v4
35+
- name: Set up Python ${{ inputs.python-version }}
36+
uses: actions/setup-python@v5
37+
with:
38+
python-version: ${{ inputs.python-version }}
39+
- name: Install Dependencies
40+
continue-on-error: ${{ inputs.django-version == 'main' }}
41+
run: |
42+
python -m pip install --upgrade pip
43+
pip install -r requirements.txt -r requirements-dev.txt
44+
- name: 'Install psycopg2'
45+
run: |
46+
pip install psycopg2
47+
- name: Install Django Release
48+
run: |
49+
pip install django~=${{ inputs.django-version }}
50+
if: inputs.django-version != 'main'
51+
- name: Install Django Main
52+
continue-on-error: ${{ inputs.django-version == 'main' }}
53+
run: |
54+
pip install 'https://github.com/django/django/archive/main.tar.gz'
55+
if: inputs.django-version == 'main'
56+
- name: Run Tests
57+
continue-on-error: ${{ inputs.django-version == 'main' }}
58+
env:
59+
TESTDB: postgres
60+
run: |
61+
export PYTHONWARNINGS=always
62+
coverage run --source='wafer' manage.py test --exclude-tag selenium && coverage report --skip-covered
63+
64+
run-sqlite-tests:
65+
runs-on: ubuntu-latest
66+
name: SQLite - Python ${{ inputs.python-version }}, Django ${{ inputs.django-version }} (Allowed Failures - ${{ inputs.django-version == 'main'}} )
67+
steps:
68+
- uses: actions/checkout@v4
69+
- name: Set up Python ${{ inputs.python-version }}
70+
uses: actions/setup-python@v5
71+
with:
72+
python-version: ${{ inputs.python-version }}
73+
- name: Install Dependencies
74+
continue-on-error: ${{ inputs.django-version == 'main' }}
75+
run: |
76+
python -m pip install --upgrade pip
77+
pip install -r requirements.txt -r requirements-dev.txt
78+
- name: Install Django Release
79+
run: |
80+
pip install django~=${{ inputs.django-version }}
81+
if: inputs.django-version != 'main'
82+
- name: Install Django Main
83+
continue-on-error: ${{ inputs.django-version == 'main' }}
84+
run: |
85+
pip install 'https://github.com/django/django/archive/main.tar.gz'
86+
if: inputs.django-version == 'main'
87+
- name: Run Tests
88+
continue-on-error: ${{ inputs.django-version == 'main' }}
89+
run: |
90+
export PYTHONWARNINGS=always
91+
coverage run --source='wafer' manage.py test --exclude-tag selenium && coverage report --skip-covered

0 commit comments

Comments
 (0)