forked from graingert/python-clamd
-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (74 loc) · 2.1 KB
/
ci.yml
File metadata and controls
87 lines (74 loc) · 2.1 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
name: CI
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]
services:
clamav:
image: clamav/clamav:stable
ports:
- 3310:3310
env:
CLAMAV_NO_FRESHCLAMD: "true"
CLAMAV_NO_MILTERD: "true"
options: >-
--health-cmd="echo PING | nc localhost 3310 | grep -q PONG"
--health-interval=30s
--health-timeout=30s
--health-retries=30
--health-start-period=300s
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
pip install -e .
- name: Wait for ClamAV to be ready
run: |
echo "Waiting for ClamAV service..."
timeout=600
elapsed=0
while [ $elapsed -lt $timeout ]; do
if echo PING | nc -w 5 localhost 3310 2>/dev/null | grep -q PONG; then
echo "ClamAV is ready after ${elapsed}s!"
exit 0
fi
echo "Waiting... (${elapsed}s elapsed)"
sleep 15
elapsed=$((elapsed + 15))
done
echo "ClamAV failed to start within ${timeout}s"
docker ps -a
docker logs $(docker ps -aq --filter "ancestor=clamav/clamav:stable") || true
exit 1
- name: Run tests
run: |
pytest src/tests/ -v
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install linting tools
run: |
python -m pip install --upgrade pip
pip install ruff
- name: Run linter
run: |
ruff check src/