|
1 | 1 | name: Test |
| 2 | + |
2 | 3 | on: |
3 | 4 | push: |
4 | 5 | branches: |
5 | | - - "**" # every branch |
6 | | - - "!gh-pages" # exclude gh-pages branch |
7 | | - - "!stage*" # exclude branches beginning with stage |
| 6 | + - "**" |
| 7 | + - "!gh-pages" |
| 8 | + - "!stage*" |
8 | 9 | paths: |
9 | | - - "src/datajoint" |
10 | | - - "tests" |
| 10 | + - "src/datajoint/**" |
| 11 | + - "tests/**" |
| 12 | + - "pyproject.toml" |
| 13 | + - ".github/workflows/test.yaml" |
11 | 14 | pull_request: |
12 | 15 | branches: |
13 | | - - "**" # every branch |
14 | | - - "!gh-pages" # exclude gh-pages branch |
15 | | - - "!stage*" # exclude branches beginning with stage |
| 16 | + - "**" |
| 17 | + - "!gh-pages" |
| 18 | + - "!stage*" |
16 | 19 | paths: |
17 | | - - "src/datajoint" |
18 | | - - "tests" |
| 20 | + - "src/datajoint/**" |
| 21 | + - "tests/**" |
| 22 | + - "pyproject.toml" |
| 23 | + - ".github/workflows/test.yaml" |
| 24 | + |
19 | 25 | jobs: |
20 | 26 | test: |
21 | 27 | runs-on: ubuntu-latest |
22 | 28 | strategy: |
| 29 | + fail-fast: false |
23 | 30 | matrix: |
24 | 31 | py_ver: ["3.10", "3.11", "3.12", "3.13"] |
25 | 32 | 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 | +
|
26 | 47 | steps: |
27 | 48 | - 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 }} |
29 | 68 | uses: actions/setup-python@v5 |
30 | 69 | 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 |
33 | 76 | 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