Files
youtube-generator/.github/workflows/ci.yml
T
poli0981andClaude Opus 5.5 a70580e703 ci: security, licensing and style gates; pin every action by SHA
New checks
- security.yml: dependency-review blocks PRs that add a high/critical
  advisory; actionlint + zizmor lint the workflows themselves (template
  injection, permissions, credential persistence, unpinned uses); OpenSSF
  Scorecard weekly and on main (published, not uploaded as alerts).
- compliance.yml: REUSE lint over the whole repo (REUSE.toml + LICENSES/,
  no per-file headers) and Conventional-Commit PR titles.
- rust.yml (src-tauri changes + weekly): rustfmt, clippy -D warnings,
  cargo test, and cargo-deny for RustSec advisories, licenses and sources.
- ci.yml `check` gains: coverage thresholds (src/engine, worker),
  check:licenses, check:bundle, and a `wrangler deploy --dry-run`.

Licensing
- THIRD_PARTY_NOTICES.md is now generated from package.json, the installed
  packages and Cargo.toml/Cargo.lock (`npm run generate:third-party`); CI
  fails when it is stale or when anything bundled into the app carries a
  license outside the allowlist. It had drifted to React 18 / Vite 7 /
  Tailwind 3.
- Vite's build.license emits the full text of every bundled package's
  license to /licenses/third-party.md (served publicly, before the gate).

Bundle budget
- scripts/check-bundle-size.ts measures what CLAUDE.md's "500KB" never
  defined: initial load (everything index.html references) <= 280 KB gzip
  (197 KB today) and no JS chunk over 500 KB raw.

Coverage
- @vitest/coverage-v8; thresholds sit just under today's numbers. The
  engine is at 89% lines / 64% functions — not the 100% CLAUDE.md claimed.

Supply chain
- Every third-party action pinned to a commit SHA (Dependabot updates the
  SHA and its version comment); checkout never persists credentials.
- Release workflows: a `verify` job (typecheck, tests, version sync, Tauri
  alignment, tag == package version) gates the build; no dependency caches
  in release jobs; permissions granted per job.
- Reusable Discord workflows receive only the secrets they declare instead
  of `secrets: inherit` (which exposed the Android signing keys to them).
- Rust: cargo-deny found RUSTSEC-2026-0194/0195 (quick-xml DoS, via plist)
  that Dependabot had not raised; plist 1.10 brings quick-xml 0.41.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 19:46:24 +07:00

92 lines
3.7 KiB
YAML

name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
# Least privilege. The job only reads the repo — it publishes nothing, comments
# nowhere. Declaring it explicitly also silences CodeQL's
# `actions/missing-workflow-permissions`, which otherwise flags the implicit
# (and much wider) default token scope.
permissions:
contents: read
# A force-push or a quick follow-up commit makes the older run worthless. Cancel
# it instead of paying for both — except on `main`, where every commit's result
# is a historical record the release process reads back.
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
# `check` is the required status on `main` (ruleset "main-protection") — keep
# the job id stable.
check:
runs-on: ubuntu-latest
steps:
# Actions are pinned by commit SHA (a tag can be moved; a SHA cannot).
# Dependabot keeps the SHA and the version comment up to date.
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version-file: .node-version
cache: npm
- run: npm ci
# --- correctness ------------------------------------------------------
# `typecheck` covers src/ (what Vite builds); `typecheck:all` adds tests/,
# scripts/, worker/ and build-plugins/.
- name: Type check (src)
run: npm run typecheck
- name: Type check (tests, scripts, worker, build plugins)
run: npm run typecheck:all
- name: Lint
run: npm run lint
- name: Validate locales
run: npm run validate:locales
# Coverage thresholds for src/engine and worker live in vitest.config.ts.
- name: Test (with coverage thresholds)
run: npm run test:coverage
# --- consistency ------------------------------------------------------
- name: Check formatting
run: npm run format:check
- name: Check dead code
run: npm run knip
# The release ritual bumps SIX version fields by hand. This is the only
# thing that notices when one is missed — see scripts/check-version-sync.ts.
- name: Check version sync
run: npm run check:version
# tauri build refuses mismatched npm/crate minors, and CI never runs it.
- name: Check Tauri npm/crate alignment
run: npm run check:tauri
# --- licensing --------------------------------------------------------
# Every package bundled into the app has an allowed license, and
# THIRD_PARTY_NOTICES.md matches what is actually installed.
- name: Check licenses and third-party notices
run: npm run check:licenses
# --- security ---------------------------------------------------------
# Advisory-only: a fresh high-severity advisory in a transitive dep must
# not turn every unrelated PR red before Dependabot has had a chance to
# open its fix PR. The Dependabot alerts tab is the source of truth, and
# dependency-review (security.yml) blocks PRs that *introduce* one.
- name: Audit dependencies
run: npm audit --audit-level=high
continue-on-error: true
# --- build ------------------------------------------------------------
- name: Build
run: npm run build
- name: Check bundle budget
run: npm run check:bundle
# Validates wrangler.jsonc and bundles the Worker exactly as Workers
# Builds will — without deploying anything.
- name: Dry-run the Cloudflare deploy
run: npx wrangler deploy --dry-run --outdir .wrangler/dry-run