trunk-merge/pr-110530/e7ac1ae0-9283-4294-94e2-4c8e34138983 #238000
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: MCP UI Apps CI | |
| on: | |
| push: | |
| branches: [master] | |
| pull_request: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} | |
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| changes: | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 5 | |
| name: Determine need to run UI Apps checks | |
| outputs: | |
| ui-apps: ${{ steps.filter.outputs.ui-apps || 'true' }} | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| sparse-checkout: .github/actions/paths-filter | |
| sparse-checkout-cone-mode: false | |
| - uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1 | |
| id: app-token | |
| if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository | |
| with: | |
| client-id: ${{ vars.GH_APP_POSTHOG_PATHS_FILTER_APP_ID }} | |
| private-key: ${{ secrets.GH_APP_POSTHOG_PATHS_FILTER_PRIVATE_KEY }} | |
| - uses: ./.github/actions/paths-filter | |
| id: filter | |
| if: github.event_name != 'push' | |
| with: | |
| token: ${{ steps.app-token.outputs.token || github.token }} | |
| filters: | | |
| ui-apps: | |
| - 'services/mcp/src/ui-apps/**' | |
| - 'services/mcp/src/resources/ui-apps.generated.ts' | |
| - 'services/mcp/vite.ui-apps.config.ts' | |
| - 'services/mcp/scripts/build-ui-apps.ts' | |
| - 'services/mcp/scripts/generate-ui-apps.ts' | |
| - 'services/mcp/scripts/post-ui-apps-size-section.mjs' | |
| - 'services/mcp/scripts/yaml-config-schema.ts' | |
| - 'products/*/mcp/**' | |
| - 'services/mcp/definitions/*.yaml' | |
| - 'common/mosaic/**' | |
| # Compiled into the UI apps: the quill packages they render with, the | |
| # product-analytics chart transforms they import, and the generated | |
| # API types their views are typed against. | |
| - 'packages/quill/**' | |
| - 'products/product_analytics/frontend/insights/**' | |
| - 'products/*/frontend/generated/**' | |
| - '.github/workflows/ci-mcp-ui-apps.yml' | |
| - '.github/actions/setup-uv/**' | |
| build-and-report: | |
| name: Build and validate UI Apps | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 10 | |
| needs: changes | |
| if: needs.changes.outputs.ui-apps == 'true' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - name: Install uv # Needed for formatting generated code and running scripts | |
| uses: ./.github/actions/setup-uv | |
| - name: Mint setup-action GitHub token | |
| id: setup-gh-token | |
| if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository | |
| continue-on-error: true | |
| uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1 | |
| with: | |
| client-id: ${{ vars.GH_APP_POSTHOG_SETUP_ACTIONS_APP_ID }} | |
| private-key: ${{ secrets.GH_APP_POSTHOG_SETUP_ACTIONS_PRIVATE_KEY }} | |
| skip-token-revoke: true | |
| - name: Install pnpm dependencies | |
| # Match services/mcp/Dockerfile exactly | |
| uses: ./.github/actions/pnpm-install | |
| with: | |
| install-command: pnpm --filter=@posthog/mcp... install --frozen-lockfile | |
| token: ${{ steps.setup-gh-token.outputs.token || github.token }} | |
| - name: Check generated UI apps are up to date | |
| run: | | |
| cd services/mcp && pnpm run generate:ui-apps | |
| if ! git diff --exit-code -- src/ui-apps/apps/generated/ src/resources/ui-apps.generated.ts; then | |
| echo "" | |
| echo "::warning::The following generated files are out of date:" | |
| git diff --name-only -- src/ui-apps/apps/generated/ src/resources/ui-apps.generated.ts | |
| echo "" | |
| echo "::error::Generated UI app files are out of date. Run 'pnpm --filter=@posthog/mcp run generate:ui-apps' and commit the result." | |
| exit 1 | |
| fi | |
| - name: Build UI Apps | |
| run: cd services/mcp && pnpm run build:ui-apps | |
| - name: Validate build output | |
| run: | | |
| # Each app should produce main.js and styles.css | |
| # Use find to recurse into wrapper dirs like generated/ | |
| missing=0 | |
| for app_dir in $(find services/mcp/public/ui-apps -mindepth 1 -type d ! -name generated | sort); do | |
| app=$(basename "$app_dir") | |
| if [ ! -f "$app_dir/main.js" ]; then | |
| echo "::error::Missing main.js for $app" | |
| missing=1 | |
| fi | |
| if [ ! -f "$app_dir/styles.css" ]; then | |
| echo "::error::Missing styles.css for $app" | |
| missing=1 | |
| fi | |
| done | |
| if [ "$missing" -eq 1 ]; then | |
| exit 1 | |
| fi | |
| echo "All UI Apps built successfully." | |
| # Writes the size table into the shared ci-report PR comment (one comment for | |
| # all CI checks), then clears any leftover standalone size comment from before | |
| # the consolidation. Guarded for unrebased branches that predate the scripts. | |
| - name: Post size report to CI report comment | |
| # Skipped on trunk-merge/** branches: merge-queue draft PRs are ephemeral and | |
| # unread, and each section write spends shared GITHUB_TOKEN budget. | |
| if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && !startsWith(github.head_ref, 'trunk-merge/') | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} | |
| run: | | |
| if [ -f services/mcp/scripts/post-ui-apps-size-section.mjs ]; then | |
| node services/mcp/scripts/post-ui-apps-size-section.mjs | |
| node frontend/bin/ci-report/delete-legacy-comments.mjs | |
| else | |
| echo "Skipping size report section — script not present on this checkout" | |
| fi | |
| ci_mcp_ui_apps: | |
| needs: [changes, build-and-report] | |
| name: MCP UI Apps CI | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 5 | |
| if: ${{ !cancelled() }} | |
| steps: | |
| - name: Check results | |
| run: | | |
| # Block cancelled too: outputs are empty then, so the exit below would report green. | |
| if [[ "${{ needs.changes.result }}" != "success" && "${{ needs.changes.result }}" != "skipped" ]]; then | |
| echo "Change detection did not succeed (result: ${{ needs.changes.result }})." | |
| exit 1 | |
| fi | |
| if [[ "${{ needs.changes.outputs.ui-apps }}" != "true" ]]; then | |
| echo "UI Apps checks were skipped (no relevant changes)." | |
| exit 0 | |
| fi | |
| if [[ "${{ needs.build-and-report.result }}" != "success" && "${{ needs.build-and-report.result }}" != "skipped" ]]; then | |
| echo "UI Apps build failed." | |
| exit 1 | |
| fi | |
| echo "All MCP UI Apps checks passed." |