-1

Trying to implement flake8 inside a workflow in github is causing me error because is not recognising .flake8 file.

It works perfectly from the terminal:

[flake8]
max-line-length = 79
exclude = 
    migrations
    views.py
    tests.py
    serializers.py
    models.py

When I try to apply it to the .yml file of Django it's giving error because doesn't take in account the config file:

name: Django CI

on:
  push:
    branches: [ "dev" ]
  pull_request:
    branches: [ "dev" ]

jobs:
  build:

    runs-on: ubuntu-latest
    strategy:
      max-parallel: 4
      matrix:
        python-version: [3.8, 3.9]

    steps:
    - uses: actions/checkout@v3
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v3
      with:
        python-version: ${{ matrix.python-version }}
    - name: Install Dependencies
      run: |
        cd scoretize_backend/
        python -m pip install --upgrade pip
        pip install -r requirements.txt
    - name: Lint with Flake8
      run: flake8 scoretize_backend/
    - name: Run Tests
      run: |
        cd scoretize_backend/
        python manage.py test

I've tried to add a new workflow just for this but same case:

name: flake8 Lint

on: [push, pull_request]

jobs:
  flake8-lint:
    runs-on: ubuntu-latest
    name: Lint
    steps:
      - name: Check out source repository
        uses: actions/checkout@v2
      - name: Set up Python environment
        uses: actions/setup-python@v2
        with:
          python-version: "3.9"
          exclude: "./scoretize_backend/api/models.py"
      - name: flake8 Lint
        uses: py-actions/flake8@v2

Tried to add with & exclude but it's not working. Could I config this with the .flake8 file? Thank you so much.

anthony sottile
  • 61,815
  • 15
  • 148
  • 207
9Shuck
  • 1
  • 1

1 Answers1

0

Thank you Anthony! I had the file inside the Django app but the workflow needed the file on the top of the directories. Solved.

9Shuck
  • 1
  • 1