-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Part of a paired project with the Web repository. Changes on the API side: * Name changed to CI (like Web) * Step names have been brought into line with the Web style (yay emojis!) * black and isort checks now correctly exit with an error code if something isn't right * A new job has been added! fixtures now checks that the example data we ship (that can be locally built with make seed or make seed-testfixtures) can be successfully loaded into the database, meaning we shouldn't run into the issues we did earlier this year where the data was out of date and therefore it was difficult to test a local copy of your API
- Loading branch information
Showing
1 changed file
with
93 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Package checks | ||
name: CI | ||
|
||
on: | ||
push: | ||
|
@@ -27,40 +27,40 @@ jobs: | |
# Maps tcp port 5432 on service container to the host | ||
- 5432:5432 | ||
|
||
|
||
steps: | ||
# Set up cache for pip packages | ||
- uses: actions/cache@v4 | ||
- name: Cache pip packages π¦ | ||
uses: actions/cache@v4 | ||
with: | ||
path: ~/.cache/pip | ||
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | ||
restore-keys: | | ||
${{ runner.os }}-pip- | ||
# Checkout the code | ||
- uses: actions/checkout@v4 | ||
- name: Checkout π | ||
uses: actions/checkout@master | ||
|
||
# Setup python | ||
- name: set up python 3.10 | ||
- name: Setup python 3.10 env π | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.10" | ||
|
||
# Install dependencies | ||
- name: Install dependencies | ||
- name: Install dependencies π¨π»βπ» | ||
run: pip install -r requirements/local.txt | ||
|
||
# Collect static | ||
- name: Collect Static | ||
- name: Collect Static π¦ | ||
run: ./manage.py collectstatic --noinput | ||
|
||
- name: Tests | ||
- name: Run tests π§ͺ | ||
run: | | ||
pytest --cov uobtheatre --cov-fail-under 100 -m "not system_test" | ||
env: | ||
DATABASE_URL: postgresql://postgres:[email protected]:5432/uobtheatre_api | ||
|
||
- name: System tests | ||
- name: Run system tests βπ¬ | ||
if: ${{ github.actor != 'dependabot[bot]' }} | ||
run: | | ||
pytest --cov uobtheatre -m "system_test" | ||
|
@@ -72,76 +72,140 @@ jobs: | |
runs-on: ubuntu-latest | ||
steps: | ||
# Set up cache for pip packages | ||
- uses: actions/cache@v4 | ||
- name: Cache pip packages π¦ | ||
uses: actions/cache@v4 | ||
with: | ||
path: ~/.cache/pip | ||
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | ||
restore-keys: | | ||
${{ runner.os }}-pip- | ||
# Checkout the code | ||
- uses: actions/checkout@v4 | ||
- name: Checkout π | ||
uses: actions/checkout@master | ||
|
||
# Setup python | ||
- name: set up python 3.10 | ||
- name: Setup python 3.10 env π | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.10" | ||
|
||
# Install dependencies | ||
- name: Install dependencies | ||
- name: Install dependencies π¨π»βπ» | ||
run: pip install -r requirements/local.txt | ||
|
||
- name: black - formatting | ||
- name: Run black - formatting | ||
run: | | ||
black uobtheatre | ||
black uobtheatre --check | ||
- name: isort - sort imports | ||
- name: Run isort - sort imports | ||
run: | | ||
isort uobtheatre | ||
isort uobtheatre -c | ||
- name: pylint - linting | ||
- name: Run pylint - linting | ||
run: | | ||
pylint uobtheatre | ||
- name: mypy - static type checking | ||
- name: Run mypy - static type checking | ||
run: | | ||
mypy uobtheatre | ||
# Check migrations have been made | ||
- name: Ensure migrations have been generated | ||
- name: Ensure migrations have been generated π | ||
run: python manage.py makemigrations --check | ||
|
||
fixtures: | ||
runs-on: ubuntu-latest | ||
|
||
services: | ||
db_service: | ||
image: postgres | ||
env: | ||
POSTGRES_USER: postgres | ||
POSTGRES_DB: uobtheatre_api | ||
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 | ||
|
||
steps: | ||
# Set up cache for pip packages | ||
- name: Cache pip packages π¦ | ||
uses: actions/cache@v4 | ||
with: | ||
path: ~/.cache/pip | ||
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | ||
restore-keys: | | ||
${{ runner.os }}-pip- | ||
- name: Checkout π | ||
uses: actions/checkout@master | ||
|
||
# Setup python | ||
- name: Setup python 3.10 env π | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.10" | ||
|
||
# Install dependencies | ||
- name: Install dependencies π¨π»βπ» | ||
run: pip install -r requirements/local.txt | ||
|
||
# Collect static | ||
- name: Collect Static π¦ | ||
run: ./manage.py collectstatic --noinput | ||
|
||
- name: Check example fixture data can still be loaded π | ||
run: | | ||
./manage.py migrate | ||
./manage.py loaddata uobtheatre/images/fixtures.json uobtheatre/addresses/fixtures.json uobtheatre/users/fixtures.json uobtheatre/venues/fixtures.json uobtheatre/societies/fixtures.json uobtheatre/productions/fixtures.json uobtheatre/bookings/fixtures.json | ||
env: | ||
DATABASE_URL: postgresql://postgres:[email protected]:5432/uobtheatre_api | ||
|
||
- name: Check e2e fixture data can still be loaded π | ||
run: | | ||
./manage.py flush --no-input | ||
./manage.py loaddata db.json | ||
env: | ||
DATABASE_URL: postgresql://postgres:[email protected]:5432/uobtheatre_api | ||
|
||
schema: | ||
runs-on: ubuntu-latest | ||
steps: | ||
# Set up cache for pip packages | ||
- uses: actions/cache@v4 | ||
- name: Cache pip packages π¦ | ||
uses: actions/cache@v4 | ||
with: | ||
path: ~/.cache/pip | ||
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | ||
restore-keys: | | ||
${{ runner.os }}-pip- | ||
# Checkout the code | ||
- uses: actions/checkout@v4 | ||
- name: Checkout π | ||
uses: actions/checkout@master | ||
|
||
# Setup python | ||
- name: set up python 3.10 | ||
- name: Setup python 3.10 env π | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.10" | ||
|
||
# Install dependencies | ||
- name: Install dependencies | ||
- name: Install dependencies π¨π»βπ» | ||
run: pip install -r requirements/local.txt | ||
|
||
# Generate schmea | ||
- name: Generate schema | ||
- name: Generate schema π€ | ||
run: | | ||
./manage.py graphql_schema --schema uobtheatre.schema.schema --out schema.graphql | ||
# Push up the schema | ||
- name: Commit schema | ||
- name: Commit schema πΈ | ||
uses: EndBug/add-and-commit@v9 | ||
with: | ||
message: 'Updated schema' | ||
|