|
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`. On **pull requests**, writes [`qa-pr-comment`](qa-pr-comment.yml) artifacts (summary markdown + PR number). | |
| 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 | +### `qa-pr-comment.yml` |
30 | 22 |
|
31 | | -### 2. Security Scan (`security-scan.yml`) |
| 23 | +**Triggers:** `workflow_run` when **Continuous integration** completes. |
32 | 24 |
|
33 | | -**Triggers:** |
34 | | -- Push/PR to main, master, develop |
35 | | -- Weekly schedule (Sunday midnight) |
| 25 | +Downloads the **qa-pr-comment** artifact from that run and **creates or updates** one PR comment with the QA suite table (pass/fail, grade, failed-test excerpt). Uses the same sticky-comment pattern as artifact-driven reporting workflows. **Do not** add this workflow as a required status check. |
36 | 26 |
|
37 | | -**Jobs:** |
38 | | -- Dependency vulnerability scan |
39 | | -- Secret detection |
40 | | -- Security audit report generation |
| 27 | +### `extended-quality-assurance.yml` |
41 | 28 |
|
42 | | -## Test Suite |
| 29 | +**Triggers:** nightly (`0 2 * * *` UTC), `workflow_dispatch`. |
43 | 30 |
|
44 | | -Single comprehensive test file: `tests/quality-assurance.mjs` |
| 31 | +Longer validation: format, lint, build, `pnpm run test:extended`, sitemap, **pnpm audit** (fails on high/critical for production deps), bundle notes, artifacts. |
45 | 32 |
|
46 | | -### Test Modes: |
| 33 | +### `security-scan.yml` |
47 | 34 |
|
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 | |
| 35 | +**Triggers:** push/PR, **merge queue** (`merge_group`), weekly schedule. |
53 | 36 |
|
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 |
| 37 | +- **pnpm audit** for production dependencies: **fails on high and critical** (moderate/low: review locally or via Dependabot). |
| 38 | +- **TruffleHog** (pinned release) for verified secrets. |
| 39 | +- **Dependency review** on pull requests (`fail-on-severity: moderate`). |
60 | 40 |
|
61 | | -## Artifacts |
| 41 | +### CodeQL (GitHub default setup) |
62 | 42 |
|
63 | | -### Retention Periods: |
64 | | -- Test results: 30 days |
65 | | -- Security audits: 90 days |
66 | | -- Lighthouse reports: Permanent (via temporary public storage) |
| 43 | +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)`). |
67 | 44 |
|
68 | | -## Status Badges |
| 45 | +### `typos.yml` |
69 | 46 |
|
70 | | -Add to README.md: |
| 47 | +**Triggers:** PR (path-filtered), push (path-filtered), **merge queue** (`merge_group`). Path filters do not apply to `merge_group` (GitHub runs the full workflow for the queued merge ref). |
71 | 48 |
|
72 | | -```markdown |
73 | | - |
74 | | - |
75 | | -``` |
| 49 | +Spell check using [typos](https://github.com/crate-ci/typos); large i18n and lockfiles are excluded in [`_typos.toml`](../../_typos.toml). |
76 | 50 |
|
77 | | -## Configuration |
| 51 | +### `dependabot-auto-merge.yml` |
78 | 52 |
|
79 | | -### Environment Variables: |
80 | | -- `NODE_VERSION`: '22' |
81 | | -- `NEXT_PUBLIC_SITE_URL`: https://www.sortvision.com |
| 53 | +Runs **after** [`Continuous integration`](continuous-integration.yml) completes successfully (`workflow_run`), resolves the PR from the CI commit, and enables **`gh pr merge --auto --squash`** only when the PR author is Dependabot (**`dependabot[bot]`** or **`app/dependabot`**). GitHub then merges once **all** required checks (including Typos, Security Scan, CodeQL, etc.) pass. |
82 | 54 |
|
83 | | -### Timeouts: |
84 | | -- Quality Assurance: 30 minutes |
85 | | -- Lighthouse: 15 minutes |
86 | | -- Production Validation: 10 minutes |
87 | | -- Security Scan: 10 minutes |
| 55 | +**Do not** add this workflow as a **required** status check (it would run after other checks, not in parallel with them in a useful way). |
88 | 56 |
|
89 | | -## Local Testing |
| 57 | +**Note:** The old `dependabot/fetch-metadata` patch/minor/dev-only filters were removed here because that action only works on `pull_request` events. Tighten what Dependabot opens via [`.github/dependabot.yml`](../../dependabot.yml) (groups, ignore, `update-types`) instead. |
90 | 58 |
|
91 | | -Run tests locally: |
| 59 | +## Merge queue (GitHub `merge_group`) |
92 | 60 |
|
93 | | -```bash |
94 | | -# Complete test suite |
95 | | -npm test |
| 61 | +Merge queue uses a **temporary branch** (ref like `refs/heads/gh-readonly-queue/...`) that combines **target branch + one or more queued PRs**. CI must run on that ref, not only on the PR’s branch, or required checks never complete in the queue. |
96 | 62 |
|
97 | | -# Quick validation (30 tests) |
98 | | -npm run test:quick |
| 63 | +**In this repo**, these workflows include `merge_group: types: [checks_requested]`: |
99 | 64 |
|
100 | | -# Production validation |
101 | | -npm run test:prod |
| 65 | +- [`continuous-integration.yml`](continuous-integration.yml) (already had it) |
| 66 | +- [`typos.yml`](typos.yml) |
| 67 | +- [`security-scan.yml`](security-scan.yml) — audit + TruffleHog run; **Dependency Review** stays `pull_request`-only by design. |
102 | 68 |
|
103 | | -# Other checks |
104 | | -npm run lint |
105 | | -npm run build |
106 | | -npm run generate-sitemap |
107 | | -npm audit --production |
108 | | -``` |
| 69 | +**Not** run on merge queue: [`extended-quality-assurance.yml`](extended-quality-assurance.yml) (scheduled/manual only) — too heavy for every queue entry. |
| 70 | + |
| 71 | +**How “PR tests” vs “merge queue tests” relate:** Each PR still gets normal `pull_request` runs. When you click **Merge when ready**, GitHub runs required checks again on the **merge group** commit (integration of `main` + your change, and possibly other queued PRs depending on queue mode). One green merge-group run can clear the next merge for batched queues; if something fails, the queue is blocked or that PR is dropped per GitHub’s rules. |
109 | 72 |
|
110 | | -## Troubleshooting |
| 73 | +**Enable in GitHub:** **Settings → Rules** (ruleset on `main`) → enable **Merge queue** → choose **Merge method** → list the **same** required status checks as for pull requests. After the first merge-group run, confirm check names match **Settings → Rules** (search for checks). |
111 | 74 |
|
112 | | -### Build Failures: |
113 | | -1. Check Node version (requires 22+) |
114 | | -2. Clear cache: `npm ci` |
115 | | -3. Verify dependencies: `npm audit` |
| 75 | +## Branch protection |
116 | 76 |
|
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 |
| 77 | +Required status check names must match each job’s `name:` field exactly (for example **Formatting**, **Lint**, **Build and test**, **Typos**, **Security Vulnerability Scan**). Add CodeQL-related checks only if you require them, using the exact names from **Settings → Rules** after a green run. |
122 | 78 |
|
123 | | -### Production Validation Failures: |
124 | | -1. Verify site is deployed |
125 | | -2. Check DNS resolution |
126 | | -3. Test manually: `curl https://www.sortvision.com` |
| 79 | +## Adding more checks |
127 | 80 |
|
128 | | -## Maintenance |
| 81 | +- **Default PR path:** extend [`continuous-integration.yml`](continuous-integration.yml) or add a job with `needs:` as appropriate. |
| 82 | +- **Nightly / manual only:** use [`extended-quality-assurance.yml`](extended-quality-assurance.yml) or a new workflow file. |
| 83 | +- **Security:** prefer [`security-scan.yml`](security-scan.yml); CodeQL is managed in **Settings → Code scanning** (default setup). |
129 | 84 |
|
130 | | -### Weekly: |
131 | | -- Review security scan results |
132 | | -- Check for dependency updates |
| 85 | +**Not configured here (optional later):** Knip/depcheck for unused exports, Playwright E2E — useful once you want the extra maintenance cost. |
133 | 86 |
|
134 | | -### Monthly: |
135 | | -- Review Lighthouse trends |
136 | | -- Analyze bundle size changes |
137 | | -- Update workflow versions |
| 87 | +## Badges |
138 | 88 |
|
139 | | -## Contact |
| 89 | +```markdown |
| 90 | + |
| 91 | + |
| 92 | +``` |
| 93 | + |
| 94 | +## Local parity |
140 | 95 |
|
141 | | -For CI/CD issues, check: |
142 | | -1. GitHub Actions logs |
143 | | -2. Uploaded artifacts |
144 | | -3. GITHUB_STEP_SUMMARY reports |
| 96 | +```bash |
| 97 | +cd SortVision |
| 98 | +pnpm run format:check && pnpm run lint && pnpm run build && pnpm test |
| 99 | +``` |
0 commit comments