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
26 changes: 26 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,33 @@ concurrency:
cancel-in-progress: true

jobs:
blog-changes:
runs-on: ubuntu-latest
outputs:
blog: ${{ steps.filter.outputs.blog }}
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0

- name: Detect changes outside the CMS
id: filter
env:
BASE: ${{ github.event.pull_request.base.sha || github.event.before }}
run: |
if [ -z "$BASE" ] || [ "$BASE" = "0000000000000000000000000000000000000000" ] || ! git cat-file -e "$BASE^{commit}" 2>/dev/null; then
echo "blog=true" >> "$GITHUB_OUTPUT"
exit 0
fi
if git diff --name-only "$BASE" "$GITHUB_SHA" | grep -qvE '^(cms/|\.github/workflows/cms\.yml$)'; then
echo "blog=true" >> "$GITHUB_OUTPUT"
else
echo "blog=false" >> "$GITHUB_OUTPUT"
fi

test:
needs: blog-changes
if: ${{ !cancelled() && (needs.blog-changes.result != 'success' || needs.blog-changes.outputs.blog == 'true') }}
runs-on: ubuntu-latest

steps:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,5 @@ pnpm-debug.log*

# openidea notes
.openidea/
.dev.vars
.trash/
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
## 2026-11-15 07:58

| Check | Status | Details |
|-------|--------|---------|
| Lint | ✓ PASS | 0 errors |
| Build | ✓ PASS | 27 pages built, 5 pages indexed (Pagefind) |
| Unit Tests | ✓ PASS | 75 tests passed |
| E2E Tests | ✓ PASS | 96 tests passed |
| Lighthouse | ✓ PASS | 99.8% performance (avg) |

### Lighthouse Performance (local build)

| Page | Scores (3 runs) |
|------|-----------------|
| / (index) | 100%, 100%, 100% |
| /about | 99%, 99%, 99% |
| /posts | 100%, 100%, 100% |
| /archives (soft 404, not linked) | 100%, 100%, 100% |
| /404 | 100%, 100%, 100% |

**Diagnostics:** None. Live site not measured. A stub `cms/src/x.tsx` changed the Tailwind CSS hash until `@source not "../../cms"` was added; hashes then matched the baseline. A temporary sixth post with a new tag passed build, unit and e2e.

Changes: Isolate the planned `cms/` directory from the blog (tsconfig, ESLint, Tailwind source, `blog-changes` CI filter); derive the post, tag and RSS counts in four tests from `src/content/posts` via `tests/helpers/published-posts.ts`.

## 2026-11-15 00:32

| Check | Status | Details |
Expand Down
9 changes: 7 additions & 2 deletions e2e/posts.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import { test, expect } from "@playwright/test";
import { published } from "../tests/helpers/published-posts";

