Merge pull request #3 from fivehanz/release-please--branches--main--c… #20
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
name: Django CI | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
services: | |
postgres: # we need a postgres docker image to be booted a side car service to run the tests that needs a db | |
image: postgres | |
env: # the environment variable must match with app/settings.py if block of DATBASES variable otherwise test will fail due to connectivity issue. | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
POSTGRES_DB: github-actions | |
ports: | |
- 5432:5432 # exposing 5432 port for application to use | |
# needed because the postgres container does not provide a healthcheck | |
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | |
strategy: | |
max-parallel: 4 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v3 | |
with: | |
python-version: '3.11' | |
- name: Install Dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install pipenv | |
make install | |
- name: Run Migrations # run migrations to create table in side car db container | |
run: | | |
pipenv run make migrate | |
- name: Run Tests | |
run: | | |
pipenv run python manage.py test |