Skip to content

Commit 7a43f25

Browse files
author
zbhan
committed
Fix validation logic
1 parent 8824001 commit 7a43f25

3 files changed

Lines changed: 40 additions & 171 deletions

File tree

.github/workflows/pr-checks-comment.yml

Lines changed: 20 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
name: PR Checks - Comment
22

3-
# This workflow posts PR check results as comments
3+
# This workflow posts ADVISORY check results as comments
44
# Runs in the main repo context with write permissions (SAFE)
55
# Triggered after pr-checks-run.yml completes
6+
#
7+
# NOTE: PR title and size checks are handled by pr-checks.yml (no duplication)
8+
# This workflow only posts backend/frontend advisory check results
69

710
on:
811
workflow_run:
@@ -19,7 +22,7 @@ permissions:
1922

2023
jobs:
2124
comment:
22-
name: Post Check Results
25+
name: Post Advisory Check Results
2326
runs-on: ubuntu-latest
2427
# Only run if the workflow was triggered by a pull_request event
2528
if: github.event.workflow_run.event == 'pull_request'
@@ -37,31 +40,14 @@ jobs:
3740
ls -la artifacts/ || echo "No artifacts directory"
3841
find artifacts/ -type f || echo "No files found"
3942
40-
- name: Read PR info results
41-
id: pr-info
42-
continue-on-error: true
43-
run: |
44-
if [ -f artifacts/pr-info-results/pr-info.json ]; then
45-
echo "=== PR Info JSON ==="
46-
cat artifacts/pr-info-results/pr-info.json
47-
echo "pr_number=$(jq -r '.pr_number' artifacts/pr-info-results/pr-info.json)" >> $GITHUB_OUTPUT
48-
echo "title_status=$(jq -r '.title_status' artifacts/pr-info-results/pr-info.json)" >> $GITHUB_OUTPUT
49-
echo "title_message=$(jq -r '.title_message' artifacts/pr-info-results/pr-info.json)" >> $GITHUB_OUTPUT
50-
echo "size=$(jq -r '.size' artifacts/pr-info-results/pr-info.json)" >> $GITHUB_OUTPUT
51-
echo "lines=$(jq -r '.lines' artifacts/pr-info-results/pr-info.json)" >> $GITHUB_OUTPUT
52-
echo "size_suggestion=$(jq -r '.size_suggestion' artifacts/pr-info-results/pr-info.json)" >> $GITHUB_OUTPUT
53-
else
54-
echo "pr_number=0" >> $GITHUB_OUTPUT
55-
echo "⚠️ PR info artifact not found"
56-
fi
57-
5843
- name: Read backend results
5944
id: backend
6045
continue-on-error: true
6146
run: |
6247
if [ -f artifacts/backend-results/backend-results.json ]; then
6348
echo "=== Backend Results JSON ==="
6449
cat artifacts/backend-results/backend-results.json
50+
echo "pr_number=$(jq -r '.pr_number' artifacts/backend-results/backend-results.json)" >> $GITHUB_OUTPUT
6551
echo "fmt_status=$(jq -r '.fmt_status' artifacts/backend-results/backend-results.json)" >> $GITHUB_OUTPUT
6652
echo "vet_status=$(jq -r '.vet_status' artifacts/backend-results/backend-results.json)" >> $GITHUB_OUTPUT
6753
echo "test_status=$(jq -r '.test_status' artifacts/backend-results/backend-results.json)" >> $GITHUB_OUTPUT
@@ -83,6 +69,7 @@ jobs:
8369
echo "EOF" >> $GITHUB_OUTPUT
8470
fi
8571
else
72+
echo "pr_number=0" >> $GITHUB_OUTPUT
8673
echo "⚠️ Backend results artifact not found"
8774
fi
8875
@@ -93,21 +80,9 @@ jobs:
9380
if [ -f artifacts/frontend-results/frontend-results.json ]; then
9481
echo "=== Frontend Results JSON ==="
9582
cat artifacts/frontend-results/frontend-results.json
96-
echo "lint_status=$(jq -r '.lint_status' artifacts/frontend-results/frontend-results.json)" >> $GITHUB_OUTPUT
97-
echo "typecheck_status=$(jq -r '.typecheck_status' artifacts/frontend-results/frontend-results.json)" >> $GITHUB_OUTPUT
9883
echo "build_status=$(jq -r '.build_status' artifacts/frontend-results/frontend-results.json)" >> $GITHUB_OUTPUT
9984
10085
# Read output files
101-
if [ -f artifacts/frontend-results/lint-output-short.txt ]; then
102-
echo "lint_output<<EOF" >> $GITHUB_OUTPUT
103-
cat artifacts/frontend-results/lint-output-short.txt >> $GITHUB_OUTPUT
104-
echo "EOF" >> $GITHUB_OUTPUT
105-
fi
106-
if [ -f artifacts/frontend-results/typecheck-output-short.txt ]; then
107-
echo "typecheck_output<<EOF" >> $GITHUB_OUTPUT
108-
cat artifacts/frontend-results/typecheck-output-short.txt >> $GITHUB_OUTPUT
109-
echo "EOF" >> $GITHUB_OUTPUT
110-
fi
11186
if [ -f artifacts/frontend-results/build-output-short.txt ]; then
11287
echo "build_output<<EOF" >> $GITHUB_OUTPUT
11388
cat artifacts/frontend-results/build-output-short.txt >> $GITHUB_OUTPUT
@@ -117,29 +92,16 @@ jobs:
11792
echo "⚠️ Frontend results artifact not found"
11893
fi
11994
120-
- name: Post combined comment
121-
if: steps.pr-info.outputs.pr_number != '0'
95+
- name: Post advisory results comment
96+
if: steps.backend.outputs.pr_number != '0'
12297
uses: actions/github-script@v7
12398
with:
12499
script: |
125-
const prNumber = ${{ steps.pr-info.outputs.pr_number }};
126-
127-
// PR Info section
128-
const titleStatus = '${{ steps.pr-info.outputs.title_status }}' || '⚠️ Unknown';
129-
const prSize = '${{ steps.pr-info.outputs.size }}' || '⚠️ Unknown';
130-
const prLines = '${{ steps.pr-info.outputs.lines }}' || '0';
131-
const sizeSuggestion = '${{ steps.pr-info.outputs.size_suggestion }}' || '';
132-
133-
let comment = '## 🤖 PR Checks Results\n\n';
134-
comment += 'Thank you for your contribution! Here are the automated check results:\n\n';
135-
136-
// PR Info
137-
comment += '### 📋 PR Information\n\n';
138-
comment += '**Title Format:** ' + titleStatus + '\n';
139-
comment += '**PR Size:** ' + prSize + ' (' + prLines + ' lines changed)\n';
140-
if (sizeSuggestion) {
141-
comment += '\n💡 **Suggestion:** ' + sizeSuggestion + '\n';
142-
}
100+
const prNumber = ${{ steps.backend.outputs.pr_number }};
101+
102+
let comment = '## 🤖 Advisory Check Results\n\n';
103+
comment += 'These are **advisory** checks to help improve code quality. They won\'t block your PR from being merged.\n\n';
104+
comment += '> **Note:** PR title and size checks are handled by the main workflow and may appear in a separate comment.\n\n';
143105
144106
// Backend checks
145107
const fmtStatus = '${{ steps.backend.outputs.fmt_status }}';
@@ -182,43 +144,21 @@ jobs:
182144
}
183145
184146
// Frontend checks
185-
const lintStatus = '${{ steps.frontend.outputs.lint_status }}';
186-
const typecheckStatus = '${{ steps.frontend.outputs.typecheck_status }}';
187147
const buildStatus = '${{ steps.frontend.outputs.build_status }}';
188148
189-
if (lintStatus || typecheckStatus || buildStatus) {
149+
if (buildStatus) {
190150
comment += '\n### ⚛️ Frontend Checks\n\n';
191151
192-
if (lintStatus) {
193-
comment += '**Linting:** ' + lintStatus + '\n';
194-
const lintOutput = `${{ steps.frontend.outputs.lint_output }}`;
195-
if (lintOutput && lintOutput.trim()) {
196-
comment += '<details><summary>Issues found</summary>\n\n```\n' + lintOutput.substring(0, 500) + '\n```\n</details>\n\n';
197-
}
198-
}
199-
200-
if (typecheckStatus) {
201-
comment += '**Type Checking:** ' + typecheckStatus + '\n';
202-
const typecheckOutput = `${{ steps.frontend.outputs.typecheck_output }}`;
203-
if (typecheckOutput && typecheckOutput.trim()) {
204-
comment += '<details><summary>Type errors</summary>\n\n```\n' + typecheckOutput.substring(0, 500) + '\n```\n</details>\n\n';
205-
}
206-
}
207-
208-
if (buildStatus) {
209-
comment += '**Build:** ' + buildStatus + '\n';
210-
const buildOutput = `${{ steps.frontend.outputs.build_output }}`;
211-
if (buildOutput && buildOutput.trim()) {
212-
comment += '<details><summary>Build output</summary>\n\n```\n' + buildOutput.substring(0, 500) + '\n```\n</details>\n\n';
213-
}
152+
comment += '**Build & Type Check:** ' + buildStatus + '\n';
153+
const buildOutput = `${{ steps.frontend.outputs.build_output }}`;
154+
if (buildOutput && buildOutput.trim()) {
155+
comment += '<details><summary>Build output</summary>\n\n```\n' + buildOutput.substring(0, 1000) + '\n```\n</details>\n\n';
214156
}
215157
216158
comment += '\n**Fix locally:**\n';
217159
comment += '```bash\n';
218160
comment += 'cd web\n';
219-
comment += 'npm run lint -- --fix # Fix linting\n';
220-
comment += 'npm run type-check # Check types\n';
221-
comment += 'npm run build # Test build\n';
161+
comment += 'npm run build # Test build (includes type checking)\n';
222162
comment += '```\n';
223163
}
224164

.github/workflows/pr-checks-run.yml

Lines changed: 12 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
name: PR Checks - Run
22

3-
# This workflow runs all PR checks with read-only permissions
3+
# This workflow runs advisory PR checks with read-only permissions
44
# Safe for fork PRs - results are saved as artifacts
55
# Companion workflow (pr-checks-comment.yml) will post comments
6+
#
7+
# NOTE: This workflow provides ADVISORY checks (non-blocking)
8+
# Main blocking checks are in pr-checks.yml
9+
# PR title and size checks are handled by pr-checks.yml (no duplication)
610

711
on:
812
pull_request:
@@ -14,63 +18,8 @@ permissions:
1418
contents: read
1519

1620
jobs:
17-
pr-info:
18-
name: PR Information
19-
runs-on: ubuntu-latest
20-
steps:
21-
- name: Check PR title format
22-
id: check-title
23-
run: |
24-
PR_TITLE="${{ github.event.pull_request.title }}"
25-
26-
# Check if title follows conventional commits (expanded type list)
27-
if echo "$PR_TITLE" | grep -qE "^(feat|fix|docs|style|refactor|perf|test|chore|ci|security|build)(\(.+\))?: .+"; then
28-
echo "status=✅ Good" >> $GITHUB_OUTPUT
29-
echo "message=PR title follows Conventional Commits format" >> $GITHUB_OUTPUT
30-
else
31-
echo "status=⚠️ Suggestion" >> $GITHUB_OUTPUT
32-
echo "message=Consider using format: type(scope): description. Valid types: feat, fix, docs, style, refactor, perf, test, chore, ci, security, build" >> $GITHUB_OUTPUT
33-
fi
34-
35-
- name: Calculate PR size and save results
36-
id: pr-size
37-
run: |
38-
ADDITIONS=${{ github.event.pull_request.additions }}
39-
DELETIONS=${{ github.event.pull_request.deletions }}
40-
TOTAL=$((ADDITIONS + DELETIONS))
41-
42-
if [ $TOTAL -lt 100 ]; then
43-
SIZE="🟢 Small"
44-
SUGGESTION=""
45-
elif [ $TOTAL -lt 500 ]; then
46-
SIZE="🟡 Medium"
47-
SUGGESTION=""
48-
else
49-
SIZE="🔴 Large"
50-
SUGGESTION="Consider breaking this into smaller PRs for easier review"
51-
fi
52-
53-
# Save all results to JSON file
54-
cat > pr-info.json <<EOF
55-
{
56-
"pr_number": ${{ github.event.pull_request.number }},
57-
"title_status": "${{ steps.check-title.outputs.status }}",
58-
"title_message": "${{ steps.check-title.outputs.message }}",
59-
"size": "$SIZE",
60-
"lines": $TOTAL,
61-
"size_suggestion": "$SUGGESTION"
62-
}
63-
EOF
64-
65-
cat pr-info.json
66-
67-
- name: Upload PR info results
68-
uses: actions/upload-artifact@v4
69-
with:
70-
name: pr-info-results
71-
path: pr-info.json
72-
retention-days: 1
73-
21+
# Backend advisory checks
22+
# Different from pr-checks.yml: these use continue-on-error and generate reports
7423
backend-checks:
7524
name: Backend Checks
7625
runs-on: ubuntu-latest
@@ -147,6 +96,8 @@ jobs:
14796
test-output-short.txt
14897
retention-days: 1
14998

99+
# Frontend advisory checks
100+
# Different from pr-checks.yml: these use continue-on-error and generate reports
150101
frontend-checks:
151102
name: Frontend Checks
152103
runs-on: ubuntu-latest
@@ -173,43 +124,18 @@ jobs:
173124
continue-on-error: true
174125
run: npm ci
175126

176-
- name: Run linter
177-
if: steps.check-web.outputs.exists == 'true'
178-
id: lint
179-
working-directory: ./web
180-
continue-on-error: true
181-
run: |
182-
if npm run lint 2>&1 | tee lint-output.txt; then
183-
echo "status=✅ Good" >> $GITHUB_OUTPUT
184-
else
185-
echo "status=⚠️ Issues found" >> $GITHUB_OUTPUT
186-
cat lint-output.txt | head -20 > lint-output-short.txt
187-
fi
188-
189-
- name: Type check
190-
if: steps.check-web.outputs.exists == 'true'
191-
id: typecheck
192-
working-directory: ./web
193-
continue-on-error: true
194-
run: |
195-
if npm run type-check 2>&1 | tee typecheck-output.txt; then
196-
echo "status=✅ Good" >> $GITHUB_OUTPUT
197-
else
198-
echo "status=⚠️ Issues found" >> $GITHUB_OUTPUT
199-
cat typecheck-output.txt | head -20 > typecheck-output-short.txt
200-
fi
201-
202-
- name: Build
127+
- name: Build and Type Check
203128
if: steps.check-web.outputs.exists == 'true'
204129
id: build
205130
working-directory: ./web
206131
continue-on-error: true
207132
run: |
133+
# build script includes: tsc && vite build
208134
if npm run build 2>&1 | tee build-output.txt; then
209135
echo "status=✅ Success" >> $GITHUB_OUTPUT
210136
else
211137
echo "status=⚠️ Failed" >> $GITHUB_OUTPUT
212-
cat build-output.txt | tail -20 > build-output-short.txt
138+
cat build-output.txt | tail -30 > build-output-short.txt
213139
fi
214140
215141
- name: Save frontend results
@@ -219,8 +145,6 @@ jobs:
219145
cat > frontend-results.json <<EOF
220146
{
221147
"pr_number": ${{ github.event.pull_request.number }},
222-
"lint_status": "${{ steps.lint.outputs.status }}",
223-
"typecheck_status": "${{ steps.typecheck.outputs.status }}",
224148
"build_status": "${{ steps.build.outputs.status }}"
225149
}
226150
EOF
@@ -232,7 +156,5 @@ jobs:
232156
name: frontend-results
233157
path: |
234158
web/frontend-results.json
235-
web/lint-output-short.txt
236-
web/typecheck-output-short.txt
237159
web/build-output-short.txt
238160
retention-days: 1

.github/workflows/pr-checks.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,18 @@ jobs:
193193
run: go mod download
194194

195195
- name: Run go fmt
196+
continue-on-error: true # Don't block PR if formatting issues found
196197
run: |
197198
if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then
198-
echo "Please run 'go fmt' on your code"
199+
echo "⚠️ Code formatting issues found. Please run 'go fmt ./...' locally."
200+
echo ""
201+
echo "Files needing formatting:"
199202
gofmt -s -l .
203+
echo ""
204+
echo "This is a warning and won't block your PR from being merged."
200205
exit 1
206+
else
207+
echo "✅ All Go files are properly formatted"
201208
fi
202209
203210
- name: Run go vet

0 commit comments

Comments
 (0)