|
1 | | -# CI/CD Workflows |
| 1 | +# SortVision — GitHub Actions |
2 | 2 |
|
3 | | -Automated quality assurance and deployment pipelines for SortVision. |
| 3 | +Workflows are split by responsibility. **Node.js 24** is used in CI to match [`SortVision/package.json` engines](../../SortVision/package.json). Third-party actions are pinned to **commit SHAs** (comments note the tag) for reproducible builds. |
4 | 4 |
|
5 | 5 | ## Workflows |
6 | 6 |
|
7 | | -### 1. Quality Assurance Pipeline (`quality-assurance.yml`) |
| 7 | +### `continuous-integration.yml` |
8 | 8 |
|
9 | | -**Triggers:** Push/PR to main, master, develop branches |
| 9 | +**Triggers:** pull request, push to `main` / `master` / `develop`, merge queue, manual dispatch. |
10 | 10 |
|
11 | | -**Jobs:** |
12 | | -- **quality-assurance** (30min timeout) |
13 | | - - Code linting |
14 | | - - Application build |
15 | | - - Comprehensive test suite (600+ tests) |
16 | | - - SEO validation and sitemap generation |
17 | | - - Security audit |
18 | | - - Bundle size analysis |
| 11 | +| Job | Purpose | |
| 12 | +|-----|---------| |
| 13 | +| **Formatting** | Prettier (`pnpm run format:check`) | |
| 14 | +| **Lint** | ESLint | |
| 15 | +| **Build and test** | After format + lint: Next.js build, dev server, `pnpm test` | |
| 16 | +| **Lighthouse** | After format + lint: production build, Lighthouse on key URLs; assertions live in [`SortVision/lighthouserc.json`](../../SortVision/lighthouserc.json) | |
| 17 | +| **Production validation** | On `main` / `master` only, after build/test: production smoke tests and HTTP checks | |
19 | 18 |
|
20 | | -- **lighthouse-audit** (Parallel, 15min timeout) |
21 | | - - Lighthouse performance tests on 4 key pages |
22 | | - - Automated performance scoring |
23 | | - - Artifact upload for historical tracking |
| 19 | +Shared setup: [`setup-sortvision`](../actions/setup-sortvision/action.yml) (pnpm, Node, `pnpm install`). |
24 | 20 |
|
25 | | -- **production-validation** (Only on main/master, 10min timeout) |
26 | | - - Production site health check |
27 | | - - Production test suite (58 tests) |
28 | | - - Response time validation |
29 | | - - HTTP status verification |
| 21 | +### `extended-quality-assurance.yml` |
30 | 22 |
|
31 | | -### 2. Security Scan (`security-scan.yml`) |
| 23 | +**Triggers:** nightly (`0 2 * * *` UTC), `workflow_dispatch`. |
32 | 24 |
|
33 | | -**Triggers:** |
34 | | -- Push/PR to main, master, develop |
35 | | -- Weekly schedule (Sunday midnight) |
| 25 | +Longer validation: format, lint, build, `pnpm run test:extended`, sitemap, **pnpm audit** (fails on high/critical for production deps), bundle notes, artifacts. |
36 | 26 |
|
37 | | -**Jobs:** |
38 | | -- Dependency vulnerability scan |
39 | | -- Secret detection |
40 | | -- Security audit report generation |
| 27 | +### `security-scan.yml` |
41 | 28 |
|
42 | | -## Test Suite |
| 29 | +**Triggers:** push/PR, weekly schedule. |
43 | 30 |
|
44 | | -Single comprehensive test file: `tests/quality-assurance.mjs` |
| 31 | +- **pnpm audit** for production dependencies: **fails on high and critical** (moderate/low: review locally or via Dependabot). |
| 32 | +- **TruffleHog** (pinned release) for verified secrets. |
| 33 | +- **Dependency review** on pull requests (`fail-on-severity: moderate`). |
45 | 34 |
|
46 | | -### Test Modes: |
| 35 | +### CodeQL (GitHub default setup) |
47 | 36 |
|
48 | | -| Command | Tests | Description | |
49 | | -|---------|-------|-------------| |
50 | | -| `npm test` | 600+ | Complete suite (localhost) | |
51 | | -| `npm run test:quick` | 30 | Quick validation only | |
52 | | -| `npm run test:prod` | 100+ | Production validation | |
| 37 | +This repo does **not** use a custom `codeql.yml` workflow. Enable **Code scanning** with **Default setup** under **Settings → Code security and analysis → Code scanning**. Results and status appear under the **Security** tab; required checks (if any) use the names GitHub shows for that setup (not the old workflow job `Analyze (JavaScript)`). |
53 | 38 |
|
54 | | -### Coverage: |
55 | | -- **Quick Validation** (30 tests): Core pages, SEO files, sample algorithms |
56 | | -- **Comprehensive** (200 tests): All languages × all algorithms × all tabs |
57 | | -- **Integration** (250 tests): Extended core, deep SEO, security, headers, edge cases |
58 | | -- **Performance** (120 tests): Multi-run performance validation across all languages |
59 | | -- **Total:** 600+ tests |
| 39 | +### `typos.yml` |
60 | 40 |
|
61 | | -## Artifacts |
| 41 | +**Triggers:** push/PR when `SortVision/**`, [`_typos.toml`](../../_typos.toml), or this workflow changes. |
62 | 42 |
|
63 | | -### Retention Periods: |
64 | | -- Test results: 30 days |
65 | | -- Security audits: 90 days |
66 | | -- Lighthouse reports: Permanent (via temporary public storage) |
| 43 | +Spell check using [typos](https://github.com/crate-ci/typos); large i18n and lockfiles are excluded in [`_typos.toml`](../../_typos.toml). |
67 | 44 |
|
68 | | -## Status Badges |
| 45 | +### `dependabot-auto-merge.yml` |
69 | 46 |
|
70 | | -Add to README.md: |
| 47 | +Auto-merge rules for Dependabot PRs (repository-specific). |
71 | 48 |
|
72 | | -```markdown |
73 | | - |
74 | | - |
75 | | -``` |
76 | | - |
77 | | -## Configuration |
78 | | - |
79 | | -### Environment Variables: |
80 | | -- `NODE_VERSION`: '22' |
81 | | -- `NEXT_PUBLIC_SITE_URL`: https://www.sortvision.com |
| 49 | +## Branch protection |
82 | 50 |
|
83 | | -### Timeouts: |
84 | | -- Quality Assurance: 30 minutes |
85 | | -- Lighthouse: 15 minutes |
86 | | -- Production Validation: 10 minutes |
87 | | -- Security Scan: 10 minutes |
| 51 | +Required status check names must match each job’s `name:` field exactly (for example **Formatting**, **Lint**, **Build and test**, **Typos**). Add CodeQL-related checks only if you require them, using the exact names from **Settings → Rules** after a green run. |
88 | 52 |
|
89 | | -## Local Testing |
| 53 | +## Adding more checks |
90 | 54 |
|
91 | | -Run tests locally: |
| 55 | +- **Default PR path:** extend [`continuous-integration.yml`](continuous-integration.yml) or add a job with `needs:` as appropriate. |
| 56 | +- **Nightly / manual only:** use [`extended-quality-assurance.yml`](extended-quality-assurance.yml) or a new workflow file. |
| 57 | +- **Security:** prefer [`security-scan.yml`](security-scan.yml); CodeQL is managed in **Settings → Code scanning** (default setup). |
92 | 58 |
|
93 | | -```bash |
94 | | -# Complete test suite |
95 | | -npm test |
96 | | - |
97 | | -# Quick validation (30 tests) |
98 | | -npm run test:quick |
| 59 | +**Not configured here (optional later):** Knip/depcheck for unused exports, Playwright E2E — useful once you want the extra maintenance cost. |
99 | 60 |
|
100 | | -# Production validation |
101 | | -npm run test:prod |
| 61 | +## Badges |
102 | 62 |
|
103 | | -# Other checks |
104 | | -npm run lint |
105 | | -npm run build |
106 | | -npm run generate-sitemap |
107 | | -npm audit --production |
| 63 | +```markdown |
| 64 | + |
| 65 | + |
108 | 66 | ``` |
109 | 67 |
|
110 | | -## Troubleshooting |
111 | | - |
112 | | -### Build Failures: |
113 | | -1. Check Node version (requires 22+) |
114 | | -2. Clear cache: `npm ci` |
115 | | -3. Verify dependencies: `npm audit` |
| 68 | +## Local parity |
116 | 69 |
|
117 | | -### Test Failures: |
118 | | -1. Ensure dev server starts: `npm run dev` |
119 | | -2. Check port 3000 is free |
120 | | -3. Review test output for details |
121 | | -4. Check specific failed URLs |
122 | | - |
123 | | -### Production Validation Failures: |
124 | | -1. Verify site is deployed |
125 | | -2. Check DNS resolution |
126 | | -3. Test manually: `curl https://www.sortvision.com` |
127 | | - |
128 | | -## Maintenance |
129 | | - |
130 | | -### Weekly: |
131 | | -- Review security scan results |
132 | | -- Check for dependency updates |
133 | | - |
134 | | -### Monthly: |
135 | | -- Review Lighthouse trends |
136 | | -- Analyze bundle size changes |
137 | | -- Update workflow versions |
138 | | - |
139 | | -## Contact |
140 | | - |
141 | | -For CI/CD issues, check: |
142 | | -1. GitHub Actions logs |
143 | | -2. Uploaded artifacts |
144 | | -3. GITHUB_STEP_SUMMARY reports |
| 70 | +```bash |
| 71 | +cd SortVision |
| 72 | +pnpm run format:check && pnpm run lint && pnpm run build && pnpm test |
| 73 | +``` |
0 commit comments