mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-09 14:00:57 +08:00
Fix validation logic
This commit is contained in:
98
.github/workflows/pr-checks-comment.yml
vendored
98
.github/workflows/pr-checks-comment.yml
vendored
@@ -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<<EOF" >> $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<<EOF" >> $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<<EOF" >> $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 += '<details><summary>Issues found</summary>\n\n```\n' + lintOutput.substring(0, 500) + '\n```\n</details>\n\n';
|
||||
}
|
||||
}
|
||||
|
||||
if (typecheckStatus) {
|
||||
comment += '**Type Checking:** ' + typecheckStatus + '\n';
|
||||
const typecheckOutput = `${{ steps.frontend.outputs.typecheck_output }}`;
|
||||
if (typecheckOutput && typecheckOutput.trim()) {
|
||||
comment += '<details><summary>Type errors</summary>\n\n```\n' + typecheckOutput.substring(0, 500) + '\n```\n</details>\n\n';
|
||||
}
|
||||
}
|
||||
|
||||
if (buildStatus) {
|
||||
comment += '**Build:** ' + buildStatus + '\n';
|
||||
const buildOutput = `${{ steps.frontend.outputs.build_output }}`;
|
||||
if (buildOutput && buildOutput.trim()) {
|
||||
comment += '<details><summary>Build output</summary>\n\n```\n' + buildOutput.substring(0, 500) + '\n```\n</details>\n\n';
|
||||
}
|
||||
comment += '**Build & Type Check:** ' + buildStatus + '\n';
|
||||
const buildOutput = `${{ steps.frontend.outputs.build_output }}`;
|
||||
if (buildOutput && buildOutput.trim()) {
|
||||
comment += '<details><summary>Build output</summary>\n\n```\n' + buildOutput.substring(0, 1000) + '\n```\n</details>\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';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user