ci: optimize pre-commit workflow with path filtering (#444)

use dorny/paths-filter to detect what changed and only install
deps that are actually needed:

- frontend changes: install bun + frontend deps
- backend changes: install uv + backend deps
- other changes: no extra deps needed

this avoids installing all deps for every PR, reducing CI time
for frontend-only or backend-only changes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>

authored by zzstoatzz.io Claude and committed by GitHub a59b29aa 270fbc18

Changed files
+41 -3
.github
workflows
+41 -3
.github/workflows/run-pre-commit.yml
··· 16 steps: 17 - uses: actions/checkout@v5 18 19 - name: install uv 20 uses: astral-sh/setup-uv@v7 21 with: 22 enable-cache: true 23 cache-dependency-glob: "backend/uv.lock" 24 25 - name: install bun 26 uses: oven-sh/setup-bun@v2 27 28 - name: cache frontend dependencies 29 uses: actions/cache@v4 30 with: 31 path: frontend/node_modules ··· 33 restore-keys: | 34 ${{ runner.os }}-bun- 35 36 - - name: install dependencies 37 run: cd backend && uv sync 38 39 - name: install frontend dependencies 40 run: cd frontend && bun install 41 42 - name: create frontend env file 43 run: echo "PUBLIC_API_URL=http://localhost:8001" > frontend/.env 44 45 - name: check lockfile is up to date 46 run: | 47 cd backend 48 if ! uv lock --check; then ··· 52 fi 53 echo "✅ lockfile is up to date" 54 55 - name: run pre-commit 56 uses: j178/prek-action@v1 57 env: 58 - SKIP: ${{ github.ref == 'refs/heads/main' && 'no-commit-to-branch' || '' }} 59 60 - name: prune uv cache 61 - if: always() 62 run: uv cache prune --ci
··· 16 steps: 17 - uses: actions/checkout@v5 18 19 + - name: detect changed paths 20 + uses: dorny/paths-filter@v3 21 + id: filter 22 + with: 23 + filters: | 24 + backend: 25 + - 'backend/**' 26 + frontend: 27 + - 'frontend/**' 28 + rust: 29 + - 'moderation/**' 30 + - 'transcoder/**' 31 + 32 - name: install uv 33 + if: steps.filter.outputs.backend == 'true' 34 uses: astral-sh/setup-uv@v7 35 with: 36 enable-cache: true 37 cache-dependency-glob: "backend/uv.lock" 38 39 - name: install bun 40 + if: steps.filter.outputs.frontend == 'true' 41 uses: oven-sh/setup-bun@v2 42 43 - name: cache frontend dependencies 44 + if: steps.filter.outputs.frontend == 'true' 45 uses: actions/cache@v4 46 with: 47 path: frontend/node_modules ··· 49 restore-keys: | 50 ${{ runner.os }}-bun- 51 52 + - name: install backend dependencies 53 + if: steps.filter.outputs.backend == 'true' 54 run: cd backend && uv sync 55 56 - name: install frontend dependencies 57 + if: steps.filter.outputs.frontend == 'true' 58 run: cd frontend && bun install 59 60 - name: create frontend env file 61 + if: steps.filter.outputs.frontend == 'true' 62 run: echo "PUBLIC_API_URL=http://localhost:8001" > frontend/.env 63 64 - name: check lockfile is up to date 65 + if: steps.filter.outputs.backend == 'true' 66 run: | 67 cd backend 68 if ! uv lock --check; then ··· 72 fi 73 echo "✅ lockfile is up to date" 74 75 + - name: build skip list 76 + id: skip 77 + run: | 78 + SKIP_LIST="" 79 + if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then 80 + SKIP_LIST="no-commit-to-branch" 81 + fi 82 + if [[ "${{ steps.filter.outputs.backend }}" != "true" ]]; then 83 + SKIP_LIST="${SKIP_LIST:+$SKIP_LIST,}type-check" 84 + fi 85 + if [[ "${{ steps.filter.outputs.frontend }}" != "true" ]]; then 86 + SKIP_LIST="${SKIP_LIST:+$SKIP_LIST,}svelte-check,eslint" 87 + fi 88 + if [[ "${{ steps.filter.outputs.rust }}" != "true" ]]; then 89 + SKIP_LIST="${SKIP_LIST:+$SKIP_LIST,}cargo-check-moderation,cargo-check-transcoder" 90 + fi 91 + echo "list=$SKIP_LIST" >> $GITHUB_OUTPUT 92 + 93 - name: run pre-commit 94 uses: j178/prek-action@v1 95 env: 96 + SKIP: ${{ steps.skip.outputs.list }} 97 98 - name: prune uv cache 99 + if: always() && steps.filter.outputs.backend == 'true' 100 run: uv cache prune --ci