Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor into main workflow and reusable workflow for the tests #703

Merged
merged 1 commit into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 5 additions & 107 deletions .github/workflows/django.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,7 @@ name: Django CI
on: [push, pull_request]

jobs:
postgres:

runs-on: ubuntu-latest

services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432

name: Postgres - Python ${{ matrix.python-version }}, Django ${{ matrix.django-version }} (Allowed Failures - ${{ matrix.django-version == 'main' }} )
non-selenium-tests:
strategy:
max-parallel: 4
matrix:
Expand All @@ -49,93 +30,10 @@ jobs:
python-version: '3.12'
- django-version: '4.1.0'
python-version: '3.12'
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
continue-on-error: ${{ matrix.django-version == 'main' }}
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt -r requirements-dev.txt
- name: 'Install psycopg2'
run: |
pip install psycopg2
- name: Install Django Release
run: |
pip install django~=${{ matrix.django-version }}
if: matrix.django-version != 'main'
- name: Install Django Main
continue-on-error: ${{ matrix.django-version == 'main' }}
run: |
pip install 'https://github.com/django/django/archive/main.tar.gz'
if: matrix.django-version == 'main'
- name: Run Tests
continue-on-error: ${{ matrix.django-version == 'main' }}
env:
TESTDB: postgres
run: |
export PYTHONWARNINGS=always
coverage run --source='wafer' manage.py test --exclude-tag selenium && coverage report --skip-covered

sqlite:

runs-on: ubuntu-latest

name: SQLite - Python ${{ matrix.python-version }}, Django ${{ matrix.django-version }} (Allowed Failures - ${{ matrix.django-version == 'main'}} )
strategy:
max-parallel: 4
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
django-version: ['3.2.0', '4.0.0', '4.1.0', '4.2.0', '5.0.0', 'main']
exclude:
- django-version: '4.2.0'
python-version: '3.8'
- django-version: 'main'
python-version: '3.8'
- django-version: 'main'
python-version: '3.9'
- django-version: '5.0.0'
python-version: '3.8'
- django-version: '5.0.0'
python-version: '3.9'
- django-version: '3.2.0'
python-version: '3.11'
- django-version: '4.0.0'
python-version: '3.11'
- django-version: '3.2.0'
python-version: '3.12'
- django-version: '4.0.0'
python-version: '3.12'
- django-version: '4.1.0'
python-version: '3.12'
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
continue-on-error: ${{ matrix.django-version == 'main' }}
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt -r requirements-dev.txt
- name: Install Django Release
run: |
pip install django~=${{ matrix.django-version }}
if: matrix.django-version != 'main'
- name: Install Django Main
continue-on-error: ${{ matrix.django-version == 'main' }}
run: |
pip install 'https://github.com/django/django/archive/main.tar.gz'
if: matrix.django-version == 'main'
- name: Run Tests
continue-on-error: ${{ matrix.django-version == 'main' }}
run: |
export PYTHONWARNINGS=always
coverage run --source='wafer' manage.py test --exclude-tag selenium && coverage report --skip-covered
uses: ./.github/workflows/run_tests.yml
with:
python-version: ${{ matrix.python-version }}
django-version: ${{ matrix.django-version }}

translations:
runs-on: ubuntu-latest
Expand Down
91 changes: 91 additions & 0 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: Run tests against postgres and sqlite

on:
workflow_call:
inputs:
python-version:
required: true
type: string
django-version:
required: true
type: string

jobs:
run-postgres-tests:
runs-on: ubuntu-latest

services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432

name: Postgres - Python ${{ inputs.python-version }}, Django ${{ inputs.django-version }} (Allowed Failures - ${{ inputs.django-version == 'main' }} )
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ inputs.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
- name: Install Dependencies
continue-on-error: ${{ inputs.django-version == 'main' }}
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt -r requirements-dev.txt
- name: 'Install psycopg2'
run: |
pip install psycopg2
- name: Install Django Release
run: |
pip install django~=${{ inputs.django-version }}
if: inputs.django-version != 'main'
- name: Install Django Main
continue-on-error: ${{ inputs.django-version == 'main' }}
run: |
pip install 'https://github.com/django/django/archive/main.tar.gz'
if: inputs.django-version == 'main'
- name: Run Tests
continue-on-error: ${{ inputs.django-version == 'main' }}
env:
TESTDB: postgres
run: |
export PYTHONWARNINGS=always
coverage run --source='wafer' manage.py test --exclude-tag selenium && coverage report --skip-covered

run-sqlite-tests:
runs-on: ubuntu-latest
name: SQLite - Python ${{ inputs.python-version }}, Django ${{ inputs.django-version }} (Allowed Failures - ${{ inputs.django-version == 'main'}} )
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ inputs.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
- name: Install Dependencies
continue-on-error: ${{ inputs.django-version == 'main' }}
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt -r requirements-dev.txt
- name: Install Django Release
run: |
pip install django~=${{ inputs.django-version }}
if: inputs.django-version != 'main'
- name: Install Django Main
continue-on-error: ${{ inputs.django-version == 'main' }}
run: |
pip install 'https://github.com/django/django/archive/main.tar.gz'
if: inputs.django-version == 'main'
- name: Run Tests
continue-on-error: ${{ inputs.django-version == 'main' }}
run: |
export PYTHONWARNINGS=always
coverage run --source='wafer' manage.py test --exclude-tag selenium && coverage report --skip-covered
Loading