π OpenHands: AI-Driven Development
fix: build npm static app with prod PostHog (#1416)
Rohit Malhotra4b0283ee8fb1
diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.ymlindex 8f93d5ef8d..070f234ac7 100644--- a/.github/workflows/npm-publish.yml+++ b/.github/workflows/npm-publish.yml@@ -60,6 +60,12 @@ jobs:run: npm test- name: Build app+ env:+ # Build the packaged static app the same way Docker tagged releases are+ # built: production telemetry key and app-level PostHog key baked in.+ # These are public, client-side project keys, not secrets.+ VITE_APP_ENV: production+ VITE_POSTHOG_CLIENT_KEY: ${{ vars.POSTHOG_PROD_KEY }}run: npm run build- name: Build librarydiff --git a/__tests__/github-workflows/npm-publish.test.ts b/__tests__/github-workflows/npm-publish.test.tsnew file mode 100644index 0000000000..4e60b0b51b--- /dev/null+++ b/__tests__/github-workflows/npm-publish.test.ts@@ -0,0 +1,30 @@+// @vitest-environment node+import { readFileSync } from "node:fs";+import path from "node:path";+import { fileURLToPath } from "node:url";+import { describe, expect, it } from "vitest";++const repoRoot = path.resolve(+ path.dirname(fileURLToPath(import.meta.url)),+ "../..",+);++function read(rel: string): string {+ return readFileSync(path.join(repoRoot, rel), "utf-8");+}++describe("npm publish workflow", () => {+ it("builds the packaged static app with production PostHog configuration", () => {+ const workflow = read(".github/workflows/npm-publish.yml");+ const buildAppStep = workflow.match(+ /- name: Build app[\s\S]*?(?=\n\s*- name: Build library)/,+ )?.[0];++ expect(buildAppStep).toBeTruthy();+ expect(buildAppStep).toContain("VITE_APP_ENV: production");+ expect(buildAppStep).toContain(+ "VITE_POSTHOG_CLIENT_KEY: ${{ vars.POSTHOG_PROD_KEY }}",+ );+ expect(buildAppStep).toContain("npm run build");+ });+});