.flake8 config #112
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 Pipeline | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
jobs: | |
flake8: | |
name: Static Analysis - flake8 | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./backend | |
steps: | |
- uses: actions/checkout@v3 | |
# Cache pipenv dependencies (pip cache and virtualenvs) | |
- name: Cache pipenv dependencies | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cache/pip | |
~/.local/share/virtualenvs | |
key: ${{ runner.os }}-pipenv-${{ hashFiles('backend/Pipfile.lock') }} | |
restore-keys: | | |
${{ runner.os }}-pipenv- | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.11" | |
- name: Install dependencies | |
run: | | |
pip install pipenv | |
pipenv lock -d | |
pipenv sync | |
- name: Run flake8 | |
run: pipenv run python3 -m flake8 --verbose . | |
tests: | |
name: Run Django Tests | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./backend | |
services: | |
postgres: | |
image: postgres:16.2 | |
env: | |
POSTGRES_DB: "cradledb" | |
POSTGRES_USER: "postgres" | |
POSTGRES_PASSWORD: "postgres" | |
ports: | |
- 5432:5432 | |
options: >- | |
--health-cmd "pg_isready -U postgres" | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
redis: | |
image: redis:7.2 | |
ports: | |
- 6379:6379 | |
options: >- | |
--health-cmd "redis-cli ping" | |
--health-interval 5s | |
--health-timeout 5s | |
--health-retries 3 | |
steps: | |
- uses: actions/checkout@v3 | |
# Cache pipenv dependencies (reuse the same caching step) | |
- name: Cache pipenv dependencies | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cache/pip | |
~/.local/share/virtualenvs | |
key: ${{ runner.os }}-pipenv-${{ hashFiles('backend/Pipfile.lock') }} | |
restore-keys: | | |
${{ runner.os }}-pipenv- | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.11" | |
- name: Install dependencies | |
run: | | |
pip install pipenv | |
pipenv lock -d | |
pipenv sync | |
- name: Settings Copy | |
run: cp cradle/settings_test.py cradle/settings.py | |
- name: Apply Migrations | |
run: | | |
pipenv run python3 manage.py migrate | |
pipenv run python3 manage.py check | |
- name: Run Tests with Coverage | |
run: | | |
pipenv run coverage run manage.py test | |
pipenv run coverage report |