Skip to content
This repository was archived by the owner on Jan 27, 2026. It is now read-only.

Commit 18c3f52

Browse files
authored
Merge branch 'main' into framework-tanstack-start
2 parents 9d18b70 + b0b86ac commit 18c3f52

35 files changed

+4130
-50
lines changed
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: Build and Release MCP Resources
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
branches: [main]
7+
workflow_dispatch:
8+
inputs:
9+
version:
10+
description: 'Version number (e.g., 1.0.0)'
11+
required: false
12+
type: string
13+
14+
jobs:
15+
build-and-release:
16+
# Manual trigger OR (PR merged with label 'mcp-publish')
17+
if: |
18+
github.event_name == 'workflow_dispatch' ||
19+
(github.event.pull_request.merged == true &&
20+
contains(github.event.pull_request.labels.*.name, 'mcp-publish'))
21+
22+
runs-on: ubuntu-latest
23+
permissions:
24+
contents: write
25+
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v4
29+
with:
30+
fetch-depth: 0 # Fetch all history for proper versioning
31+
32+
- name: Setup Node.js
33+
uses: actions/setup-node@v4
34+
with:
35+
node-version: 'lts/*'
36+
37+
- name: Install dependencies
38+
run: npm install
39+
40+
- name: Build markdown documentation
41+
run: npm run build:docs
42+
43+
- name: Determine version
44+
id: version
45+
run: |
46+
if [ -n "${{ github.event.inputs.version }}" ]; then
47+
VERSION="${{ github.event.inputs.version }}"
48+
else
49+
# Get the latest tag, or use 1.0.0 if no tags exist
50+
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
51+
# Remove 'v' prefix if present
52+
LATEST_VERSION=${LATEST_TAG#v}
53+
# Increment patch version
54+
IFS='.' read -r -a VERSION_PARTS <<< "$LATEST_VERSION"
55+
MAJOR=${VERSION_PARTS[0]:-0}
56+
MINOR=${VERSION_PARTS[1]:-0}
57+
PATCH=${VERSION_PARTS[2]:-0}
58+
PATCH=$((PATCH + 1))
59+
VERSION="${MAJOR}.${MINOR}.${PATCH}"
60+
fi
61+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
62+
echo "tag=v${VERSION}" >> $GITHUB_OUTPUT
63+
echo "Building version: ${VERSION}"
64+
65+
- name: Create Release
66+
id: create_release
67+
uses: actions/create-release@v1
68+
env:
69+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70+
with:
71+
tag_name: ${{ steps.version.outputs.tag }}
72+
release_name: Release ${{ steps.version.outputs.tag }}
73+
body: |
74+
Automated release of PostHog example projects as markdown documentation.
75+
76+
This release contains pre-processed markdown files for all example projects.
77+
78+
**Contents:**
79+
- `nextjs-app-router.md` - Next.js App Router example
80+
- `nextjs-pages-router.md` - Next.js Pages Router example
81+
82+
**SHA:** ${{ github.sha }}
83+
draft: false
84+
prerelease: false
85+
86+
- name: Upload Release Asset
87+
uses: actions/upload-release-asset@v1
88+
env:
89+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
90+
with:
91+
upload_url: ${{ steps.create_release.outputs.upload_url }}
92+
asset_path: ./dist/examples-mcp-resources.zip
93+
asset_name: examples-mcp-resources.zip
94+
asset_content_type: application/zip
95+
96+
- name: Update latest tag
97+
run: |
98+
git config user.name "github-actions[bot]"
99+
git config user.email "github-actions[bot]@users.noreply.github.com"
100+
# Create the version tag locally first
101+
git tag ${{ steps.version.outputs.tag }}
102+
# Point latest to the current commit (same as the version tag)
103+
git tag -f latest
104+
# Push both tags
105+
git push origin ${{ steps.version.outputs.tag }}
106+
git push -f origin latest
107+
108+
- name: Build Summary
109+
run: |
110+
echo "## Release Summary" >> $GITHUB_STEP_SUMMARY
111+
echo "" >> $GITHUB_STEP_SUMMARY
112+
echo "- **Version:** ${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
113+
echo "- **Tag:** ${{ steps.version.outputs.tag }}" >> $GITHUB_STEP_SUMMARY
114+
echo "- **Artifact:** examples-mcp-resources.zip" >> $GITHUB_STEP_SUMMARY
115+
echo "" >> $GITHUB_STEP_SUMMARY
116+
echo "### Files Generated" >> $GITHUB_STEP_SUMMARY
117+
ls -lh dist/ >> $GITHUB_STEP_SUMMARY

.github/workflows/playwright.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: PostHog Examples - Playwright Tests
2+
permissions:
3+
contents: read
4+
5+
on:
6+
push:
7+
branches: [ main ]
8+
pull_request:
9+
branches: [ main ]
10+
schedule:
11+
# Runs nightly at 12am PST (which is 8am UTC)
12+
- cron: '0 8 * * *'
13+
14+
jobs:
15+
discover:
16+
runs-on: ubuntu-latest
17+
outputs:
18+
examples: ${{ steps.set-examples.outputs.examples }}
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Discover examples with Playwright configs
23+
id: set-examples
24+
run: |
25+
examples=$(find basics -maxdepth 2 -name "playwright.config.ts" -exec dirname {} \; | sed 's|^basics/||' | jq -R -s -c 'split("\n")[:-1]')
26+
echo "examples=$examples" >> $GITHUB_OUTPUT
27+
echo "Found examples: $examples"
28+
29+
test:
30+
needs: discover
31+
if: needs.discover.outputs.examples != '[]'
32+
timeout-minutes: 60
33+
runs-on: ubuntu-latest
34+
strategy:
35+
fail-fast: false
36+
matrix:
37+
example: ${{ fromJson(needs.discover.outputs.examples) }}
38+
steps:
39+
- uses: actions/checkout@v4
40+
41+
- uses: actions/setup-node@v4
42+
with:
43+
node-version: lts/*
44+
45+
- uses: pnpm/action-setup@v4
46+
with:
47+
version: latest
48+
49+
- name: Install dependencies
50+
run: |
51+
cd basics/${{ matrix.example }}
52+
pnpm install
53+
54+
- name: Install Playwright Browsers
55+
run: |
56+
cd basics/${{ matrix.example }}
57+
pnpm exec playwright install chromium --with-deps
58+
59+
- name: Run Playwright tests
60+
run: |
61+
cd basics/${{ matrix.example }}
62+
pnpm exec playwright test
63+
env:
64+
NEXT_PUBLIC_POSTHOG_KEY: ${{ vars.NEXT_PUBLIC_POSTHOG_KEY }}
65+
NEXT_PUBLIC_POSTHOG_HOST: ${{ vars.NEXT_PUBLIC_POSTHOG_HOST }}
66+
67+
- uses: actions/upload-artifact@v4
68+
if: always()
69+
with:
70+
name: playwright-report-${{ matrix.example }}
71+
path: basics/${{ matrix.example }}/playwright-report/
72+
retention-days: 30
73+
74+
# TODO: report to PostHog which will warn in channel for failure.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ coverage/
5050
# TanStack Router generated files
5151
routeTree.gen.ts
5252

53+
# Build artifacts
54+
dist/
55+
5356
# Misc
5457
*.pem
5558
*.key
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# PostHog Configuration
2+
# Get your PostHog API key from: https://app.posthog.com/project/settings
3+
NEXT_PUBLIC_POSTHOG_KEY=your_posthog_project_api_key_here
4+
# NEXT_PUBLIC_POSTHOG_HOST=https://eu.i.posthog.com
5+
NEXT_PUBLIC_POSTHOG_HOST=https://us.i.posthog.com

basics/next-app-router/.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212

1313
# testing
1414
/coverage
15+
/test-results/
16+
/playwright-report/
17+
/blob-report/
18+
/playwright/.cache/
1519

1620
# next.js
1721
/.next/
@@ -31,7 +35,7 @@ yarn-error.log*
3135
.pnpm-debug.log*
3236

3337
# env files (can opt-in for committing if needed)
34-
.env*
38+
.env
3539

3640
# vercel
3741
.vercel

basics/next-app-router/instrumentation-client.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,9 @@ posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY!, {
99
capture_exceptions: true,
1010
// Turn on debug in development mode
1111
debug: process.env.NODE_ENV === "development",
12+
// @ignoreBlockStart
13+
// Disable request batching in test environment
14+
request_batching: false,
15+
opt_out_useragent_filter: true, // This disables bot detection
16+
// @ignoreBlockEnd
1217
});

basics/next-app-router/package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
"dev": "next dev --turbopack",
77
"build": "next build --turbopack",
88
"start": "next start",
9-
"lint": "eslint"
9+
"lint": "eslint",
10+
"postinstall": "playwright install chromium",
11+
"test": "playwright test",
12+
"test:ui": "playwright test --ui",
13+
"test:report": "playwright show-report"
1014
},
1115
"dependencies": {
1216
"next": "15.5.2",
@@ -17,9 +21,11 @@
1721
},
1822
"devDependencies": {
1923
"@eslint/eslintrc": "^3",
24+
"@playwright/test": "^1.56.1",
2025
"@types/node": "^20",
2126
"@types/react": "^19",
2227
"@types/react-dom": "^19",
28+
"dotenv": "^17.2.3",
2329
"eslint": "^9",
2430
"eslint-config-next": "15.5.2",
2531
"typescript": "^5"
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// @ignoreFile
2+
import { defineConfig, devices } from '@playwright/test';
3+
import { config } from 'dotenv';
4+
5+
// Load environment variables from .env file
6+
config();
7+
8+
/**
9+
* See https://playwright.dev/docs/test-configuration.
10+
*/
11+
export default defineConfig({
12+
testDir: './tests',
13+
/* Run tests in files in parallel */
14+
fullyParallel: true,
15+
/* Fail the build on CI if you accidentally left test.only in the source code. */
16+
forbidOnly: !!process.env.CI,
17+
/* Retry on CI only */
18+
retries: process.env.CI ? 2 : 0,
19+
/* Opt out of parallel tests on CI. */
20+
workers: process.env.CI ? 1 : undefined,
21+
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
22+
reporter: 'html',
23+
24+
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
25+
use: {
26+
/* Base URL to use in actions like `await page.goto('/')`. */
27+
baseURL: 'http://127.0.0.1:3333',
28+
29+
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
30+
trace: 'on-first-retry',
31+
},
32+
33+
/* Global timeout settings */
34+
timeout: 180000, // 3 minutes for individual tests
35+
expect: {
36+
timeout: 60000, // 1 minute for expect assertions
37+
},
38+
39+
/* Configure projects for major browsers */
40+
projects: [
41+
{
42+
name: 'chromium',
43+
use: { ...devices['Desktop Chrome'] },
44+
snapshotPathTemplate: '{testDir}/{testFileName}-snapshots/{arg}{ext}',
45+
},
46+
],
47+
48+
/* Run your local dev server before starting the tests */
49+
webServer: {
50+
command: 'pnpm dev --port 3333',
51+
url: 'http://127.0.0.1:3333',
52+
reuseExistingServer: false, // Always start fresh
53+
},
54+
});
55+
56+

0 commit comments

Comments
 (0)