-
-
Notifications
You must be signed in to change notification settings - Fork 7
146 lines (126 loc) · 4.42 KB
/
test.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
---
name: Test
on:
push:
branches: [latest]
paths:
- '**.py'
- '.github/workflows/test.yml'
- 'requirements_test.txt'
pull_request:
branches: [latest]
paths:
- '**.py'
- '**.yml'
- '.github/workflows/test.yml'
- 'requirements_test.txt'
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 3
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.ref }}
- name: Install python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
pip install -r requirements_test.txt >/dev/null
pip install -r requirements_build.txt >/dev/null
pip install -r requirements.txt >/dev/null
- name: Testing DB migrations for errors (1/3)
run: |
export AW_DB="/tmp/$(date +%s).e1.aw.db"
rm -rf src/ansibleguy-webui/aw/migrations/*
python3 manage.py makemigrations
working-directory: src/ansibleguy-webui/
- name: Testing DB migrations for warnings (1/3)
run: |
export AW_DB="/tmp/$(date +%s).w1.aw.db"
rm -rf src/ansibleguy-webui/aw/migrations/*
m1=$(python3 manage.py makemigrations 2>&1)
if echo "$m1" | grep -q 'WARNING'; then exit 1;fi
working-directory: src/ansibleguy-webui/
- name: Testing DB migrations for errors (2/3)
run: |
export AW_DB="/tmp/$(date +%s).e2.aw.db"
rm -rf src/ansibleguy-webui/aw/migrations/*
python3 manage.py makemigrations aw
working-directory: src/ansibleguy-webui/
- name: Testing DB migrations for warnings (2/3)
run: |
export AW_DB="/tmp/$(date +%s).w2.aw.db"
rm -rf src/ansibleguy-webui/aw/migrations/*
m2=$(python3 manage.py migrate aw 2>&1)
if echo "$m2" | grep -q 'WARNING'; then exit 1;fi
working-directory: src/ansibleguy-webui/
- name: Testing DB migrations for errors (3/3)
run: |
export AW_DB="/tmp/$(date +%s).e3.aw.db"
rm -rf src/ansibleguy-webui/aw/migrations/*
python3 manage.py migrate
working-directory: src/ansibleguy-webui/
- name: Testing DB migrations for warnings (3/3)
run: |
export AW_DB="/tmp/$(date +%s).w3.aw.db"
rm -rf src/ansibleguy-webui/aw/migrations/*
m3=$(python3 manage.py migrate 2>&1)
if echo "$m3" | grep -q 'WARNING'; then exit 1;fi
working-directory: src/ansibleguy-webui/
- name: Testing to start Ansible-WebUI
run: |
set +e
export AW_DB="/tmp/$(date +%s).aw.db"
rm -rf src/ansibleguy-webui/aw/migrations/*
timeout 10 python3 src/ansibleguy-webui
ec="$?"
if [[ "$ec" != "124" ]]
then
exit 1
fi
- name: Running Unit Tests
run: |
pytest --version
python3 -m pytest
- name: Running Integration Tests
run: |
export AW_ENV='dev'
export AW_DB="/tmp/$(date +%s).aw.db"
export AW_ADMIN='tester'
export AW_ADMIN_PWD='someSecret!Pwd'
rm -rf src/ansibleguy-webui/aw/migrations/*
python3 src/ansibleguy-webui/ >/dev/null 2>/dev/null &
sleep 5
echo 'WEB-UI INTEGRATION TESTS'
python3 test/integration/webui/main.py
sleep 1
echo 'API INTEGRATION TESTS'
echo 'Create API key'
api_key="$(python3 src/ansibleguy-webui/cli.py -a api-key.create -p "$AW_ADMIN" | grep 'Key=' | cut -d '=' -f2)"
export AW_API_KEY="$api_key"
sleep 1
python3 test/integration/api/main.py
sleep 1
pkill -f 'ansibleguy-webui'
- name: Running Integration Tests - AUTH SAML
run: |
sleep 5
export AW_ENV='dev'
export AW_DB="/tmp/$(date +%s).aw.db"
export AW_ADMIN='tester'
export AW_ADMIN_PWD='someSecret!Pwd'
export AW_CONFIG="$(pwd)/test/integration/auth/saml.yml"
rm -rf src/ansibleguy-webui/aw/migrations/*
python3 src/ansibleguy-webui/ >/dev/null 2>/dev/null &
sleep 5
echo 'WEB-UI AUTH-SAML INTEGRATION TESTS'
python3 test/integration/auth/saml.py
sleep 1
pkill -f 'ansibleguy-webui'