|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ master, python314 ] |
| 6 | + pull_request: |
| 7 | + branches: [ master ] |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +jobs: |
| 11 | + test: |
| 12 | + name: Test Python ${{ matrix.python-version }} on ${{ matrix.os }} |
| 13 | + runs-on: ${{ matrix.os }} |
| 14 | + strategy: |
| 15 | + fail-fast: false |
| 16 | + matrix: |
| 17 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 18 | + python-version: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14'] |
| 19 | + |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v4 |
| 22 | + |
| 23 | + - name: Set up Python ${{ matrix.python-version }} |
| 24 | + uses: actions/setup-python@v5 |
| 25 | + with: |
| 26 | + python-version: ${{ matrix.python-version }} |
| 27 | + allow-prereleases: true |
| 28 | + |
| 29 | + - name: Install uv |
| 30 | + uses: astral-sh/setup-uv@v4 |
| 31 | + with: |
| 32 | + enable-cache: true |
| 33 | + |
| 34 | + - name: Install dependencies |
| 35 | + run: | |
| 36 | + uv pip install --system -e ".[hdf5,dev]" |
| 37 | +
|
| 38 | + - name: Run tests |
| 39 | + run: | |
| 40 | + pytest -v tests --tb=short |
| 41 | +
|
| 42 | + - name: Test worldengine command |
| 43 | + run: | |
| 44 | + worldengine --help |
| 45 | + worldengine world -s 42 -n test_world -x 512 -y 512 |
| 46 | +
|
| 47 | + lint: |
| 48 | + name: Lint and Type Check |
| 49 | + runs-on: ubuntu-latest |
| 50 | + |
| 51 | + steps: |
| 52 | + - uses: actions/checkout@v4 |
| 53 | + |
| 54 | + - name: Set up Python |
| 55 | + uses: actions/setup-python@v5 |
| 56 | + with: |
| 57 | + python-version: '3.11' |
| 58 | + |
| 59 | + - name: Install uv |
| 60 | + uses: astral-sh/setup-uv@v4 |
| 61 | + |
| 62 | + - name: Install dependencies |
| 63 | + run: | |
| 64 | + uv pip install --system -e ".[dev]" |
| 65 | +
|
| 66 | + - name: Run pre-commit |
| 67 | + run: | |
| 68 | + pre-commit run --all-files |
| 69 | +
|
| 70 | + - name: Run ruff check |
| 71 | + run: | |
| 72 | + ruff check worldengine/ |
| 73 | +
|
| 74 | + - name: Run mypy |
| 75 | + run: | |
| 76 | + mypy worldengine/ --ignore-missing-imports |
| 77 | + continue-on-error: true |
| 78 | + |
| 79 | + build-wheels: |
| 80 | + name: Build wheels on ${{ matrix.os }} |
| 81 | + runs-on: ${{ matrix.os }} |
| 82 | + strategy: |
| 83 | + matrix: |
| 84 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 85 | + |
| 86 | + steps: |
| 87 | + - uses: actions/checkout@v4 |
| 88 | + |
| 89 | + - name: Set up Python |
| 90 | + uses: actions/setup-python@v5 |
| 91 | + with: |
| 92 | + python-version: '3.11' |
| 93 | + |
| 94 | + - name: Install build tools |
| 95 | + run: | |
| 96 | + python -m pip install --upgrade pip build |
| 97 | +
|
| 98 | + - name: Build sdist (Ubuntu only) |
| 99 | + if: matrix.os == 'ubuntu-latest' |
| 100 | + run: | |
| 101 | + python -m build --sdist |
| 102 | +
|
| 103 | + - name: Build wheel |
| 104 | + run: | |
| 105 | + python -m build --wheel |
| 106 | +
|
| 107 | + - name: Upload artifacts |
| 108 | + uses: actions/upload-artifact@v4 |
| 109 | + with: |
| 110 | + name: wheels-${{ matrix.os }} |
| 111 | + path: dist/* |
| 112 | + |
| 113 | + docker: |
| 114 | + name: Test Docker build |
| 115 | + runs-on: ubuntu-latest |
| 116 | + |
| 117 | + steps: |
| 118 | + - uses: actions/checkout@v4 |
| 119 | + |
| 120 | + - name: Set up Docker Buildx |
| 121 | + uses: docker/setup-buildx-action@v3 |
| 122 | + |
| 123 | + - name: Build Docker image |
| 124 | + uses: docker/build-push-action@v6 |
| 125 | + with: |
| 126 | + context: . |
| 127 | + push: false |
| 128 | + tags: worldengine:test |
| 129 | + cache-from: type=gha |
| 130 | + cache-to: type=gha,mode=max |
| 131 | + |
| 132 | + - name: Test Docker image |
| 133 | + run: | |
| 134 | + docker run worldengine:test worldengine --help |
| 135 | + docker run worldengine:test worldengine world -s 123 -n docker_test -x 256 -y 256 |
0 commit comments