Skip to content

fix: add lfs workaround #1

fix: add lfs workaround

fix: add lfs workaround #1

name: Lint and check a Django app
on:
workflow_call:
inputs:
LABELS:
required: true
type: string
WORKING_DIRECTORY:
required: true
type: string
PYTHON_IMAGE:
required: true
type: string
RUN:
required: false
type: boolean
default: true
DJANGO_MIGRATIONS_CHECK_APPS:
required: false
type: string
default: ""
SETUP_COMMANDS:
required: false
type: string
default: ""
ENABLE_LFS:
required: false
type: boolean
default: false
env: "${{secrets}}"
jobs:
django-linter:
if: ${{ inputs.RUN }}
runs-on: ${{ fromJson(inputs.LABELS) }}
container: ${{ inputs.PYTHON_IMAGE }}
defaults:
run:
working-directory: ${{ inputs.WORKING_DIRECTORY }}
services:
postgres:
image: postgres
env:
POSTGRES_USER: django-runner
POSTGRES_PASSWORD: django-runner
POSTGRES_DB: django
redis:
image: redis
steps:
- name: Install prerequisites
if: ${{ inputs.ENABLE_LFS == 'true' }}
run: apt-get update && apt-get install -y git-lfs
- name: Checkout code
uses: actions/checkout@v3
if: ${{ inputs.ENABLE_LFS == 'true' }}
with:
lfs: 'true'
run: git config --global --add safe.directory /__w/mobygis-waterjade/mobygis-waterjade
- name: Checkout LFS objects
if: ${{ inputs.ENABLE_LFS == 'true' }}
run: git lfs pull
- name: Setup
run: ${{ inputs.SETUP_COMMANDS }}
- name: Install dependencies
run: pip install -r requirements.txt
- name: Copy env file
run: cp .env.github .env
- name: Lint with flake8
run: python -m flake8 .
- name: Lint with black
run: python -m black --check .
- name: Django check
run: python manage.py check
- name: Django validate templates
run: python manage.py validate_templates
- name: Django check migrations
run: python manage.py makemigrations ${{ inputs.DJANGO_MIGRATIONS_CHECK_APPS }} --check --dry-run
- name: Django validate migration
run: python manage.py migrate --noinput