Repository navigation
103 lines (86 loc) · 3.26 KB
/
Copy pathpython-app.yml
File metadata and controls
103 lines (86 loc) · 3.26 KB
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
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Python application
on:
push:
branches: [ "main", "development"]
pull_request:
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up uv (Python 3.12)
uses: astral-sh/setup-uv@v6.6.0
with:
python-version: "3.12"
activate-environment: true
enable-cache: true
- uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.ref }}
- name: Set timezone
run: sudo timedatectl set-timezone Europe/Vienna
- name: Run pre-commit with prek
run: uv run --dev prek run -a
- name: Start Containers
run: docker compose -f tests/test_schemas/compose.yaml up -d
- name: Wait for MongoDB
run: |
for attempt in {1..30}; do
if docker compose -f tests/test_schemas/compose.yaml exec -T mongo \
mongosh --quiet --eval 'db.adminCommand("ping")' >/dev/null 2>&1; then
exit 0
fi
sleep 1
done
docker compose -f tests/test_schemas/compose.yaml logs mongo
exit 1
- name: Wait for Redis
run: |
for attempt in {1..30}; do
if [ "$(docker compose -f tests/test_schemas/compose.yaml exec -T redis redis-cli ping 2>/dev/null)" = "PONG" ]; then
echo "Redis is ready"
exit 0
fi
sleep 1
done
docker compose -f tests/test_schemas/compose.yaml logs redis
exit 1
- name: Test with pytest
run: uv run pytest -s --run-ignored --run-ignored-mongo --run-ignored-redis
- name: Stop Containers
if: always()
run: docker compose -f tests/test_schemas/compose.yaml down
- name: Commit and Push Changes
env:
PR_BRANCH: ${{ github.event.pull_request.head.ref }}
run: |
git add .
if git diff --cached --quiet; then
echo "No tracked files changed"
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git commit -m "Automated documentation update"
git push origin "HEAD:$PR_BRANCH"
# integration tests for DetectMateService
- name: Checkout DetectMateService
uses: actions/checkout@v4
with:
repository: ait-detectmate/DetectMateService
path: DetectMateService
- name: Prepare DetectMateService (using local DetectMateLibrary)
working-directory: DetectMateService
run: |
# remove the git-based dependency so we don't override the local lib
sed -i '/detectmatelibrary @ git+/d' pyproject.toml
- name: Prepare packages
working-directory: DetectMateService
run: uv pip install .
#- name: Run DetectMateService library integration tests
# working-directory: DetectMateService
# run: uv run --dev pytest tests/library_integration -s