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
62 changes: 62 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,65 @@ jobs:
run: pnpm run build
- name: Lint
run: pnpm run lint

e2e:
name: E2E (Obsidian)
runs-on: ubuntu-latest
timeout-minutes: 20
env:
# Pinned like a dependency: bump deliberately, at least seven days after release.
OBSIDIAN_VERSION: 1.14.4
OBSIDIAN_SHA256: e70b7cd63787e7f798a84fec453f5c446b91877bd3f612e8fb98e9b76cc81120
steps:
- name: Harden Runner
uses: step-security/harden-runner@ccd8616d44fd3846e67624a50d5aad6d37bf2d25 # v2.22.1
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Setup pnpm
uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
- name: Use Node.js 24
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 24
check-latest: true
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Install Xvfb
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends xvfb xauth
- name: Install Obsidian
run: |
archive="$RUNNER_TEMP/obsidian.tar.gz"
curl -fsSL -o "$archive" "https://github.com/obsidianmd/obsidian-releases/releases/download/v${OBSIDIAN_VERSION}/obsidian-${OBSIDIAN_VERSION}.tar.gz"
echo "${OBSIDIAN_SHA256} $archive" | sha256sum -c -
tar -xzf "$archive" -C "$RUNNER_TEMP"
echo "OBSIDIAN_DIR=$RUNNER_TEMP/obsidian-${OBSIDIAN_VERSION}" >> "$GITHUB_ENV"
- name: Build
run: pnpm run build
- name: Start Obsidian
run: |
pnpm run --silent start:e2e-obsidian -- \
--obsidian-app "$OBSIDIAN_DIR/obsidian" \
--obsidian-bin "$OBSIDIAN_DIR/obsidian-cli" \
--print-env > "$RUNNER_TEMP/e2e-env.sh"
sed -n "s/^export \([A-Z0-9_]*\)='\(.*\)'$/\1=\2/p" "$RUNNER_TEMP/e2e-env.sh" >> "$GITHUB_ENV"
- name: Run E2E suite
# The instance's CLI socket lives under its private HOME.
run: HOME="$OBSIDIAN_E2E_OBSIDIAN_HOME" ./node_modules/.bin/vitest run --config vitest.e2e.config.mts
- name: Upload failure artifacts
if: failure()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: e2e-failure-artifacts
path: |
.obsidian-e2e-artifacts/
/tmp/metaedit-obsidian-e2e/*/obsidian.log
if-no-files-found: ignore
Comment thread
macroscopeapp[bot] marked this conversation as resolved.
Resolved
include-hidden-files: true
- name: Stop Obsidian
if: always()
run: pnpm run --silent stop:e2e-obsidian
2 changes: 2 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ hand-written, committed release asset.
- `pnpm run lint`: ESLint over the TypeScript sources.
- `pnpm run test`: Vitest unit suite (jsdom-free, `node` environment).
- `pnpm run test:e2e`: build, then run the live Obsidian E2E suite (`tests/e2e/`).
CI's `E2E (Obsidian)` job runs the same suite headless under Xvfb against the
Obsidian version pinned in `.github/workflows/ci.yml`.
- `pnpm run obsidian:e2e -- <command>`: run an `obsidian` CLI command against an
isolated, auto-provisioned worktree instance (see below).

Expand Down
14 changes: 2 additions & 12 deletions esbuild.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {dirname, join, relative, sep} from "node:path";
import {fileURLToPath} from "node:url";
import esbuild from "esbuild";
import {compile} from "svelte/compiler";
import {rejectSvelteRuneModules} from "./scripts/svelte-rune-guard.mjs";

const isProduction = process.argv.includes("production");
const projectSrcDir = `${join(dirname(fileURLToPath(import.meta.url)), "src")}${sep}`;
Expand Down Expand Up @@ -64,18 +65,6 @@ function toEsbuildMessage({message, start, end}, file, source) {
};
}

// Registered first so no other loader can hand esbuild a rune module's source.
function rejectSvelteRuneModules() {
return {
name: "reject-svelte-rune-modules",
setup(build) {
build.onLoad({filter: /\.svelte\.[cm]?[jt]s$/}, (args) => ({
errors: [{text: `Svelte rune modules (.svelte.js/.svelte.ts) are not supported by this build: ${args.path}`}],
}));
},
};
}

function compileSvelte() {
return {
name: "compile-svelte",
Expand Down Expand Up @@ -116,6 +105,7 @@ const options = {
},
logLevel: "info",
plugins: [
// Registered first so no other loader can hand esbuild a rune module's source.
rejectSvelteRuneModules(),
...(isProduction ? [stripDevCommandBlocks()] : []),
compileSvelte(),
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"eslint-plugin-svelte": "^3.23.1",
"globals": "^17.13.0",
"obsidian": "1.14.4",
"obsidian-e2e": "^0.14.0",
"obsidian-e2e": "^0.15.0",
"svelte": "^5.57.2",
"svelte-check": "^4.7.7",
"typescript": "^6.0.3",
Expand Down
14 changes: 7 additions & 7 deletions pnpm-lock.yaml

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

13 changes: 13 additions & 0 deletions scripts/svelte-rune-guard.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// The build compiles `.svelte` components only. A `.svelte.js`/`.svelte.ts` rune
// module would need svelte's compileModule, and without it esbuild would bundle
// the raw `$state`/`$derived` calls, which then throw at runtime.
export function rejectSvelteRuneModules() {
return {
name: "reject-svelte-rune-modules",
setup(build) {
build.onLoad({filter: /\.svelte\.[cm]?[jt]s$/}, (args) => ({
errors: [{text: `Svelte rune modules (.svelte.js/.svelte.ts) are not supported by this build: ${args.path}`}],
}));
},
};
}
33 changes: 33 additions & 0 deletions scripts/svelte-rune-guard.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import esbuild from "esbuild";
import { afterAll, describe, expect, it } from "vitest";
import { rejectSvelteRuneModules } from "./svelte-rune-guard.mjs";

const dir = mkdtempSync(join(tmpdir(), "metaedit-rune-guard-"));
afterAll(() => rmSync(dir, { recursive: true, force: true }));

function bundle(importPath: string, source: string) {
writeFileSync(join(dir, importPath), source);
return esbuild.build({
stdin: { contents: `import {value} from "./${importPath}"; console.debug(value);`, resolveDir: dir },
bundle: true,
write: false,
logLevel: "silent",
plugins: [rejectSvelteRuneModules()],
});
}

describe("rejectSvelteRuneModules", () => {
it.each(["counter.svelte.ts", "counter.svelte.js", "counter.svelte.mts"])("fails the build when %s is imported", async (file) => {
await expect(bundle(file, "export const value = $state(0);")).rejects.toThrow(
/Svelte rune modules \(\.svelte\.js\/\.svelte\.ts\) are not supported by this build/,
);
});

it("leaves ordinary modules alone", async () => {
const result = await bundle("counter.ts", "export const value = 0;");
expect(result.errors).toEqual([]);
});
});
3 changes: 2 additions & 1 deletion tests/e2e/audit-suggester.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ describe("MetaEdit Edit Meta suggester flows", () => {
await sleep(300);
// Adding an existing key triggers the duplicate Notice.
await plugin.controller.addYamlProp("status", "x", f);
const notice = await waitFor(".notice");
// Notices from earlier suites can still be on screen.
const notice = await waitFor(".notice", (n) => n.textContent.includes("already has property"));
return (notice.textContent || "").trim();
})()
`,
Expand Down
Loading