-
-
Notifications
You must be signed in to change notification settings - Fork 30
executable file
·76 lines (64 loc) · 1.95 KB
/
pytest.yaml
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
name: pytest
on:
pull_request:
branches:
- main
push:
branches:
- main
schedule:
- cron: '0 0 * * *'
jobs:
pytest:
name: pytest
runs-on: ubuntu-latest
services:
babybuddy:
image: linuxserver/babybuddy
ports:
- 8000:8000
options: >- # Set health checks to wait until babybuddy has started
--health-cmd "curl --fail http://localhost:8000"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Retrieve API Key
run: |
# Retrieve CSRF token
csrf_token=$(curl -s -c cookies.txt 'http://localhost:8000/login/' | grep -oP 'name="csrfmiddlewaretoken" value="\K[^"]+')
if [ -z "$csrf_token" ]; then
echo "Failed to retrieve CSRF Token."
exit 1
fi
# Login and get session
login_response=$(curl -s 'http://localhost:8000/login/' \
-b cookies.txt \
-c cookies.txt \
--data-raw "csrfmiddlewaretoken=${csrf_token}&username=admin&password=admin&login=")
# Retrieve API key
api_key=$(curl -s 'http://localhost:8000/api/profile' \
-b cookies.txt \
| jq -r '.api_key')
if [ -z "$api_key" ]; then
echo "Failed to retrieve API Key."
exit 1
fi
# Set API key in GitHub environment
echo "api_key=$api_key" >> $GITHUB_ENV
- name: Checkout the repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
cache: pip
- name: Install requirements
run: python3 -m pip install -r requirements-test.txt
- name: Run tests
env:
BABY_BUDDY_HOST: http://localhost
BABY_BUDDY_PORT: 8000
API_KEY: ${{ env.api_key }}
run: |
pytest --verbose --maxfail=1