DEV Community

Darshit Jain
Darshit Jain

Posted on • Edited on

Django Tests

Alt Text

My Workflow

My workflow checks for any linting errors or any changes that breaks the code and doesn't pass the tests on every new pull request or push to the repository! This makes sure that nothing is added to the repository that breaks the workflow. This helps in maintaining the quality of the code base.

Submission Category:

Maintainer Must-Haves

Yaml File

name: Django Tests

on: [push, pull_request]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v1
    - name: Set up Python 3.6
      uses: actions/setup-python@v1
      with:
        python-version: 3.6
    - name: Setup environment variables
      run: |
        cp .env.example .env
        export DJANGO_SETTINGS_MODULE=main.settings
    - name: Install dependencies
      run: |
        sudo apt-get install libpq-dev 
        pip3 install -r requirements.txt

    - name: Linting
      working-directory: ./src
      run: |
        flake8 .
    - name: Migrations
      working-directory: ./src
      run: |
        python3 manage.py makemigrations
        python3 manage.py migrate
    - name: Coverage
      working-directory: ./src
      run: |
        pip3 install coverage
        coverage run --source='.' manage.py test
        bash <(curl -s https://codecov.io/bash) || echo 'Codecov failed to upload'
Enter fullscreen mode Exit fullscreen mode

Top comments (0)