Skip to content

Commit

Permalink
Update test.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
berat-samli authored Mar 17, 2024
1 parent 73ffa5b commit d33ce2d
Showing 1 changed file with 50 additions and 18 deletions.
68 changes: 50 additions & 18 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# test.yml
name: Run Django Tests
name: Django Test and Lint

on:
push:
branches:
branches:
- '**'

jobs:
test-django-app:
test-and-lint:
runs-on: ubuntu-latest

services:
postgres:
image: postgres:latest
Expand All @@ -17,30 +19,60 @@ jobs:
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

strategy:
fail-fast: false
matrix:
python-version: ["3.12"]
python-version: [3.8, 3.9, 3.10]

steps:
- uses: actions/checkout@v3
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3

- 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
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Run Django test
run: |
cd API
export PG_HOST=localhost
export PG_USER=${{ secrets.POSTGRES_USER }}
export PG_PASSWORD=${{ secrets.POSTGRES_PASSWORD }}
export PG_DB=${{ secrets.POSTGRES_DB }}
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
python manage.py test
- 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

0 comments on commit d33ce2d

Please sign in to comment.