update #49
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: PR Checks | |
| on: | |
| pull_request_target: | |
| branches: [main, dev] | |
| types: [opened, synchronize, reopened, ready_for_review] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number }} | |
| cancel-in-progress: true | |
| jobs: | |
| backend: | |
| if: github.event.pull_request.draft == false | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| cache: "pip" | |
| cache-dependency-path: backend/pyproject.toml | |
| - name: Install backend (editable) | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -e backend | |
| - name: Backend syntax check (compileall) | |
| run: python -m compileall -q backend/app | |
| - name: Backend import smoke test | |
| run: | | |
| python -c "from app.main import app; print('backend app import: ok')" | |
| frontend: | |
| if: github.event.pull_request.draft == false | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: frontend | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: "9.12.2" | |
| run_install: false | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| cache: "pnpm" | |
| cache-dependency-path: frontend/pnpm-lock.yaml | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Build web app | |
| run: pnpm --filter @whalewhisper/web build | |
| report-status: | |
| needs: [backend, frontend] | |
| if: always() && github.event.pull_request.draft == false | |
| runs-on: ubuntu-latest | |
| permissions: | |
| statuses: write | |
| steps: | |
| - name: Report check status to PR head SHA | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const sha = context.payload.pull_request.head.sha; | |
| const backendResult = '${{ needs.backend.result }}'; | |
| const frontendResult = '${{ needs.frontend.result }}'; | |
| const checks = [ | |
| { context: 'PR Checks / backend', result: backendResult }, | |
| { context: 'PR Checks / frontend', result: frontendResult }, | |
| ]; | |
| for (const check of checks) { | |
| const state = check.result === 'success' ? 'success' | |
| : check.result === 'skipped' ? 'success' | |
| : 'failure'; | |
| await github.rest.repos.createCommitStatus({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| sha, | |
| state, | |
| context: check.context, | |
| description: `${check.result} (via pull_request_target)`, | |
| target_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`, | |
| }); | |
| } |