name: PR Checks - Run # This workflow runs all PR checks with read-only permissions # Safe for fork PRs - results are saved as artifacts # Companion workflow (pr-checks-comment.yml) will post comments on: pull_request: types: [opened, synchronize, reopened] branches: [main, dev] # Read-only permissions - safe for fork PRs permissions: contents: read jobs: pr-info: name: PR Information runs-on: ubuntu-latest steps: - name: Check PR title format id: check-title run: | PR_TITLE="${{ github.event.pull_request.title }}" # Check if title follows conventional commits if echo "$PR_TITLE" | grep -qE "^(feat|fix|docs|style|refactor|perf|test|chore|ci|security)(\(.+\))?: .+"; then echo "status=✅ Good" >> $GITHUB_OUTPUT echo "message=PR title follows Conventional Commits format" >> $GITHUB_OUTPUT else echo "status=⚠️ Suggestion" >> $GITHUB_OUTPUT echo "message=Consider using Conventional Commits format: type(scope): description" >> $GITHUB_OUTPUT fi - name: Calculate PR size and save results id: pr-size run: | ADDITIONS=${{ github.event.pull_request.additions }} DELETIONS=${{ github.event.pull_request.deletions }} TOTAL=$((ADDITIONS + DELETIONS)) if [ $TOTAL -lt 100 ]; then SIZE="🟢 Small" SUGGESTION="" elif [ $TOTAL -lt 500 ]; then SIZE="🟡 Medium" SUGGESTION="" else SIZE="🔴 Large" SUGGESTION="Consider breaking this into smaller PRs for easier review" fi # Save all results to JSON file cat > pr-info.json </dev/null || echo "") if [ -n "$UNFORMATTED" ]; then echo "status=⚠️ Needs formatting" >> $GITHUB_OUTPUT echo "$UNFORMATTED" | head -10 > fmt-files.txt else echo "status=✅ Good" >> $GITHUB_OUTPUT echo "" > fmt-files.txt fi - name: Run go vet id: go-vet continue-on-error: true run: | if go vet ./... 2>&1 | tee vet-output.txt; then echo "status=✅ Good" >> $GITHUB_OUTPUT else echo "status=⚠️ Issues found" >> $GITHUB_OUTPUT cat vet-output.txt | head -20 > vet-output-short.txt fi - name: Run tests id: go-test continue-on-error: true run: | if go test ./... -v 2>&1 | tee test-output.txt; then echo "status=✅ Passed" >> $GITHUB_OUTPUT else echo "status=⚠️ Failed" >> $GITHUB_OUTPUT cat test-output.txt | tail -30 > test-output-short.txt fi - name: Save backend results if: always() run: | cat > backend-results.json <> $GITHUB_OUTPUT else echo "exists=false" >> $GITHUB_OUTPUT fi - name: Install dependencies if: steps.check-web.outputs.exists == 'true' working-directory: ./web continue-on-error: true run: npm ci - name: Run linter if: steps.check-web.outputs.exists == 'true' id: lint working-directory: ./web continue-on-error: true run: | if npm run lint 2>&1 | tee lint-output.txt; then echo "status=✅ Good" >> $GITHUB_OUTPUT else echo "status=⚠️ Issues found" >> $GITHUB_OUTPUT cat lint-output.txt | head -20 > lint-output-short.txt fi - name: Type check if: steps.check-web.outputs.exists == 'true' id: typecheck working-directory: ./web continue-on-error: true run: | if npm run type-check 2>&1 | tee typecheck-output.txt; then echo "status=✅ Good" >> $GITHUB_OUTPUT else echo "status=⚠️ Issues found" >> $GITHUB_OUTPUT cat typecheck-output.txt | head -20 > typecheck-output-short.txt fi - name: Build if: steps.check-web.outputs.exists == 'true' id: build working-directory: ./web continue-on-error: true run: | if npm run build 2>&1 | tee build-output.txt; then echo "status=✅ Success" >> $GITHUB_OUTPUT else echo "status=⚠️ Failed" >> $GITHUB_OUTPUT cat build-output.txt | tail -20 > build-output-short.txt fi - name: Save frontend results if: always() && steps.check-web.outputs.exists == 'true' working-directory: ./web run: | cat > frontend-results.json <