Skip to content

Commit dacf4ac

Browse files
ci: add MySQL/MinIO services to GitHub Actions workflow
- Use MySQL service container for integration tests - Start MinIO manually (requires server command) - Set environment variables for external container mode - Add separate unit-tests job for faster feedback - Test against Python 3.10-3.13 matrix Addresses #1272 Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent cabdb74 commit dacf4ac

File tree

1 file changed

+85
-17
lines changed

1 file changed

+85
-17
lines changed

.github/workflows/test.yaml

Lines changed: 85 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,105 @@
11
name: Test
2+
23
on:
34
push:
45
branches:
5-
- "**" # every branch
6-
- "!gh-pages" # exclude gh-pages branch
7-
- "!stage*" # exclude branches beginning with stage
6+
- "**"
7+
- "!gh-pages"
8+
- "!stage*"
89
paths:
9-
- "src/datajoint"
10-
- "tests"
10+
- "src/datajoint/**"
11+
- "tests/**"
12+
- "pyproject.toml"
13+
- ".github/workflows/test.yaml"
1114
pull_request:
1215
branches:
13-
- "**" # every branch
14-
- "!gh-pages" # exclude gh-pages branch
15-
- "!stage*" # exclude branches beginning with stage
16+
- "**"
17+
- "!gh-pages"
18+
- "!stage*"
1619
paths:
17-
- "src/datajoint"
18-
- "tests"
20+
- "src/datajoint/**"
21+
- "tests/**"
22+
- "pyproject.toml"
23+
- ".github/workflows/test.yaml"
24+
1925
jobs:
2026
test:
2127
runs-on: ubuntu-latest
2228
strategy:
29+
fail-fast: false
2330
matrix:
2431
py_ver: ["3.10", "3.11", "3.12", "3.13"]
2532
mysql_ver: ["8.0"]
33+
34+
services:
35+
mysql:
36+
image: mysql:${{ matrix.mysql_ver }}
37+
env:
38+
MYSQL_ROOT_PASSWORD: password
39+
ports:
40+
- 3306:3306
41+
options: >-
42+
--health-cmd="mysqladmin ping -h localhost"
43+
--health-interval=10s
44+
--health-timeout=5s
45+
--health-retries=5
46+
2647
steps:
2748
- uses: actions/checkout@v4
28-
- name: Set up Python ${{matrix.py_ver}}
49+
50+
- name: Start MinIO
51+
run: |
52+
docker run -d --name minio \
53+
-p 9000:9000 \
54+
-e MINIO_ROOT_USER=datajoint \
55+
-e MINIO_ROOT_PASSWORD=datajoint \
56+
minio/minio:latest server /data
57+
# Wait for MinIO to be ready
58+
for i in {1..30}; do
59+
if curl -sf http://127.0.0.1:9000/minio/health/live; then
60+
echo "MinIO is ready"
61+
break
62+
fi
63+
echo "Waiting for MinIO... ($i/30)"
64+
sleep 2
65+
done
66+
67+
- name: Set up Python ${{ matrix.py_ver }}
2968
uses: actions/setup-python@v5
3069
with:
31-
python-version: ${{matrix.py_ver}}
32-
- name: Integration test
70+
python-version: ${{ matrix.py_ver }}
71+
72+
- name: Install dependencies
73+
run: pip install -e ".[test]"
74+
75+
- name: Run tests
3376
env:
34-
MYSQL_VER: ${{matrix.mysql_ver}}
35-
run: |
36-
pip install -e ".[test]"
37-
pytest --cov-report term-missing --cov=datajoint tests
77+
DJ_USE_EXTERNAL_CONTAINERS: "1"
78+
DJ_HOST: 127.0.0.1
79+
DJ_PORT: 3306
80+
DJ_USER: root
81+
DJ_PASS: password
82+
S3_ENDPOINT: 127.0.0.1:9000
83+
S3_ACCESS_KEY: datajoint
84+
S3_SECRET_KEY: datajoint
85+
run: pytest --cov-report term-missing --cov=datajoint tests -v
86+
87+
# Unit tests run without containers (faster feedback)
88+
unit-tests:
89+
runs-on: ubuntu-latest
90+
strategy:
91+
matrix:
92+
py_ver: ["3.11"]
93+
steps:
94+
- uses: actions/checkout@v4
95+
96+
- name: Set up Python ${{ matrix.py_ver }}
97+
uses: actions/setup-python@v5
98+
with:
99+
python-version: ${{ matrix.py_ver }}
100+
101+
- name: Install dependencies
102+
run: pip install -e ".[test]"
103+
104+
- name: Run unit tests
105+
run: pytest tests/unit -v

0 commit comments

Comments
 (0)