-
Notifications
You must be signed in to change notification settings - Fork 0
117 lines (97 loc) · 3.21 KB
/
Copy pathci.yml
File metadata and controls
117 lines (97 loc) · 3.21 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
name: test (py${{ matrix.python-version }}, pydantic${{ matrix.pydantic-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12", "3.13"]
pydantic-version: ["~=2.0.0", "~=2.10.0"]
exclude:
- python-version: "3.13"
pydantic-version: "~=2.0.0"
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
- name: Install deps
run: uv sync --all-extras --python ${{ matrix.python-version }}
- name: Pin pydantic version
run: uv pip install "pydantic${{ matrix.pydantic-version }}"
- name: Lint
run: uv run ruff check .
- name: Type-check
run: uv run pyright
- name: Unit tests
run: uv run pytest tests/unit tests/contract -q -m unit
- name: Coverage
if: matrix.python-version == '3.13' && matrix.pydantic-version == '~=2.10.0'
run: |
uv run coverage run -m pytest tests/unit tests/contract -q -m unit
uv run coverage report -m --fail-under=95
integration:
name: integration tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
- name: Set up Python
run: uv python install 3.13
- name: Install deps
run: uv sync --all-extras --python 3.13
- name: Start Snipe-IT stack
run: |
rm -rf docker/api_key.txt
touch docker/api_key.txt
cd docker && docker compose up -d
- name: Wait for API key
run: |
echo "Waiting for docker/api_key.txt (up to ~120s)..."
for i in $(seq 1 120); do
if [ -s docker/api_key.txt ]; then break; fi
sleep 1
done
if [ ! -s docker/api_key.txt ]; then
echo "Timed out waiting for docker/api_key.txt"
cd docker && docker compose logs seeder
exit 1
fi
- name: Wait for API readiness
run: |
TOKEN=$(cat docker/api_key.txt)
echo "Waiting for Snipe-IT API (up to ~120s)..."
for i in $(seq 1 120); do
code=$(curl -s -o /dev/null -w "%{http_code}" -m 5 \
-H "Authorization: Bearer $TOKEN" \
-H "Accept: application/json" \
http://localhost:8000/api/v1/users/me 2>/dev/null || echo "000")
if [ "$code" = "200" ]; then
echo "API is ready"
break
fi
sleep 1
done
if [ "$code" != "200" ]; then
echo "Timed out. Last status: $code"
cd docker && docker compose logs app
exit 1
fi
- name: Integration tests
run: uv run pytest tests/integration -q -m integration