|
| 1 | +name: Python Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: ["main"] |
| 6 | + pull_request: |
| 7 | + |
| 8 | +concurrency: |
| 9 | + group: tests-${{ github.ref }} |
| 10 | + cancel-in-progress: true |
| 11 | + |
| 12 | +defaults: |
| 13 | + run: |
| 14 | + shell: bash -eux {0} |
| 15 | + |
| 16 | +env: |
| 17 | + MIN_PYTHON: "3.9" |
| 18 | + MIN_MONGODB: "4.0" |
| 19 | + MAX_MONGODB: "8.0" |
| 20 | + |
| 21 | +jobs: |
| 22 | + static: |
| 23 | + runs-on: ubuntu-latest |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@v4 |
| 26 | + with: |
| 27 | + persist-credentials: false |
| 28 | + fetch-depth: 0 |
| 29 | + - name: Install uv |
| 30 | + uses: astral-sh/setup-uv@v5 |
| 31 | + with: |
| 32 | + enable-cache: true |
| 33 | + python-version: ${{ matrix.python-version }} |
| 34 | + - uses: extractions/setup-just@v3 |
| 35 | + - run: just install |
| 36 | + - run: just lint |
| 37 | + - run: just docs |
| 38 | + - run: just doctest |
| 39 | + build: |
| 40 | + runs-on: ${{ matrix.os }} |
| 41 | + strategy: |
| 42 | + matrix: |
| 43 | + os: ["ubuntu-latest", "macos-latest", "windows-latest"] |
| 44 | + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] |
| 45 | + fail-fast: false |
| 46 | + name: CPython ${{ matrix.python-version }}-${{ matrix.os }} |
| 47 | + steps: |
| 48 | + - uses: actions/checkout@v4 |
| 49 | + with: |
| 50 | + persist-credentials: false |
| 51 | + fetch-depth: 0 |
| 52 | + - name: Install uv |
| 53 | + uses: astral-sh/setup-uv@v5 |
| 54 | + with: |
| 55 | + enable-cache: true |
| 56 | + python-version: ${{ matrix.python-version }} |
| 57 | + - uses: extractions/setup-just@v3 |
| 58 | + - name: Start MongoDB on Linux |
| 59 | + if: ${{ startsWith(runner.os, 'Linux') }} |
| 60 | + uses: supercharge/[email protected] |
| 61 | + with: |
| 62 | + mongodb-version: ${{ env.MAX_MONGODB }} |
| 63 | + mongodb-replica-set: test-rs |
| 64 | + - name: Start MongoDB on MacOS |
| 65 | + if: ${{ startsWith(runner.os, 'macOS') }} |
| 66 | + run: | |
| 67 | + brew tap mongodb/brew |
| 68 | + brew install mongodb/brew/mongodb-community@${MAX_MONGODB} |
| 69 | + brew services start mongodb-community@${MAX_MONGODB} |
| 70 | + - name: Start MongoDB on Windows |
| 71 | + if: ${{ startsWith(runner.os, 'Windows') }} |
| 72 | + shell: powershell |
| 73 | + run: | |
| 74 | + mkdir data |
| 75 | + mongod --remove |
| 76 | + mongod --install --dbpath=$(pwd)/data --logpath=$PWD/mongo.log |
| 77 | + net start MongoDB |
| 78 | + - run: just install |
| 79 | + - run: just test |
| 80 | + |
| 81 | + build-min: |
| 82 | + runs-on: ubuntu-latest |
| 83 | + steps: |
| 84 | + - uses: actions/checkout@v4 |
| 85 | + with: |
| 86 | + persist-credentials: false |
| 87 | + fetch-depth: 0 |
| 88 | + - name: Install uv |
| 89 | + uses: astral-sh/setup-uv@v5 |
| 90 | + with: |
| 91 | + enable-cache: true |
| 92 | + python-version: ${{ env.MIN_PYTHON }} |
| 93 | + - uses: extractions/setup-just@v3 |
| 94 | + - name: Install uv |
| 95 | + uses: astral-sh/setup-uv@v5 |
| 96 | + with: |
| 97 | + enable-cache: true |
| 98 | + python-version: ${{ env.MIN_PYTHON }} |
| 99 | + - uses: extractions/setup-just@v3 |
| 100 | + - uses: supercharge/[email protected] |
| 101 | + with: |
| 102 | + mongodb-version: ${{ env.MIN_MONGODB }} |
| 103 | + mongodb-replica-set: test-rs |
| 104 | + - name: Run unit tests with minimum dependency versions |
| 105 | + run: | |
| 106 | + uv sync --python=${MIN_PYTHON} --resolution=lowest-direct |
| 107 | + just test |
0 commit comments