diff --git a/.github/workflows/pr-checks-comment.yml b/.github/workflows/pr-checks-comment.yml index f0806026..f90a7128 100644 --- a/.github/workflows/pr-checks-comment.yml +++ b/.github/workflows/pr-checks-comment.yml @@ -1,8 +1,11 @@ name: PR Checks - Comment -# This workflow posts PR check results as comments +# This workflow posts ADVISORY check results as comments # Runs in the main repo context with write permissions (SAFE) # Triggered after pr-checks-run.yml completes +# +# NOTE: PR title and size checks are handled by pr-checks.yml (no duplication) +# This workflow only posts backend/frontend advisory check results on: workflow_run: @@ -19,7 +22,7 @@ permissions: jobs: comment: - name: Post Check Results + name: Post Advisory Check Results runs-on: ubuntu-latest # Only run if the workflow was triggered by a pull_request event if: github.event.workflow_run.event == 'pull_request' @@ -37,24 +40,6 @@ jobs: ls -la artifacts/ || echo "No artifacts directory" find artifacts/ -type f || echo "No files found" - - name: Read PR info results - id: pr-info - continue-on-error: true - run: | - if [ -f artifacts/pr-info-results/pr-info.json ]; then - echo "=== PR Info JSON ===" - cat artifacts/pr-info-results/pr-info.json - echo "pr_number=$(jq -r '.pr_number' artifacts/pr-info-results/pr-info.json)" >> $GITHUB_OUTPUT - echo "title_status=$(jq -r '.title_status' artifacts/pr-info-results/pr-info.json)" >> $GITHUB_OUTPUT - echo "title_message=$(jq -r '.title_message' artifacts/pr-info-results/pr-info.json)" >> $GITHUB_OUTPUT - echo "size=$(jq -r '.size' artifacts/pr-info-results/pr-info.json)" >> $GITHUB_OUTPUT - echo "lines=$(jq -r '.lines' artifacts/pr-info-results/pr-info.json)" >> $GITHUB_OUTPUT - echo "size_suggestion=$(jq -r '.size_suggestion' artifacts/pr-info-results/pr-info.json)" >> $GITHUB_OUTPUT - else - echo "pr_number=0" >> $GITHUB_OUTPUT - echo "⚠️ PR info artifact not found" - fi - - name: Read backend results id: backend continue-on-error: true @@ -62,6 +47,7 @@ jobs: if [ -f artifacts/backend-results/backend-results.json ]; then echo "=== Backend Results JSON ===" cat artifacts/backend-results/backend-results.json + echo "pr_number=$(jq -r '.pr_number' artifacts/backend-results/backend-results.json)" >> $GITHUB_OUTPUT echo "fmt_status=$(jq -r '.fmt_status' artifacts/backend-results/backend-results.json)" >> $GITHUB_OUTPUT echo "vet_status=$(jq -r '.vet_status' artifacts/backend-results/backend-results.json)" >> $GITHUB_OUTPUT echo "test_status=$(jq -r '.test_status' artifacts/backend-results/backend-results.json)" >> $GITHUB_OUTPUT @@ -83,6 +69,7 @@ jobs: echo "EOF" >> $GITHUB_OUTPUT fi else + echo "pr_number=0" >> $GITHUB_OUTPUT echo "⚠️ Backend results artifact not found" fi @@ -93,21 +80,9 @@ jobs: if [ -f artifacts/frontend-results/frontend-results.json ]; then echo "=== Frontend Results JSON ===" cat artifacts/frontend-results/frontend-results.json - echo "lint_status=$(jq -r '.lint_status' artifacts/frontend-results/frontend-results.json)" >> $GITHUB_OUTPUT - echo "typecheck_status=$(jq -r '.typecheck_status' artifacts/frontend-results/frontend-results.json)" >> $GITHUB_OUTPUT echo "build_status=$(jq -r '.build_status' artifacts/frontend-results/frontend-results.json)" >> $GITHUB_OUTPUT # Read output files - if [ -f artifacts/frontend-results/lint-output-short.txt ]; then - echo "lint_output<> $GITHUB_OUTPUT - cat artifacts/frontend-results/lint-output-short.txt >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - fi - if [ -f artifacts/frontend-results/typecheck-output-short.txt ]; then - echo "typecheck_output<> $GITHUB_OUTPUT - cat artifacts/frontend-results/typecheck-output-short.txt >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - fi if [ -f artifacts/frontend-results/build-output-short.txt ]; then echo "build_output<> $GITHUB_OUTPUT cat artifacts/frontend-results/build-output-short.txt >> $GITHUB_OUTPUT @@ -117,29 +92,16 @@ jobs: echo "⚠️ Frontend results artifact not found" fi - - name: Post combined comment - if: steps.pr-info.outputs.pr_number != '0' + - name: Post advisory results comment + if: steps.backend.outputs.pr_number != '0' uses: actions/github-script@v7 with: script: | - const prNumber = ${{ steps.pr-info.outputs.pr_number }}; + const prNumber = ${{ steps.backend.outputs.pr_number }}; - // PR Info section - const titleStatus = '${{ steps.pr-info.outputs.title_status }}' || '⚠️ Unknown'; - const prSize = '${{ steps.pr-info.outputs.size }}' || '⚠️ Unknown'; - const prLines = '${{ steps.pr-info.outputs.lines }}' || '0'; - const sizeSuggestion = '${{ steps.pr-info.outputs.size_suggestion }}' || ''; - - let comment = '## 🤖 PR Checks Results\n\n'; - comment += 'Thank you for your contribution! Here are the automated check results:\n\n'; - - // PR Info - comment += '### 📋 PR Information\n\n'; - comment += '**Title Format:** ' + titleStatus + '\n'; - comment += '**PR Size:** ' + prSize + ' (' + prLines + ' lines changed)\n'; - if (sizeSuggestion) { - comment += '\n💡 **Suggestion:** ' + sizeSuggestion + '\n'; - } + let comment = '## 🤖 Advisory Check Results\n\n'; + comment += 'These are **advisory** checks to help improve code quality. They won\'t block your PR from being merged.\n\n'; + comment += '> **Note:** PR title and size checks are handled by the main workflow and may appear in a separate comment.\n\n'; // Backend checks const fmtStatus = '${{ steps.backend.outputs.fmt_status }}'; @@ -182,43 +144,21 @@ jobs: } // Frontend checks - const lintStatus = '${{ steps.frontend.outputs.lint_status }}'; - const typecheckStatus = '${{ steps.frontend.outputs.typecheck_status }}'; const buildStatus = '${{ steps.frontend.outputs.build_status }}'; - if (lintStatus || typecheckStatus || buildStatus) { + if (buildStatus) { comment += '\n### ⚛️ Frontend Checks\n\n'; - if (lintStatus) { - comment += '**Linting:** ' + lintStatus + '\n'; - const lintOutput = `${{ steps.frontend.outputs.lint_output }}`; - if (lintOutput && lintOutput.trim()) { - comment += '
Issues found\n\n```\n' + lintOutput.substring(0, 500) + '\n```\n
\n\n'; - } - } - - if (typecheckStatus) { - comment += '**Type Checking:** ' + typecheckStatus + '\n'; - const typecheckOutput = `${{ steps.frontend.outputs.typecheck_output }}`; - if (typecheckOutput && typecheckOutput.trim()) { - comment += '
Type errors\n\n```\n' + typecheckOutput.substring(0, 500) + '\n```\n
\n\n'; - } - } - - if (buildStatus) { - comment += '**Build:** ' + buildStatus + '\n'; - const buildOutput = `${{ steps.frontend.outputs.build_output }}`; - if (buildOutput && buildOutput.trim()) { - comment += '
Build output\n\n```\n' + buildOutput.substring(0, 500) + '\n```\n
\n\n'; - } + comment += '**Build & Type Check:** ' + buildStatus + '\n'; + const buildOutput = `${{ steps.frontend.outputs.build_output }}`; + if (buildOutput && buildOutput.trim()) { + comment += '
Build output\n\n```\n' + buildOutput.substring(0, 1000) + '\n```\n
\n\n'; } comment += '\n**Fix locally:**\n'; comment += '```bash\n'; comment += 'cd web\n'; - comment += 'npm run lint -- --fix # Fix linting\n'; - comment += 'npm run type-check # Check types\n'; - comment += 'npm run build # Test build\n'; + comment += 'npm run build # Test build (includes type checking)\n'; comment += '```\n'; } diff --git a/.github/workflows/pr-checks-run.yml b/.github/workflows/pr-checks-run.yml index d228bb44..48d23afe 100644 --- a/.github/workflows/pr-checks-run.yml +++ b/.github/workflows/pr-checks-run.yml @@ -1,8 +1,12 @@ name: PR Checks - Run -# This workflow runs all PR checks with read-only permissions +# This workflow runs advisory PR checks with read-only permissions # Safe for fork PRs - results are saved as artifacts # Companion workflow (pr-checks-comment.yml) will post comments +# +# NOTE: This workflow provides ADVISORY checks (non-blocking) +# Main blocking checks are in pr-checks.yml +# PR title and size checks are handled by pr-checks.yml (no duplication) on: pull_request: @@ -14,63 +18,8 @@ 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 (expanded type list) - if echo "$PR_TITLE" | grep -qE "^(feat|fix|docs|style|refactor|perf|test|chore|ci|security|build)(\(.+\))?: .+"; 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 format: type(scope): description. Valid types: feat, fix, docs, style, refactor, perf, test, chore, ci, security, build" >> $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 <&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 + - name: Build and Type Check if: steps.check-web.outputs.exists == 'true' id: build working-directory: ./web continue-on-error: true run: | + # build script includes: tsc && vite build 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 + cat build-output.txt | tail -30 > build-output-short.txt fi - name: Save frontend results @@ -219,8 +145,6 @@ jobs: cat > frontend-results.json <