-
Notifications
You must be signed in to change notification settings - Fork 181
69 lines (63 loc) · 2.35 KB
/
unit-test-ciso-assistant.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
name: Unit tests on CISO Assistant
on:
push:
pull_request:
branches: [develop, main]
env:
GITHUB_WORKFLOW: github_actions
jobs:
build:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:14.1
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
POSTGRES_DB: postgres
ports: ["5432:5432"]
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
strategy:
max-parallel: 4
matrix:
python-version: ["3.11"]
steps:
- uses: actions/checkout@v3
- name: Set up python ${{ matrix.python-version }}
uses: actions/setup-python@v4
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: Create environment variables file
run: |
touch .env
echo DJANGO_SECRET_KEY=${{ secrets.DJANGO_SECRET_KEY }} >> .env
echo POSTGRES_NAME=postgres >> .env
echo POSTGRES_USER=postgres >> .env
echo POSTGRES_PASSWORD=${{ secrets.POSTGRES_PASSWORD }} >> .env
echo DB_HOST=localhost >> .env
echo EMAIL_HOST=localhost >> .env
echo EMAIL_PORT=1025 >> .env
echo EMAIL_HOST_USER='' >> .env
echo EMAIL_HOST_PASSWORD='' >> .env
echo DJANGO_SETTINGS_MODULE=ciso_assistant.settings >> .env
#echo EMAIL_USE_TLS=False >> .env
echo CISO_URL=http://127.0.0.1:8000 >> .env
echo DEFAULT_FROM_EMAIL='[email protected]' >> .env
echo CISO_SUPERUSER_EMAIL='' >> .env
echo RECAPTCHA_PUBLIC_KEY=MyRecaptchaKey123 >> .env
echo RECAPTCHA_PRIVATE_KEY=MyRecaptchaPrivateKey456 >> .env
- name: Run migrations
run: |
export $(grep -v '^#' .env | xargs)
python manage.py makemigrations
python manage.py migrate
- name: Run tests
env:
DATABASE_URL: "postgres://postgres:postgres@localhost:${{ job.services.postgres.ports[5432] }}/postgres"
run: |
export $(grep -v '^#' .env | xargs)
find . -path '*/tests/*' -and -name 'test*.py' -and -not -path "./venv/*" | xargs pytest