-
Notifications
You must be signed in to change notification settings - Fork 0
91 lines (78 loc) · 2.67 KB
/
django.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
name: Django CI
on:
push:
branches: [ develop ]
pull_request:
branches: [ develop ]
jobs:
build:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:12
env:
POSTGRES_DB: test_db_name
POSTGRES_USER: test_db_user
POSTGRES_PASSWORD: test_db_password
DJANGO_SECRET_KEY: ${{ secrets.DJANGO_SECRET_KEY }}
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.11
uses: actions/setup-python@v2
with:
python-version: 3.11
- name: Install dependencies
run: |
pip install pipenv
pipenv install --dev
- name: Run migrations
run: |
pipenv run python manage.py migrate
env:
DJANGO_SECRET_KEY: ${{ secrets.DJANGO_SECRET_KEY }}
DATABASE_NAME: ${{ secrets.TEST_DATABASE_NAME }}
DATABASE_USER: ${{ secrets.TEST_DATABASE_USER }}
DATABASE_PASSWORD: ${{ secrets.TEST_DATABASE_PASSWORD }}
DATABASE_HOST: ${{ secrets.TEST_DATABASE_HOST }}
DATABASE_PORT: ${{ secrets.TEST_DATABASE_PORT }}
- name: Run tests
run: |
pipenv run python manage.py test
env:
DJANGO_SECRET_KEY: ${{ secrets.DJANGO_SECRET_KEY }}
DATABASE_NAME: ${{ secrets.TEST_DATABASE_NAME }}
DATABASE_USER: ${{ secrets.TEST_DATABASE_USER }}
DATABASE_PASSWORD: ${{ secrets.TEST_DATABASE_PASSWORD }}
DATABASE_HOST: ${{ secrets.TEST_DATABASE_HOST }}
DATABASE_PORT: ${{ secrets.TEST_DATABASE_PORT }}
- name: Install PostgreSQL client
run: |
sudo apt-get install postgresql-client
- name: Check PostgreSQL service
run: |
pg_isready -h localhost -p 5432 -U test_db_user
- name: Run tests with coverage
run: |
pipenv run coverage run --source='.' manage.py test
pipenv run coverage xml -o coverage.xml
env:
DJANGO_SECRET_KEY: ${{ secrets.DJANGO_SECRET_KEY }}
DATABASE_NAME: ${{ secrets.TEST_DATABASE_NAME }}
DATABASE_USER: ${{ secrets.TEST_DATABASE_USER }}
DATABASE_PASSWORD: ${{ secrets.TEST_DATABASE_PASSWORD }}
DATABASE_HOST: ${{ secrets.TEST_DATABASE_HOST }}
DATABASE_PORT: ${{ secrets.TEST_DATABASE_PORT }}
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
with:
projectBaseDir: .
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_CLOUD_TOKEN }}