Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,14 @@ jobs:
bun-version: 1.4.0
- run: bun install --frozen-lockfile
- run: bun run build
- run: bunx --no-install playwright install --with-deps chromium
- run: bun run test:browser
- name: Upload browser report
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: browser-report
path: |
playwright-report/
test-results/
retention-days: 7
30 changes: 30 additions & 0 deletions .github/workflows/starlight-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Update shared Starlight

on:
repository_dispatch:
types: [starlight-release]
workflow_dispatch:
inputs:
version:
description: Published stable Starlight version (x.y.z)
required: true
type: string

permissions:
contents: read
packages: read

jobs:
update:
if: >-
(github.event_name == 'repository_dispatch' &&
github.event.client_payload.package == '@tech0ver/starlight') ||
(github.event_name == 'workflow_dispatch' &&
github.ref == format('refs/heads/{0}', github.event.repository.default_branch))
uses: tech0ver/starlight/.github/workflows/update-consumer.yml@343a40df718723aed65150befe6e323f0b7bac98
with:
version: ${{ github.event.client_payload.version || inputs.version }}
release-url: ${{ github.event.client_payload.release_url || '' }}
secrets:
UPDATE_APP_ID: ${{ secrets.UPDATE_APP_ID }}
UPDATE_APP_PRIVATE_KEY: ${{ secrets.UPDATE_APP_PRIVATE_KEY }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# build output
dist/
playwright-report/
test-results/
# generated types
.astro/

Expand Down
37 changes: 32 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,39 @@ production preview to check search results.

## Shared UI updates

Update `@tech0ver/starlight` in `package.json` and `bun.lock`, then rebuild.
Use the peer dependency versions documented by that release. Site settings are
in `astro.config.mjs`; articles, glossary entries, diagrams, and site extensions
stay in this repository. Shared visual changes belong in the package.
After a successful package publication, Starlight sends a `starlight-release`
event to this repository. **Update shared Starlight** calls the shared updater
pinned in `.github/workflows/starlight-update.yml`. It opens a PR with the package
version, required peer dependency versions, and `bun.lock`. Run the same workflow
manually from `main` with a published version to retry an update. Repeated events
do not create duplicate PRs or downgrade the dependency. Review release notes and
any migration before approving; updates do not merge automatically.

The receiver must be on the default branch. Configure Actions secrets
`UPDATE_APP_ID` and `UPDATE_APP_PRIVATE_KEY` for the update GitHub App, installed
on this repository with **Contents: Read and write** and **Pull requests: Read
and write** permissions. Organization secrets can be shared with selected
repositories. See the [Starlight rollout instructions](https://github.com/tech0ver/starlight/blob/main/WORKFLOW.md#consumer-update-notifications)
for publisher setup and enabling delivery after the receiver is ready.

To update manually, change `@tech0ver/starlight` in `package.json` and `bun.lock`
using the peer dependency versions documented by that release, then rebuild.
Site settings are in `astro.config.mjs`; articles, glossary entries, diagrams,
and site extensions stay in this repository. Shared visual changes belong in
the package.

Pull requests run a frozen install, production build, and Chromium checks on
desktop and mobile in light and dark themes. The checks cover the home page,
articles, glossary, Markdown exports, search, theme persistence, navigation, and
browser errors. Run them against a fresh production build locally:

Pull requests run a frozen install and production build. GitHub Actions uses
```sh
bunx --no-install playwright install --with-deps chromium
bun run build
bun run test:browser
```

Failed CI runs upload a browser report with screenshots and traces. GitHub Actions uses
`GITHUB_TOKEN` with `packages: read`; this repository must have read access under
the package's **Manage Actions access** settings. Pushes to `main` build and
deploy to GitHub Pages.
7 changes: 7 additions & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"dev": "astro dev",
"build": "astro build",
"preview": "astro preview",
"test:browser": "playwright test",
"astro": "astro",
"skills": "skills",
"skills:list": "skills list --agent codex claude-code",
Expand All @@ -19,6 +20,7 @@
"sharp": "^0.35.3"
},
"devDependencies": {
"@playwright/test": "1.64.1",
"skills": "1.7.4"
}
}
30 changes: 30 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { defineConfig } from '@playwright/test';