test.describe("Posts Page", () => {
test("listing shows perPage (3) posts", async ({ page }) => {
await page.goto("/posts/");
await expect(page.locator("#main-content ul > li")).toHaveCount(3);
await expect(page.locator("#main-content ul > li")).toHaveCount(
Math.min(3, published.length)
);
});

test("listing paginates to /posts/2/", async ({ page }) => {
await page.goto("/posts/2/");
await expect(page.locator("#main-content ul > li")).toHaveCount(2);
await expect(page.locator("#main-content ul > li")).toHaveCount(
Math.min(3, published.length - 3)
);
});

test("can navigate to individual post", async ({ page }) => {
Expand Down
5 changes: 3 additions & 2 deletions e2e/tags.spec.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { test, expect } from "@playwright/test";
import { tags } from "../tests/helpers/published-posts";

test.describe("Tags Page", () => {
test("loads tags page", async ({ page }) => {
await page.goto("/tags/");
await expect(page).toHaveTitle("Tags | Developer Musings");
});

test("lists all 14 tags", async ({ page }) => {
test("lists all published tags", async ({ page }) => {
await page.goto("/tags/");
await expect(page.locator('#main-content a[href^="/tags/"]')).toHaveCount(
14
tags.length
);
});

Expand Down
5 changes: 3 additions & 2 deletions e2e/url-preservation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@ test.describe("URL preservation", () => {
const links = [...xml.matchAll(/<item>.*?<link>([^<]+)<\/link>/gs)].map(
m => m[1]
);
expect(links).toEqual([
const OLD = [
"https://blog.kulkarni.cloud/posts/some-interesting-features-in-github-actions/",
"https://blog.kulkarni.cloud/posts/gradle-tricks/",
"https://blog.kulkarni.cloud/posts/tmux-how-i-use-it/",
"https://blog.kulkarni.cloud/posts/followup-latest-version-of-the-tools-using-asdf/",
"https://blog.kulkarni.cloud/posts/on-the-topic-of-tools-their-versions-and-automated-installations/",
]);
];
expect(links.filter(l => OLD.includes(l))).toEqual(OLD);
});

test("old ampersand-less slug is not served", async ({ request }) => {
Expand Down
3 changes: 3 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ export default [
".husky/",
".vscode/",
"public/",
"cms/",
".claude/",
".trash/",
],
},
];
1 change: 1 addition & 0 deletions src/styles/global.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@import "tailwindcss";
@source not "../../cms";
@import "./theme.css";
@import "./typography.css";
@import "rehype-callouts/theme/obsidian";
Expand Down
1 change: 1 addition & 0 deletions tests/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Unit tests need no network: offline, the Google font provider in `astro.config.t
## Subdirectories
| Directory | Purpose |
|-----------|---------|
| `helpers/` | `published-posts.ts` reads `../src/content/posts` and exports `published` and `tags`; the count-coupled tests derive expected values from it |
| `utils/` | Tests for `src/utils/` (see `utils/AGENTS.md`) |
| `functions/` | `turnstile.test.ts`: session cookie signing, public-path list and middleware branches of `../functions/` |

Expand Down
3 changes: 2 additions & 1 deletion tests/build.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { describe, it, expect, beforeAll } from "vitest";
import { existsSync, readdirSync, readFileSync } from "fs";
import { join } from "path";
import { published } from "./helpers/published-posts";

const distDir = join(process.cwd(), "dist");

Expand Down Expand Up @@ -69,7 +70,7 @@ describe("Build Output", () => {
const pngs = readdirSync(postsDir)
.map(d => join(postsDir, d, "index.png"))
.filter(existsSync);
expect(pngs).toHaveLength(5);
expect(pngs).toHaveLength(published.filter(p => !p.ogImage).length);
for (const png of pngs) {
expect(readFileSync(png).subarray(0, 8)).toEqual(
Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a])
Expand Down
14 changes: 14 additions & 0 deletions tests/helpers/published-posts.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { describe, it, expect } from "vitest";
import { published, tags } from "./published-posts";

describe("published-posts helper", () => {
it("lists published posts", () => {
expect(published.length).toBeGreaterThanOrEqual(5);
expect(published.every(post => !post.draft)).toBe(true);
});

it("lists unique slugified tags", () => {
expect(tags).toContain("gradle");
expect(new Set(tags).size).toBe(tags.length);
});
});
44 changes: 44 additions & 0 deletions tests/helpers/published-posts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { readdirSync, readFileSync } from "node:fs";
import { join } from "node:path";
import { parseYaml } from "@astrojs/internal-helpers/yaml";
import dayjs from "dayjs";
import timezone from "dayjs/plugin/timezone.js";
import utc from "dayjs/plugin/utc.js";
import config from "../../astro-paper.config";
import { slugifyStr } from "../../src/utils/slugify";

dayjs.extend(utc);
dayjs.extend(timezone);

const postsDir = join(import.meta.dirname, "../../src/content/posts");

interface PostData {
draft?: boolean;
pubDatetime: string | Date;
timezone?: string;
tags?: string[];
ogImage?: unknown;
}

function readPosts(): PostData[] {
return readdirSync(postsDir)
.filter(name => /^[^_].*\.mdx?$/.test(name))
.map(name => {
const source = readFileSync(join(postsDir, name), "utf8");
const match = /^---\r?\n([\s\S]*?)\r?\n---/.exec(source);
return parseYaml(match?.[1] ?? "") as PostData;
});
}

export const published = readPosts().filter(post => {
if (post.draft) return false;
const tz = post.timezone || config.site.timezone || "UTC";
const publishDay = dayjs(post.pubDatetime).tz(tz).startOf("day");
return !publishDay.isAfter(dayjs().tz(tz).startOf("day"));
});

export const tags = [
...new Set(
published.flatMap(post => (post.tags ?? ["others"]).map(slugifyStr))
),
];
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"old-posts",
".lighthouseci",
"playwright-report",
"test-results"
"test-results",
"cms"
],
"compilerOptions": {
"paths": {
Expand Down
Loading