Merge pull request #280 from PyGotham/dependabot-pip-flake8-bugbear-2… #771
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: CI | |
on: | |
# Run the worflow for all pull requests. | |
pull_request: | |
# Only run the workflow for pushes to the default branch. | |
push: | |
branches: | |
- main | |
# Allow the workflow to be triggered manually from the Actions tab. | |
workflow_dispatch: | |
jobs: | |
# Run style checks. | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.11 | |
- uses: pre-commit/action@v3.0.0 | |
env: | |
SKIP: no-commit-to-branch | |
migrations: | |
runs-on: ubuntu-latest | |
services: | |
db: | |
image: postgres:14.0 | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
POSTGRES_DB: postgres | |
ports: | |
- 5432:5432 | |
# This is needed because the postgres container does not provide a | |
# healthcheck. | |
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.11 | |
- name: Set up Poetry | |
shell: bash | |
run: pip install poetry | |
- name: Set up cache | |
uses: actions/cache@v3 | |
id: poetry-cache | |
with: | |
path: .venv | |
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }} | |
restore-keys: | | |
${{ runner.os }}-poetry- | |
- name: Install dependencies | |
shell: bash | |
run: poetry install | |
- name: Run migrations | |
shell: bash | |
env: | |
DATABASE_HOST: localhost | |
DATABASE_NAME: postgres | |
DATABASE_PASSWORD: postgres | |
DATABASE_PORT: 5432 | |
DATABASE_USER: postgres | |
run: | | |
poetry run tox -e migrate | |
# Reverse all of the migrations. This must be done app by app. | |
poetry run tox -e migrate accounts zero | |
# Apply the migrations again just to make sure we cleaned up | |
# after ourselves properly. | |
poetry run tox -e migrate | |
# Run the test suite and type checks. | |
tox: | |
name: ${{ matrix.toxenv }} | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
toxenv: | |
- types | |
- unit | |
services: | |
db: | |
image: postgres:14.0 | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
POSTGRES_DB: postgres | |
ports: | |
- 5432:5432 | |
# This is needed because the postgres container does not provide a | |
# healthcheck. | |
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.11 | |
- name: Set up Poetry | |
shell: bash | |
run: pip install poetry | |
- name: Set up cache | |
uses: actions/cache@v3 | |
id: poetry-cache | |
with: | |
path: .venv | |
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }} | |
restore-keys: | | |
${{ runner.os }}-poetry- | |
- name: Install dependencies | |
shell: bash | |
run: poetry install | |
- name: Run ${{ matrix.toxenv }} | |
shell: bash | |
env: | |
DATABASE_HOST: localhost | |
DATABASE_NAME: postgres | |
DATABASE_PASSWORD: postgres | |
DATABASE_PORT: 5432 | |
DATABASE_USER: postgres | |
run: poetry run tox -e ${{ matrix.toxenv }} |