[#163] Update User and Food Request Models, Serializers, and Views #1
Workflow file for this run
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
# This is a matrix GitHub Action workflow for running CI tests on a Django | |
# project. | |
# | |
# Based on https://github.com/snok/install-poetry?tab=readme-ov-file | |
# | |
# See: | |
# https://docs.github.com/en/actions/guides/building-and-testing-python#building-and-testing-python-with-multiple-versions | |
# https://devguide.python.org/versions/ | |
# | |
name: API - Tests | |
on: | |
# Trigger the workflow during API PRs and when this file changes | |
pull_request: | |
paths: | |
- apps/api/** | |
- .github/workflows/api.yml | |
# Allow running the workflow manually | |
workflow_dispatch: | |
inputs: | |
debug_enabled: | |
type: boolean | |
description: Enable tmate debugging (see mxschmitt/action-tmate@v3) | |
required: false | |
default: false | |
jobs: | |
install-and-cache: | |
strategy: | |
fail-fast: true | |
max-parallel: 4 | |
matrix: | |
os: [ ubuntu-latest ] # ubuntu-latest, macos-latest | |
python-version: [ "3.11" ] # "3.10", "3.11", "3.12" or simply ">=3.9,<4.0" | |
django-version: [ "5" ] # "4", "5" | |
runs-on: ${{ matrix.os }} | |
# Service containers to run with `build` job | |
services: | |
# Label used to access the service container which is | |
# running a postgres image from Docker Hub. | |
postgres: | |
image: postgres:16.2-bookworm | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: bronco | |
POSTGRES_DB: postgres | |
ports: | |
- 5432:5432 | |
# Set health checks to wait until postgres has started | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
env: | |
DB_NAME: postgres | |
DB_USER: postgres | |
DB_HOST: postgres | |
DB_PASSWORD: bronco | |
DB_PORT: 5432 | |
DB_ENGINE: django.db.backends.postgresql | |
# All steps should run in the Django app | |
# subdirectory by default. | |
defaults: | |
run: | |
working-directory: ./apps/api | |
steps: | |
#---------------------------------------------- | |
# check-out repo and set-up python | |
#---------------------------------------------- | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
submodules: true | |
- name: Set up python ${{ matrix.python-version }} | |
id: setup-python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Debug | |
run: env | sort | |
#---------------------------------------------- | |
# ----- install & configure poetry ----- | |
#---------------------------------------------- | |
- name: Install Poetry | |
uses: snok/[email protected] | |
with: | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
# Enable tmate debugging of manually-triggered workflows if the input option was provided | |
- name: Setup tmate session | |
uses: mxschmitt/action-tmate@v3 | |
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }} | |
#---------------------------------------------- | |
# load cached venv if cache exists | |
#---------------------------------------------- | |
- name: Load cached venv | |
id: cached-poetry-dependencies | |
uses: actions/cache@v3 | |
with: | |
path: .venv | |
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} | |
#---------------------------------------------- | |
# install dependencies if cache does not exist | |
#---------------------------------------------- | |
- name: Install dependencies | |
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' | |
run: poetry install --no-interaction --no-root | |
#---------------------------------------------- | |
# install your root project, if required | |
#---------------------------------------------- | |
- name: Install library | |
run: poetry install --no-interaction | |
#---------------------------------------------- | |
# add matrix specifics and run test suite | |
#---------------------------------------------- | |
- name: Install django ${{ matrix.django-version }} | |
run: | | |
poetry add Django@${{ matrix.django-version }} | |
#-------------------------------------------- | |
# run tests | |
#-------------------------------------------- | |
- name: Run tests | |
run: | | |
# Install the default environment settings. This includes | |
# the database config for the CI environment (sqlite3). | |
cp -p .env.example .env | |
poetry run pytest |