Skip to content

Commit

Permalink
Merge pull request #558 from UW-GAC/maint/ci-combined-tests
Browse files Browse the repository at this point in the history
Combine mysql and sqlite tests into a single job
  • Loading branch information
amstilp authored May 8, 2024
2 parents 1abf702 + da6c0c0 commit caefe37
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 60 deletions.
74 changes: 16 additions & 58 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,34 @@ concurrency:

jobs:

pytest-mariadb:
test:
runs-on: ubuntu-latest
strategy:
max-parallel: 2
matrix:
# While we are only running for a single version
# ahead of planned upgrades we can add versions as
# needed
python-version: [3.8]
mariadb-version: ["10.4", "10.5"]
backend: ["sqlite", "mariadb"]
mariadb-version: ["10.4"]
include:
- python-version: 3.8 # Possible future version.
backend: "mariadb"
mariadb-version: "10.5"
name: "py${{ matrix.python-version }}-${{ matrix.backend }}-${{ matrix.mariadb-version }}"

services:
mysql:
# Always start mariadb, even if we are testing with the mysql backend.
# Github actions do not allow conditional services yet.
image: mariadb:${{ matrix.mariadb-version }}
ports:
- 3306:3306
env:
MYSQL_ROOT_PASSWORD: root

options: --tmpfs /var/lib/mysql

env:
# mysql://user:password@host:port/database
DATABASE_URL: "mysql://root:[email protected]:3306/mysql"
# We can set this to an empty string, since we'll never make an API call.
ANVIL_API_SERVICE_ACCOUNT_FILE: foo
PYTEST_ADDOPTS: "--maxfail=20" # Stop testing after too many failures.
# Conditionally set the database url based on the backend.
DATABASE_URL: ${{ matrix.backend == 'sqlite' && 'sqlite:///db.sqlite3' || 'mysql://root:[email protected]:3306/mysql' }}

steps:

Expand All @@ -71,61 +74,16 @@ jobs:

- name: Run tests
run: coverage run -p -m pytest
env:
# We can set this to an empty string, since we'll never make an API call.
ANVIL_API_SERVICE_ACCOUNT_FILE: foo

- name: Upload coverage data
uses: actions/upload-artifact@v4
with:
name: coverage-data-mysql-${{ strategy.job-index }}
path: .coverage.*

pytest-sqlite:
runs-on: ubuntu-latest

env:
# We can set this to an empty string, since we'll never make an API call.
ANVIL_API_SERVICE_ACCOUNT_FILE: foo

steps:
- name: Checkout Code Repository
uses: actions/checkout@v4

- name: Set up Python 3.8
uses: actions/setup-python@v5
with:
python-version: 3.8
cache: pip
cache-dependency-path: |
requirements/requirements.txt
requirements/test-requirements.txt
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install pip-tools
pip-sync requirements/requirements.txt requirements/test-requirements.txt
- name: Collect staticfiles
run: python manage.py collectstatic --noinput --settings=config.settings.test

- name: Run tests
run: coverage run -p -m pytest
env:
# We can set this to an empty string, since we'll never make an API call.
ANVIL_API_SERVICE_ACCOUNT_FILE: foo

- name: Upload coverage data
uses: actions/upload-artifact@v4
with:
name: coverage-data-sqlite-${{ strategy.job-index }}
name: coverage-data-${{ strategy.job-index }}
path: .coverage.*

coverage:
needs:
- pytest-mariadb
- pytest-sqlite
- test
runs-on: ubuntu-latest
steps:
- name: Check out the repo
Expand Down
2 changes: 0 additions & 2 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,6 @@

# django-anvil-consortium-manager
# ------------------------------------------------------------------------------
# Specify the path to the service account to use for managing access on AnVIL.
ANVIL_API_SERVICE_ACCOUNT_FILE = env("ANVIL_API_SERVICE_ACCOUNT_FILE")
ANVIL_WORKSPACE_ADAPTERS = [
"gregor_django.gregor_anvil.adapters.ResourceWorkspaceAdapter",
"gregor_django.gregor_anvil.adapters.TemplateWorkspaceAdapter",
Expand Down
2 changes: 2 additions & 0 deletions config/settings/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,5 @@

# Your stuff...
# ------------------------------------------------------------------------------
# Specify the path to the service account to use for managing access on AnVIL.
ANVIL_API_SERVICE_ACCOUNT_FILE = env("ANVIL_API_SERVICE_ACCOUNT_FILE")
2 changes: 2 additions & 0 deletions config/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,5 @@

# Your stuff...
# ------------------------------------------------------------------------------
# Specify the path to the service account to use for managing access on AnVIL.
ANVIL_API_SERVICE_ACCOUNT_FILE = env("ANVIL_API_SERVICE_ACCOUNT_FILE")

0 comments on commit caefe37

Please sign in to comment.