|
| 1 | +name: Run Code Checks |
| 2 | +on: |
| 3 | + push: |
| 4 | + pull_request: |
| 5 | + |
| 6 | +jobs: |
| 7 | + format: |
| 8 | + runs-on: ubuntu-latest |
| 9 | + steps: |
| 10 | + - uses: actions/checkout@v4 |
| 11 | + |
| 12 | + - name: Install uv |
| 13 | + uses: astral-sh/setup-uv@v5 |
| 14 | + with: |
| 15 | + version: "latest" |
| 16 | + enable-cache: true |
| 17 | + cache-dependency-glob: "uv.lock" |
| 18 | + |
| 19 | + - name: Set up Python |
| 20 | + uses: actions/setup-python@v5 |
| 21 | + with: |
| 22 | + python-version-file: ".python-version" |
| 23 | + |
| 24 | + - name: Install dependencies |
| 25 | + run: uv sync --locked --all-extras --dev |
| 26 | + |
| 27 | + - name: Run ruff format |
| 28 | + run: | |
| 29 | + uv run ruff --version |
| 30 | + uv run ruff format --check hdc tests |
| 31 | +
|
| 32 | + linting: |
| 33 | + runs-on: ubuntu-latest |
| 34 | + steps: |
| 35 | + - uses: actions/checkout@v4 |
| 36 | + |
| 37 | + - name: Install uv |
| 38 | + uses: astral-sh/setup-uv@v5 |
| 39 | + with: |
| 40 | + version: "latest" |
| 41 | + enable-cache: true |
| 42 | + cache-dependency-glob: "uv.lock" |
| 43 | + |
| 44 | + - name: Set up Python |
| 45 | + uses: actions/setup-python@v5 |
| 46 | + with: |
| 47 | + python-version-file: ".python-version" |
| 48 | + |
| 49 | + - name: Install dependencies |
| 50 | + run: uv sync --locked --all-extras --dev |
| 51 | + |
| 52 | + - name: Run ruff check |
| 53 | + run: | |
| 54 | + uv run ruff --version |
| 55 | + uv run ruff check --output-format=github hdc tests |
| 56 | + |
| 57 | + - name: Run mypy |
| 58 | + run: | |
| 59 | + uv run mypy --version |
| 60 | + uv run mypy --explicit-package-bases hdc |
| 61 | +
|
| 62 | + wheels: |
| 63 | + needs: |
| 64 | + - format |
| 65 | + - linting |
| 66 | + runs-on: ubuntu-latest |
| 67 | + steps: |
| 68 | + - uses: actions/checkout@v4 |
| 69 | + |
| 70 | + - name: Install uv |
| 71 | + uses: astral-sh/setup-uv@v5 |
| 72 | + with: |
| 73 | + version: "latest" |
| 74 | + enable-cache: true |
| 75 | + cache-dependency-glob: "uv.lock" |
| 76 | + |
| 77 | + - name: Set up Python |
| 78 | + uses: actions/setup-python@v5 |
| 79 | + with: |
| 80 | + python-version-file: ".python-version" |
| 81 | + |
| 82 | + - name: Install dependencies |
| 83 | + run: uv sync --locked --all-extras --dev |
| 84 | + |
| 85 | + - uses: actions/cache@v4 |
| 86 | + id: wheels_cache |
| 87 | + with: |
| 88 | + path: ./wheels |
| 89 | + key: wheels-${{ github.sha }} |
| 90 | + |
| 91 | + - name: Build wheels unpatched |
| 92 | + if: steps.wheels_cache.outputs.cache-hit != 'true' |
| 93 | + run: | |
| 94 | + mkdir -p wheels |
| 95 | + uv build --wheel --out-dir wheels |
| 96 | + |
| 97 | + - name: Patch version |
| 98 | + run: | |
| 99 | + uv run python ./scripts/patch_version.py ${GITHUB_RUN_NUMBER:-0} ./hdc/colors/_version.py |
| 100 | +
|
| 101 | + - name: Build wheels patched version |
| 102 | + if: steps.wheels_cache.outputs.cache-hit != 'true' |
| 103 | + run: | |
| 104 | + uv build --out-dir wheels |
| 105 | +
|
| 106 | + - name: Upload results (artifact) |
| 107 | + uses: actions/upload-artifact@v4 |
| 108 | + with: |
| 109 | + name: wheels |
| 110 | + path: wheels |
| 111 | + if-no-files-found: error |
| 112 | + |
| 113 | + tests: |
| 114 | + needs: |
| 115 | + - format |
| 116 | + - linting |
| 117 | + runs-on: ubuntu-latest |
| 118 | + steps: |
| 119 | + - uses: actions/checkout@v4 |
| 120 | + |
| 121 | + - name: Install uv |
| 122 | + uses: astral-sh/setup-uv@v5 |
| 123 | + with: |
| 124 | + version: "latest" |
| 125 | + enable-cache: true |
| 126 | + cache-dependency-glob: "uv.lock" |
| 127 | + |
| 128 | + - name: Set up Python |
| 129 | + uses: actions/setup-python@v5 |
| 130 | + with: |
| 131 | + python-version-file: ".python-version" |
| 132 | + |
| 133 | + - name: Install dependencies |
| 134 | + run: uv sync --locked --all-extras --dev |
| 135 | + |
| 136 | + - name: Run tests with coverage |
| 137 | + run: | |
| 138 | + uv run pytest -s \ |
| 139 | + --cov \ |
| 140 | + --cov-report=term \ |
| 141 | + tests/ |
| 142 | +
|
| 143 | + test-wheel: |
| 144 | + needs: |
| 145 | + - format |
| 146 | + - linting |
| 147 | + - wheels |
| 148 | + runs-on: ubuntu-latest |
| 149 | + steps: |
| 150 | + - uses: actions/checkout@v4 |
| 151 | + |
| 152 | + - name: Install uv |
| 153 | + uses: astral-sh/setup-uv@v5 |
| 154 | + with: |
| 155 | + version: "latest" |
| 156 | + |
| 157 | + - name: Set up Python |
| 158 | + uses: actions/setup-python@v5 |
| 159 | + with: |
| 160 | + python-version-file: ".python-version" |
| 161 | + |
| 162 | + - name: Get Wheels |
| 163 | + uses: actions/download-artifact@v4 |
| 164 | + with: |
| 165 | + name: wheels |
| 166 | + path: wheels |
| 167 | + |
| 168 | + - name: Install dev wheel |
| 169 | + run: | |
| 170 | + WHEEL=$(find wheels/ -type f -name "*.dev*.whl" | head -1) |
| 171 | + uv pip install --system "$WHEEL[ui,mpl]" |
| 172 | +
|
| 173 | + - name: Test code from the wheel |
| 174 | + run: | |
| 175 | + cd tests/ |
| 176 | + uv pip install --system pytest |
| 177 | + uv run --no-project pytest -s . |
0 commit comments