Fix validation logic

This commit is contained in:
zbhan
2025-11-02 22:49:43 -05:00
parent 3c7925dc46
commit 9f311580e1
3 changed files with 39 additions and 170 deletions

View File

@@ -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 <<EOF
{
"pr_number": ${{ github.event.pull_request.number }},
"title_status": "${{ steps.check-title.outputs.status }}",
"title_message": "${{ steps.check-title.outputs.message }}",
"size": "$SIZE",
"lines": $TOTAL,
"size_suggestion": "$SUGGESTION"
}
EOF
cat pr-info.json
- name: Upload PR info results
uses: actions/upload-artifact@v4
with:
name: pr-info-results
path: pr-info.json
retention-days: 1
# Backend advisory checks
# Different from pr-checks.yml: these use continue-on-error and generate reports
backend-checks:
name: Backend Checks
runs-on: ubuntu-latest
@@ -147,6 +96,8 @@ jobs:
test-output-short.txt
retention-days: 1
# Frontend advisory checks
# Different from pr-checks.yml: these use continue-on-error and generate reports
frontend-checks:
name: Frontend Checks
runs-on: ubuntu-latest
@@ -173,43 +124,18 @@ jobs:
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
- 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 <<EOF
{
"pr_number": ${{ github.event.pull_request.number }},
"lint_status": "${{ steps.lint.outputs.status }}",
"typecheck_status": "${{ steps.typecheck.outputs.status }}",
"build_status": "${{ steps.build.outputs.status }}"
}
EOF
@@ -232,7 +156,5 @@ jobs:
name: frontend-results
path: |
web/frontend-results.json
web/lint-output-short.txt
web/typecheck-output-short.txt
web/build-output-short.txt
retention-days: 1