diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..9b50e126 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,81 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [20] + + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Set up Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + + - name: Cache npm directory + uses: actions/cache@v4 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ matrix.node-version }}-npm-${{ hashFiles('package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node-${{ matrix.node-version }}-npm- + + - name: Cache node_modules + id: node-modules-cache + uses: actions/cache@v4 + with: + path: node_modules + key: ${{ runner.os }}-node-${{ matrix.node-version }}-modules-${{ hashFiles('package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node-${{ matrix.node-version }}-modules- + + - name: Install dependencies + if: steps.node-modules-cache.outputs.cache-hit != 'true' + run: npm ci + + - name: Install ripgrep + run: sudo apt-get update && sudo apt-get install -y ripgrep + + - name: Run lint suite + run: npm run lint + + - name: Build CSS + run: npm run build:css + + - name: Install Playwright browsers + run: npx playwright install --with-deps chromium + + - name: Run visual regression tests + id: visual + run: npm run test:visual + continue-on-error: true + + - name: Upload Playwright artifacts + if: steps.visual.outcome == 'failure' + uses: actions/upload-artifact@v4 + with: + name: playwright-visual-diffs + path: | + playwright-report + test-results + if-no-files-found: ignore + + - name: Run unit tests + run: npm run test:unit + + - name: Check CSS artifacts are clean + run: npm run check:css + + - name: Fail if visual regressions detected + if: steps.visual.outcome == 'failure' + run: exit 1 diff --git a/.gitignore b/.gitignore index c26cbea6..a8ebf016 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,6 @@ saved_config.yaml repo-context.txt node_modules/ src/webtorrent-docs/ +playwright-report/ +test-results/ +tests/visual/__snapshots__/ diff --git a/AGENTS.md b/AGENTS.md index ba606920..78007417 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,6 +1,6 @@ -# Bitvid — AI Agent Guide +# bitvid — AI Agent Guide -This guide tells AI agents how to keep Bitvid aligned with the current product direction. Follow it whenever you touch code, content, or documentation inside this repository. +This guide tells AI agents how to keep bitvid aligned with the current product direction. Follow it whenever you touch code, content, or documentation inside this repository. --- @@ -10,13 +10,31 @@ This guide tells AI agents how to keep Bitvid aligned with the current product d * **Unstable** is our experimentation lane. Gate risky behavior behind feature flags defined in `js/constants.js` and document the toggle/rollback plan in PR descriptions. * **Emergency response:** If a change regresses URL-first playback or breaks magnet parsing, revert immediately, call this out in the PR, and annotate the AGENTS.md changelog with remediation tips. **Note:** These regressions usually surface in dev logs and tests around playback/magnet helpers—reference them when triaging so future agents don’t repeat the mistake. +### Browser logging policy + +* Route every browser log through `js/utils/logger.js`. Do **not** call `console.*` directly. +* Use `logger.dev.*` for diagnostics that should disappear in production (flagged by `IS_DEV_MODE`/`isDevMode`). Use `logger.user.*` for operator-facing warnings and errors that must reach production consoles. +* Before promoting a build, flip `IS_DEV_MODE` in `config/instance-config.js` to match the target environment so `window.__BITVID_DEV_MODE__` and the logger channels behave correctly. +* Review and follow [`docs/logging.md`](docs/logging.md) whenever you add new logging or touch inline scripts. + ## 2. Mission: URL‑First Playback with WebTorrent Fallback * **Goal:** Always deliver smooth playback while keeping hosting costs low. * **Primary transport:** A hosted video URL (MP4/WebM/HLS/DASH) that the `