|
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.yml` |
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 | +**Triggers:** push/PR when `SortVision/**` or this workflow changes; weekly schedule. |
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 | +JavaScript/TypeScript analysis scoped to `SortVision` via [`codeql-config.yml`](../codeql/codeql-config.yml). |
60 | 40 |
|
61 | | -## Artifacts |
| 41 | +### `typos.yml` |
62 | 42 |
|
63 | | -### Retention Periods: |
64 | | -- Test results: 30 days |
65 | | -- Security audits: 90 days |
66 | | -- Lighthouse reports: Permanent (via temporary public storage) |
| 43 | +**Triggers:** push/PR when `SortVision/**`, [`_typos.toml`](../../_typos.toml), or this workflow changes. |
67 | 44 |
|
68 | | -## Status Badges |
| 45 | +Spell check using [typos](https://github.com/crate-ci/typos); large i18n and lockfiles are excluded in [`_typos.toml`](../../_typos.toml). |
69 | 46 |
|
70 | | -Add to README.md: |
| 47 | +### `dependabot-auto-merge.yml` |
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 | +Auto-merge rules for Dependabot PRs (repository-specific). |
82 | 50 |
|
83 | | -### Timeouts: |
84 | | -- Quality Assurance: 30 minutes |
85 | | -- Lighthouse: 15 minutes |
86 | | -- Production Validation: 10 minutes |
87 | | -- Security Scan: 10 minutes |
| 51 | +## Branch protection |
88 | 52 |
|
89 | | -## Local Testing |
| 53 | +Required status check names must match each job’s `name:` field exactly (for example **Formatting**, **Lint**, **Build and test**, **Typos**, **Analyze (JavaScript)**). |
90 | 54 |
|
91 | | -Run tests locally: |
| 55 | +## Adding more checks |
92 | 56 |
|
93 | | -```bash |
94 | | -# Complete test suite |
95 | | -npm test |
| 57 | +- **Default PR path:** extend [`continuous-integration.yml`](continuous-integration.yml) or add a job with `needs:` as appropriate. |
| 58 | +- **Nightly / manual only:** use [`extended-quality-assurance.yml`](extended-quality-assurance.yml) or a new workflow file. |
| 59 | +- **Security:** prefer [`security-scan.yml`](security-scan.yml) or CodeQL-related config under `.github/codeql/`. |
96 | 60 |
|
97 | | -# Quick validation (30 tests) |
98 | | -npm run test:quick |
| 61 | +**Not configured here (optional later):** Knip/depcheck for unused exports, Playwright E2E — useful once you want the extra maintenance cost. |
99 | 62 |
|
100 | | -# Production validation |
101 | | -npm run test:prod |
| 63 | +## Badges |
102 | 64 |
|
103 | | -# Other checks |
104 | | -npm run lint |
105 | | -npm run build |
106 | | -npm run generate-sitemap |
107 | | -npm audit --production |
| 65 | +```markdown |
| 66 | + |
| 67 | + |
| 68 | + |
108 | 69 | ``` |
109 | 70 |
|
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` |
116 | | - |
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 |
| 71 | +## Local parity |
122 | 72 |
|
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 |
| 73 | +```bash |
| 74 | +cd SortVision |
| 75 | +pnpm run format:check && pnpm run lint && pnpm run build && pnpm test |
| 76 | +``` |
0 commit comments