|
| 1 | +name: Validation |
| 2 | + |
| 3 | +on: workflow_call |
| 4 | + |
| 5 | +env: |
| 6 | + PYTHON_VERSION: "3.14" |
| 7 | + PRE_COMMIT_HOME: "/home/runner/.cache/pre-commit" |
| 8 | + |
| 9 | +jobs: |
| 10 | + lint: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + |
| 13 | + steps: |
| 14 | + - name: Checkout repository |
| 15 | + uses: actions/checkout@v4 |
| 16 | + |
| 17 | + - name: Setup uv |
| 18 | + uses: astral-sh/setup-uv@v5 |
| 19 | + with: |
| 20 | + version: "latest" |
| 21 | + python-version: ${{ env.PYTHON_VERSION }} |
| 22 | + enable-cache: true |
| 23 | + cache-suffix: "validation-py${{ env.python-version }}" |
| 24 | + |
| 25 | + - name: Install dependencies |
| 26 | + run: | |
| 27 | + # We need the test group here to allow pyright to type-check code in tests |
| 28 | + uv sync --no-default-groups --group lint --group test |
| 29 | +
|
| 30 | + - name: Get precommit version |
| 31 | + id: precommit_version |
| 32 | + run: | |
| 33 | + PACKAGE_VERSION=$(pip show pre-commit | grep -i "version:" | awk '{print $2}') |
| 34 | + echo "version=$PACKAGE_VERSION" >> $GITHUB_ENV |
| 35 | +
|
| 36 | + - name: Pre-commit Environment Caching |
| 37 | + uses: actions/cache@v4 |
| 38 | + with: |
| 39 | + path: ${{ env.PRE_COMMIT_HOME }} |
| 40 | + key: |
| 41 | + "precommit-${{ runner.os }}-${{ env.PYTHON_VERSION }}-${{ steps.precommit_version.outputs.version }}-\ |
| 42 | + ${{ hashFiles('./.pre-commit-config.yaml') }}" |
| 43 | + # Restore keys allows us to perform a cache restore even if the full cache key wasn't matched. |
| 44 | + # That way we still end up saving new cache, but we can still make use of the cache from previous |
| 45 | + # version. |
| 46 | + restore-keys: "precommit-${{ runner.os }}-${{ steps.poetry_setup.outputs-python-version}}-" |
| 47 | + |
| 48 | + - name: Run pre-commit hooks |
| 49 | + run: SKIP=ruff-linter,ruff-formatter,slotscheck,basedpyright pre-commit run --all-files |
| 50 | + |
| 51 | + - name: Run ruff linter |
| 52 | + run: ruff check --output-format=github --show-fixes --exit-non-zero-on-fix . |
| 53 | + |
| 54 | + - name: Run ruff formatter |
| 55 | + run: ruff format --diff . |
| 56 | + |
| 57 | + - name: Run basedpyright type checker |
| 58 | + run: basedpyright --warnings . |
| 59 | + |
| 60 | + - name: Check UV Lockfile |
| 61 | + run: uv lock --check |
0 commit comments