export default defineConfig({
testDir: './tests/browser',
fullyParallel: true,
forbidOnly: Boolean(process.env.CI),
workers: process.env.CI ? 2 : undefined,
reporter: [['list'], ['html', { open: 'never' }]],
use: {
baseURL: 'http://127.0.0.1:4322/sysdes/',
browserName: 'chromium',
trace: 'retain-on-failure',
screenshot: 'only-on-failure',
},
projects: (['light', 'dark'] as const).flatMap((colorScheme) => [
{
name: `desktop-${colorScheme}`,
use: { viewport: { width: 1440, height: 900 }, colorScheme },
},
{
name: `mobile-${colorScheme}`,
use: { viewport: { width: 393, height: 851 }, isMobile: true, hasTouch: true, colorScheme },
},
]),
webServer: {
command: 'bun run preview --host 127.0.0.1 --port 4322 --ignore-lock',
url: 'http://127.0.0.1:4322/sysdes/',
reuseExistingServer: false,
},
});
78 changes: 78 additions & 0 deletions tests/browser/site.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import { test as base, expect } from '@playwright/test';

const test = base.extend({
page: async ({ page }, use) => {
const errors: string[] = [];
page.on('pageerror', (error) => errors.push(error.message));
page.on('console', (message) => {
if (message.type() === 'error') errors.push(message.text());
});
page.on('response', (response) => {
if (response.url().startsWith('http://127.0.0.1:4322/') && response.status() >= 400) {
errors.push(`${response.status()} ${response.url()}`);
}
});
// Keep checks independent of analytics availability and avoid sending test visits.
await page.route('https://www.googletagmanager.com/**', (route) =>
route.fulfill({ contentType: 'application/javascript', body: '' }));
await page.route('https://**.google-analytics.com/**', (route) =>
route.fulfill({ status: 204 }));
await use(page);
expect(errors, 'Browser errors and missing local assets').toEqual([]);
},
});

test('home, article, glossary, and article exports work under the site base', async ({ page, request }) => {
await page.goto('./');
await expect(page.getByRole('heading', { level: 1 })).toContainText('SystemDesign0ver');
await page.goto('fundamentals/networking/');
await expect(page.getByRole('heading', { level: 1 })).toHaveText('Networking');
await page.goto('glossary/');
await expect(page.getByRole('heading', { level: 1 })).toHaveText('Glossary');
await expect(page.getByRole('heading', { level: 2 }).first()).toBeVisible();
const index = await request.get('llms.txt');
expect(index.ok()).toBeTruthy();
expect(await index.text()).toContain('/sysdes/fundamentals/networking.md');
const article = await request.get('fundamentals/networking.md');
expect(article.ok()).toBeTruthy();
expect(await article.text()).toContain('Networking');
});

test('theme follows the browser and preserves an explicit choice after reload', async ({ page }, testInfo) => {
await page.goto('fundamentals/networking/');
const initial = testInfo.project.use.colorScheme;
const selected = initial === 'dark' ? 'light' : 'dark';
await expect(page.locator('html')).toHaveAttribute('data-theme', initial!);
await page.getByRole('button', { name: 'Toggle theme' }).click();
await expect(page.locator('html')).toHaveAttribute('data-theme', selected);
await page.reload();
await expect(page.locator('html')).toHaveAttribute('data-theme', selected);
});

test('search loads the production index and opens an article', async ({ page }) => {
await page.goto('./');
await page.getByRole('button', { name: 'Search', exact: true }).click();
const dialog = page.getByRole('dialog', { name: 'Search' });
await expect(dialog).toBeVisible();
await dialog.getByRole('textbox', { name: 'Search', exact: true }).fill('networking');
const result = dialog.getByRole('link', { name: 'Networking', exact: true })
.and(dialog.locator('a[href="/sysdes/fundamentals/networking/"]'));
await expect(result).toBeVisible();
await result.click();
await expect(page).toHaveURL(/\/sysdes\/fundamentals\/networking\/$/);
await expect(page.getByRole('heading', { level: 1 })).toHaveText('Networking');
});

test('sidebar navigation works on desktop and through the mobile menu', async ({ page }, testInfo) => {
await page.goto('./');
const sidebar = page.locator('#starlight__sidebar');
if (testInfo.project.use.isMobile) {
await expect(sidebar).toBeHidden();
await page.getByRole('button', { name: 'Menu', exact: true }).click();
}
await expect(sidebar).toBeVisible();
await sidebar.getByRole('link', { name: /^Networking\b/ }).click();
await expect(page).toHaveURL(/\/sysdes\/fundamentals\/networking\/$/);
await expect(page.getByRole('heading', { level: 1 })).toHaveText('Networking');
if (testInfo.project.use.isMobile) await expect(sidebar).toBeHidden();
});
Loading