at main 2.9 kB view raw
1name: pre-commit checks 2 3on: 4 pull_request: 5 push: 6 branches: [main] 7 8permissions: 9 contents: read 10 11jobs: 12 pre_commit: 13 timeout-minutes: 5 14 runs-on: ubuntu-latest 15 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 48 key: ${{ runner.os }}-bun-${{ hashFiles('frontend/bun.lockb') }} 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 69 echo "❌ lockfile is out of date!" 70 echo "to update the lockfile, run 'uv lock'." 71 exit 1 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