Elffuss BraidHub

kikocis/continue public

update compliance.yaml
Changesetcfcffe5b3a78880a76e353148384ccec45d3190fa2b822b6979bdd26dd7ff456
AuthorNate <sestinj@gmail.com> · 2025-07-07 12:37 -07:00
CommitterNate <sestinj@gmail.com> · 2025-07-07 12:37 -07:00
Parentsd2f16c35b8be

Browse the files at this changeset

2 files changed

added .github/workflows/compliance.yaml +196 −0
@@ -0,0 +1,196 @@
1+name: PR Compliance Checks
2+
3+on:
4+ pull_request:
5+ types: [opened, synchronize, reopened, ready_for_review]
6+ branches: [main]
7+ workflow_dispatch:
8+
9+concurrency:
10+ group: ${{ github.workflow }}-${{ github.ref }}
11+ cancel-in-progress: true
12+
13+jobs:
14+ conventional-commits:
15+ name: Validate Conventional Commits (Warning Only)
16+ runs-on: ubuntu-latest
17+ if: ${{ !github.event.pull_request.draft }}
18+ continue-on-error: true
19+ permissions:
20+ pull-requests: write
21+ issues: write
22+ contents: read
23+ steps:
24+ - name: Checkout code
25+ uses: actions/checkout@v4
26+ with:
27+ fetch-depth: 0
28+
29+ - name: Validate conventional commits
30+ uses: wagoid/commitlint-github-action@v6
31+ with:
32+ configFile: .commitlintrc.warning.json
33+ continue-on-error: true
34+
35+ - name: Add commit message guidance comment
36+ if: failure()
37+ uses: actions/github-script@v7
38+ with:
39+ script: |
40+ const { data: comments } = await github.rest.issues.listComments({
41+ owner: context.repo.owner,
42+ repo: context.repo.repo,
43+ issue_number: context.issue.number,
44+ });
45+
46+ const botComment = comments.find(comment =>
47+ comment.user.type === 'Bot' &&
48+ comment.body.includes('Conventional Commit Format')
49+ );
50+
51+ if (!botComment) {
52+ await github.rest.issues.createComment({
53+ owner: context.repo.owner,
54+ repo: context.repo.repo,
55+ issue_number: context.issue.number,
56+ body: [
57+ "## ⚠️ Conventional Commit Format",
58+ "",
59+ "Your commit messages don't follow the conventional commit format, but **this won't block your PR from being merged**.",
60+ "",
61+ "### Expected Format:",
62+ "```",
63+ "<type>[optional scope]: <description>",
64+ "",
65+ "[optional body]",
66+ "",
67+ "[optional footer(s)]",
68+ "```",
69+ "",
70+ "### Examples:",
71+ "- `feat: add changelog generation support`",
72+ "- `fix: resolve login redirect issue`",
73+ "- `docs: update README with new instructions`",
74+ "- `chore: update dependencies`",
75+ "",
76+ "### Valid Types:",
77+ "`feat`, `fix`, `docs`, `style`, `refactor`, `perf`, `test`, `build`, `ci`, `chore`, `revert`",
78+ "",
79+ "This helps with:",
80+ "- 📝 Automatic changelog generation",
81+ "- 🚀 Automated semantic versioning",
82+ "- 📊 Better project history tracking",
83+ "",
84+ "*This is a non-blocking warning - your PR can still be merged without fixing this.*"
85+ ].join('\n')
86+ });
87+ }
88+
89+ security-audit:
90+ name: Security Audit
91+ runs-on: ubuntu-latest
92+ if: ${{ !github.event.pull_request.draft }}
93+ permissions:
94+ security-events: write
95+ contents: read
96+ steps:
97+ - name: Checkout code
98+ uses: actions/checkout@v4
99+
100+ - name: Setup Node.js
101+ uses: actions/setup-node@v4
102+ with:
103+ node-version-file: ".nvmrc"
104+ cache: "npm"
105+
106+ - name: Install dependencies
107+ run: npm ci
108+
109+ - name: Fix vulnerabilities
110+ run: npm audit fix
111+
112+ - name: Run npm audit
113+ run: npm audit --audit-level=moderate
114+
115+ - name: Initialize CodeQL
116+ uses: github/codeql-action/init@v3
117+ with:
118+ languages: javascript
119+
120+ - name: Perform CodeQL Analysis
121+ uses: github/codeql-action/analyze@v3
122+
123+ # Use this for any files that we want to be certain exist
124+ # Basically creates a forcing function to discuss were anyone to want to remove them
125+ file-validation:
126+ name: Required Files Check
127+ runs-on: ubuntu-latest
128+ if: ${{ !github.event.pull_request.draft }}
129+ steps:
130+ - name: Checkout code
131+ uses: actions/checkout@v4
132+
133+ - name: Check required files
134+ run: |
135+ required_files=(
136+ "package.json"
137+ "package-lock.json"
138+ "README.md"
139+ "LICENSE"
140+ ".gitignore"
141+ "tsconfig.json"
142+ "SECURITY.md"
143+ "CONTRIBUTING.md"
144+ ".nvmrc"
145+ ".prettierrc"
146+ ".prettierignore"
147+ )
148+
149+ missing_files=()
150+ for file in "${required_files[@]}"; do
151+ if [[ ! -f "$file" ]]; then
152+ missing_files+=("$file")
153+ fi
154+ done
155+
156+ if [[ ${#missing_files[@]} -gt 0 ]]; then
157+ echo "❌ Missing required files:"
158+ printf '%s\n' "${missing_files[@]}"
159+ exit 1
160+ else
161+ echo "✅ All required files present"
162+ fi
163+
164+ compliance-summary:
165+ name: Compliance Summary
166+ runs-on: ubuntu-latest
167+ needs: [conventional-commits, security-audit, file-validation]
168+ if: always() && !github.event.pull_request.draft
169+ steps:
170+ - name: Check compliance status
171+ run: |
172+ echo "## 🔍 Compliance Check Results" >> $GITHUB_STEP_SUMMARY
173+ echo "" >> $GITHUB_STEP_SUMMARY
174+
175+ if [[ "${{ needs.conventional-commits.result }}" == "success" ]]; then
176+ echo "✅ Conventional Commits: PASSED" >> $GITHUB_STEP_SUMMARY
177+ elif [[ "${{ needs.conventional-commits.result }}" == "failure" ]]; then
178+ echo "⚠️ Conventional Commits: WARNING (non-blocking)" >> $GITHUB_STEP_SUMMARY
179+ else
180+ echo "❌ Conventional Commits: SKIPPED" >> $GITHUB_STEP_SUMMARY
181+ fi
182+
183+ if [[ "${{ needs.security-audit.result }}" == "success" ]]; then
184+ echo "✅ Security Audit: PASSED" >> $GITHUB_STEP_SUMMARY
185+ else
186+ echo "❌ Security Audit: FAILED" >> $GITHUB_STEP_SUMMARY
187+ fi
188+
189+ if [[ "${{ needs.file-validation.result }}" == "success" ]]; then
190+ echo "✅ File Validation: PASSED" >> $GITHUB_STEP_SUMMARY
191+ else
192+ echo "❌ File Validation: FAILED" >> $GITHUB_STEP_SUMMARY
193+ fi
194+
195+ echo "" >> $GITHUB_STEP_SUMMARY
196+ echo "📊 **Overall Status**: ${{ job.status }}" >> $GITHUB_STEP_SUMMARY
deleted .github/workflows/conventional-commit.yaml +0 −315
@@ -1,315 +0,0 @@
1-name: PR Compliance Checks
2-
3-on:
4- pull_request:
5- types: [opened, synchronize, reopened, ready_for_review]
6- branches: [main]
7- workflow_dispatch:
8-
9-concurrency:
10- group: ${{ github.workflow }}-${{ github.ref }}
11- cancel-in-progress: true
12-
13-jobs:
14- conventional-commits:
15- name: Validate Conventional Commits (Warning Only)
16- runs-on: ubuntu-latest
17- if: ${{ !github.event.pull_request.draft }}
18- continue-on-error: true
19- permissions:
20- pull-requests: write
21- issues: write
22- contents: read
23- steps:
24- - name: Checkout code
25- uses: actions/checkout@v4
26- with:
27- fetch-depth: 0
28-
29- - name: Validate conventional commits
30- uses: wagoid/commitlint-github-action@v6
31- with:
32- configFile: .commitlintrc.warning.json
33- continue-on-error: true
34-
35- - name: Add commit message guidance comment
36- if: failure()
37- uses: actions/github-script@v7
38- with:
39- script: |
40- const { data: comments } = await github.rest.issues.listComments({
41- owner: context.repo.owner,
42- repo: context.repo.repo,
43- issue_number: context.issue.number,
44- });
45-
46- const botComment = comments.find(comment =>
47- comment.user.type === 'Bot' &&
48- comment.body.includes('Conventional Commit Format')
49- );
50-
51- if (!botComment) {
52- await github.rest.issues.createComment({
53- owner: context.repo.owner,
54- repo: context.repo.repo,
55- issue_number: context.issue.number,
56- body: [
57- "## ⚠️ Conventional Commit Format",
58- "",
59- "Your commit messages don't follow the conventional commit format, but **this won't block your PR from being merged**.",
60- "",
61- "### Expected Format:",
62- "```",
63- "<type>[optional scope]: <description>",
64- "",
65- "[optional body]",
66- "",
67- "[optional footer(s)]",
68- "```",
69- "",
70- "### Examples:",
71- "- `feat: add changelog generation support`",
72- "- `fix: resolve login redirect issue`",
73- "- `docs: update README with new instructions`",
74- "- `chore: update dependencies`",
75- "",
76- "### Valid Types:",
77- "`feat`, `fix`, `docs`, `style`, `refactor`, `perf`, `test`, `build`, `ci`, `chore`, `revert`",
78- "",
79- "This helps with:",
80- "- 📝 Automatic changelog generation",
81- "- 🚀 Automated semantic versioning",
82- "- 📊 Better project history tracking",
83- "",
84- "*This is a non-blocking warning - your PR can still be merged without fixing this.*"
85- ].join('\n')
86- });
87- }
88-
89- code-quality:
90- name: Code Quality Checks
91- runs-on: ubuntu-latest
92- if: ${{ !github.event.pull_request.draft }}
93- steps:
94- - name: Checkout code
95- uses: actions/checkout@v4
96-
97- - name: Setup Node.js
98- uses: actions/setup-node@v4
99- with:
100- node-version: "20"
101- cache: "npm"
102-
103- - name: Install dependencies
104- run: npm ci
105-
106- - name: Run TypeScript type checking
107- run: npm run build
108-
109- - name: Debug environment
110- run: |
111- echo "Node version: $(node --version)"
112- echo "NPM version: $(npm --version)"
113- echo "Current directory: $(pwd)"
114- echo "Package.json type: $(node -p 'JSON.parse(require("fs").readFileSync("package.json", "utf8")).type')"
115- ls -la node_modules/@nivo/ || echo "@nivo not found"
116- ls -la node_modules/d3-interpolate/ || echo "d3-interpolate not found"
117-
118- - name: Run tests
119- run: npm test -- --coverage --passWithNoTests --reporter=verbose
120- env:
121- VITE_OPENAI_API_KEY: test-key-for-ci
122- NODE_OPTIONS: "--unhandled-rejections=strict"
123-
124- - name: Upload coverage reports
125- uses: codecov/codecov-action@v4
126- with:
127- file: ./coverage/lcov.info
128- fail_ci_if_error: false
129-
130- security-audit:
131- name: Security Audit
132- runs-on: ubuntu-latest
133- if: ${{ !github.event.pull_request.draft }}
134- permissions:
135- security-events: write
136- contents: read
137- steps:
138- - name: Checkout code
139- uses: actions/checkout@v4
140-
141- - name: Setup Node.js
142- uses: actions/setup-node@v4
143- with:
144- node-version: "20"
145- cache: "npm"
146-
147- - name: Install dependencies
148- run: npm ci
149-
150- - name: Fix vulnerabilities
151- run: npm audit fix
152-
153- - name: Run npm audit
154- run: npm audit --audit-level=moderate
155-
156- - name: Initialize CodeQL
157- uses: github/codeql-action/init@v3
158- with:
159- languages: javascript
160-
161- - name: Perform CodeQL Analysis
162- uses: github/codeql-action/analyze@v3
163-
164- bundle-size:
165- name: Bundle Size Impact
166- runs-on: ubuntu-latest
167- if: ${{ !github.event.pull_request.draft }}
168- steps:
169- - name: Checkout code
170- uses: actions/checkout@v4
171-
172- - name: Setup Node.js
173- uses: actions/setup-node@v4
174- with:
175- node-version: "20"
176- cache: "npm"
177-
178- - name: Install dependencies
179- run: npm ci
180-
181- - name: Build application
182- run: npm run build:prod
183-
184- - name: Analyze bundle size
185- run: |
186- echo "## Bundle Size Analysis" >> $GITHUB_STEP_SUMMARY
187- echo "" >> $GITHUB_STEP_SUMMARY
188-
189- # Get bundle sizes
190- if [ -d "dist" ]; then
191- echo "### JavaScript Bundles:" >> $GITHUB_STEP_SUMMARY
192- find dist -name "*.js" -not -name "*.map" -exec du -h {} \; | sort -hr | head -10 >> $GITHUB_STEP_SUMMARY
193-
194- echo "" >> $GITHUB_STEP_SUMMARY
195- echo "### CSS Bundles:" >> $GITHUB_STEP_SUMMARY
196- find dist -name "*.css" -exec du -h {} \; | sort -hr >> $GITHUB_STEP_SUMMARY
197-
198- echo "" >> $GITHUB_STEP_SUMMARY
199- echo "### Total Size:" >> $GITHUB_STEP_SUMMARY
200- du -sh dist >> $GITHUB_STEP_SUMMARY
201-
202- # Check if bundle sizes are reasonable (warn if JS > 2MB)
203- total_js_size=$(find dist -name "*.js" -not -name "*.map" -exec stat -c%s {} \; | awk '{sum+=$1} END {print sum}')
204- if [ "$total_js_size" -gt 2097152 ]; then
205- echo "⚠️ **Warning**: Total JavaScript bundle size is $(( total_js_size / 1024 / 1024 ))MB" >> $GITHUB_STEP_SUMMARY
206- else
207- echo "✅ Bundle size looks good!" >> $GITHUB_STEP_SUMMARY
208- fi
209- else
210- echo "❌ No dist folder found" >> $GITHUB_STEP_SUMMARY
211- fi
212-
213- file-validation:
214- name: Required Files Check
215- runs-on: ubuntu-latest
216- if: ${{ !github.event.pull_request.draft }}
217- steps:
218- - name: Checkout code
219- uses: actions/checkout@v4
220-
221- - name: Check required files
222- run: |
223- required_files=(
224- "package.json"
225- "README.md"
226- "LICENSE"
227- ".gitignore"
228- "tsconfig.json"
229- )
230-
231- missing_files=()
232- for file in "${required_files[@]}"; do
233- if [[ ! -f "$file" ]]; then
234- missing_files+=("$file")
235- fi
236- done
237-
238- if [[ ${#missing_files[@]} -gt 0 ]]; then
239- echo "❌ Missing required files:"
240- printf '%s\n' "${missing_files[@]}"
241- exit 1
242- else
243- echo "✅ All required files present"
244- fi
245-
246- pr-labels:
247- name: PR Label Management
248- runs-on: ubuntu-latest
249- if: ${{ !github.event.pull_request.draft }}
250- permissions:
251- pull-requests: write
252- contents: read
253- steps:
254- - name: Checkout code
255- uses: actions/checkout@v4
256-
257- - name: Auto-label PR based on changes
258- uses: actions/labeler@v5
259- with:
260- repo-token: ${{ secrets.GITHUB_TOKEN }}
261- configuration-path: .github/pr-labeler.yml
262-
263- compliance-summary:
264- name: Compliance Summary
265- runs-on: ubuntu-latest
266- needs:
267- [
268- conventional-commits,
269- code-quality,
270- security-audit,
271- bundle-size,
272- file-validation,
273- pr-labels,
274- ]
275- if: always() && !github.event.pull_request.draft
276- steps:
277- - name: Check compliance status
278- run: |
279- echo "## 🔍 Compliance Check Results" >> $GITHUB_STEP_SUMMARY
280- echo "" >> $GITHUB_STEP_SUMMARY
281-
282- if [[ "${{ needs.conventional-commits.result }}" == "success" ]]; then
283- echo "✅ Conventional Commits: PASSED" >> $GITHUB_STEP_SUMMARY
284- elif [[ "${{ needs.conventional-commits.result }}" == "failure" ]]; then
285- echo "⚠️ Conventional Commits: WARNING (non-blocking)" >> $GITHUB_STEP_SUMMARY
286- else
287- echo "❌ Conventional Commits: SKIPPED" >> $GITHUB_STEP_SUMMARY
288- fi
289-
290- if [[ "${{ needs.code-quality.result }}" == "success" ]]; then
291- echo "✅ Code Quality: PASSED" >> $GITHUB_STEP_SUMMARY
292- else
293- echo "❌ Code Quality: FAILED" >> $GITHUB_STEP_SUMMARY
294- fi
295-
296- if [[ "${{ needs.security-audit.result }}" == "success" ]]; then
297- echo "✅ Security Audit: PASSED" >> $GITHUB_STEP_SUMMARY
298- else
299- echo "❌ Security Audit: FAILED" >> $GITHUB_STEP_SUMMARY
300- fi
301-
302- if [[ "${{ needs.bundle-size.result }}" == "success" ]]; then
303- echo "✅ Bundle Size: PASSED" >> $GITHUB_STEP_SUMMARY
304- else
305- echo "❌ Bundle Size: FAILED" >> $GITHUB_STEP_SUMMARY
306- fi
307-
308- if [[ "${{ needs.file-validation.result }}" == "success" ]]; then
309- echo "✅ File Validation: PASSED" >> $GITHUB_STEP_SUMMARY
310- else
311- echo "❌ File Validation: FAILED" >> $GITHUB_STEP_SUMMARY
312- fi
313-
314- echo "" >> $GITHUB_STEP_SUMMARY
315- echo "📊 **Overall Status**: ${{ job.status }}" >> $GITHUB_STEP_SUMMARY