Update test.yml #18
Workflow file for this run
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: Django Test and Lint | |
on: | |
push: | |
branches: | |
- '**' | |
jobs: | |
test-and-lint: | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres:latest | |
env: | |
POSTGRES_USER: ${{ secrets.POSTGRES_USER }} | |
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }} | |
POSTGRES_DB: ${{ secrets.POSTGRES_DB }} | |
ports: | |
- 5432:5432 | |
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | |
strategy: | |
matrix: | |
python-version: [3.8, 3.9, 3.10] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
pip install coverage | |
- name: Lint with flake8 | |
run: | | |
pip install flake8 | |
flake8 . | |
- name: Format code with black | |
run: | | |
pip install black | |
black . | |
- name: Sort imports with isort | |
run: | | |
pip install isort | |
isort . | |
- name: Run Django migrations | |
run: | | |
python manage.py makemigrations | |
python manage.py migrate | |
- name: Run tests with coverage | |
run: | | |
coverage run --source='.' manage.py test | |
coverage report -m | |
- name: Check security with bandit | |
run: | | |
pip install bandit | |
bandit -r . | |
- name: Upload coverage report | |
uses: actions/upload-artifact@v2 | |
with: | |
name: coverage-report | |
path: coverage.xml |