Skip to content

Commit

Permalink
ci: speed up Django tests using cache and running them only once
Browse files Browse the repository at this point in the history
Use the github cache to cache the poetry virtualenv.
The tests were run both at pull request and pushes - given that we
don't allow merges to main without pull request, lets see if its enough
to run them only on PRs.
  • Loading branch information
b1rger committed Nov 23, 2023
1 parent 14d87d6 commit e46c29a
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions .github/workflows/django-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

name: Django Test

on: [push, pull_request]
on:
pull_request:

env:
DJANGO_SETTINGS_MODULE: tests.settings_ci
Expand All @@ -20,16 +21,30 @@ jobs:
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies

- name: Upgrade pip
run: |
python -m pip install --upgrade pip
pip install poetry
poetry config virtualenvs.create false
- name: Install poetry and setuptools
run: |
pip install poetry setuptools
- name: Configure poetry
run: |
poetry config virtualenvs.in-project true
- name: Cache the virtualenv
uses: actions/cache@v2
with:
path: ./.venv
key: ${{ runner.os }}-venv-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
run: |
poetry lock
poetry install
- name: Make migrations
run: ./manage.py makemigrations
run: poetry run ./manage.py makemigrations
- name: Migrate
run: ./manage.py migrate
run: poetry run ./manage.py migrate
- name: Test
run: ./manage.py test
run: poetry run ./manage.py test

0 comments on commit e46c29a

Please sign in to comment.