Skip to content

fix: add lfs workaround #1

fix: add lfs workaround

fix: add lfs workaround #1

name: Run Django tests
on:
workflow_call:
inputs:
LABELS:
required: true
type: string
WORKING_DIRECTORY:
required: true
type: string
PYTHON_IMAGE:
required: true
type: string
COVERAGE_ARTIFACT_NAME:
required: true
type: string
RUN:
required: false
type: boolean
default: true
SETUP_COMMANDS:
required: false
type: string
default: ""
ENABLE_LFS:
required: false
type: boolean
default: false
env: "${{secrets}}"
jobs:
django-tests:
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
- 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: Migrate django DB
run: python manage.py migrate
- name: Run django tests
run: |
coverage erase
coverage run --source='.' manage.py test --noinput
coverage xml -i -o coverage-reports/coverage-django.xml
coverage report --fail-under 50
- name: Archive code coverage results
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.COVERAGE_ARTIFACT_NAME }}
path: ${{ inputs.WORKING_DIRECTORY }}/coverage-reports/coverage-django.xml
retention-days: 1