-
Notifications
You must be signed in to change notification settings - Fork 41
ci(setup): add local setup smoke workflow #3772
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
d5cb3a9
ci(setup): add local setup smoke workflow
RSO 549d51f
fix(dev): tolerate tmux title option differences
RSO c17b4fa
fix(dev): pass action PATH into tmux session
RSO f32e94d
fix(dev): set tmux session environment
RSO b91188e
fix(ci): enable corepack for setup smoke
RSO 66866f9
fix(dev): use resolved pnpm path in tmux
RSO 173f28c
fix(dev): preserve action env in tmux commands
RSO cbd72b7
fix(ci): seed setup smoke user locally
RSO 263a8b3
fix(ci): use direct db client in setup smoke
RSO 1e19108
fix(ci): mark setup smoke user verified
RSO edcbe8c
fix(ci): provide setup smoke PostHog env
RSO bed5eaa
fix(ci): skip Stripe API during setup smoke
RSO a0c17bb
fix(ci): assert visible setup smoke profile content
RSO b5bf448
ci(setup): schedule setup smoke workflow
RSO b96f9b1
ci(setup): notify on setup smoke failure
RSO b24dfb8
ci(setup): add manual smoke failure trigger
RSO 289710c
ci(setup): trigger smoke notification verification
RSO 146ae86
ci(setup): restore scheduled smoke workflow
RSO a3954dd
ci(setup): run smoke workflow hourly
RSO File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| name: Setup Smoke | ||
|
|
||
| on: | ||
| schedule: | ||
| - cron: '17 * * * *' | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
| issues: write | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| setup-smoke: | ||
| runs-on: ${{ vars.RUNNER_LARGE_LABEL || 'ubuntu-24.04-8core' }} | ||
| timeout-minutes: 45 | ||
|
|
||
| env: | ||
| NODE_ENV: development | ||
| DEBUG_SHOW_DEV_UI: 'true' | ||
| PORT: '3000' | ||
| NEXTAUTH_URL: http://localhost:3000 | ||
| POSTGRES_URL: postgresql://postgres:postgres@localhost:5432/postgres | ||
| POSTGRES_CONNECT_TIMEOUT: '30000' | ||
| POSTGRES_MAX_QUERY_TIME: '30000' | ||
| SKIP_STRIPE_API: 'true' | ||
| NEXT_PUBLIC_POSTHOG_KEY: fake-token | ||
| PLAYWRIGHT_BASE_URL: http://localhost:3000 | ||
|
|
||
| steps: | ||
| - uses: useblacksmith/checkout@41cdeedae8edb2e684ba22896a5fd2a3cb85db6b # v1 | ||
| with: | ||
| lfs: true | ||
|
|
||
| - name: Setup pnpm | ||
| uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0 | ||
|
|
||
| - name: Setup Node | ||
| uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 | ||
| with: | ||
| node-version-file: '.nvmrc' | ||
| cache: 'pnpm' | ||
|
|
||
| - name: Enable Corepack | ||
| run: | | ||
| corepack enable | ||
| corepack prepare pnpm@11.1.2 --activate | ||
|
|
||
| - name: Install tmux | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y tmux | ||
|
|
||
| - name: Install dependencies | ||
| run: pnpm install --frozen-lockfile | ||
|
|
||
| - name: Generate local environment | ||
| run: pnpm dev:setup-env --ci | ||
|
|
||
| - name: Sync local service environment | ||
| run: pnpm dev:env -y | ||
|
|
||
| - name: Start local infrastructure | ||
| run: docker compose -f dev/docker-compose.yml up -d --wait | ||
|
|
||
| - name: Verify migrations bootstrap cleanly | ||
| run: pnpm drizzle:verify-bootstrap | ||
|
|
||
| - name: Run database migrations | ||
| run: pnpm drizzle migrate | ||
|
|
||
| - name: Install Playwright browsers | ||
| run: pnpm --filter web exec playwright install --with-deps chromium | ||
|
|
||
| - name: Start dev stack | ||
| run: pnpm dev:start --no-attach | ||
|
|
||
| - name: Wait for web app | ||
| run: | | ||
| for i in {1..60}; do | ||
| if curl -fsSL http://localhost:3000/users/sign_in >/dev/null; then | ||
| exit 0 | ||
| fi | ||
|
|
||
| pnpm dev:status | ||
| sleep 5 | ||
| done | ||
|
|
||
| echo "Web app did not become ready in time" | ||
| exit 1 | ||
|
|
||
| - name: Run setup smoke tests | ||
| run: pnpm test:setup-smoke | ||
|
|
||
| - name: Stop dev stack | ||
| if: always() | ||
| run: pnpm dev:stop --force | ||
|
|
||
| - name: Upload setup smoke artifacts | ||
| if: always() | ||
| uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 | ||
| with: | ||
| name: setup-smoke-artifacts | ||
| path: | | ||
| apps/web/playwright-report | ||
| apps/web/test-results | ||
| dev/logs | ||
| retention-days: 7 | ||
|
|
||
| - name: Notify setup smoke failure | ||
| if: failure() | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| ISSUE_NUMBER: '3791' | ||
| RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | ||
| run: | | ||
| cat > /tmp/setup-smoke-failure.md <<EOF | ||
| @RSO Setup Smoke failed. | ||
|
|
||
| Run: ${RUN_URL} | ||
| Ref: ${GITHUB_REF_NAME} | ||
| SHA: ${GITHUB_SHA} | ||
| Trigger: ${GITHUB_EVENT_NAME} | ||
| EOF | ||
|
|
||
| gh issue comment "$ISSUE_NUMBER" --body-file /tmp/setup-smoke-failure.md |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import { defineConfig, devices } from '@playwright/test'; | ||
|
|
||
| const port = process.env.PORT ? Number(process.env.PORT) : 3000; | ||
| const baseURL = process.env.PLAYWRIGHT_BASE_URL ?? `http://localhost:${port}`; | ||
|
|
||
| export default defineConfig({ | ||
| testDir: './tests/setup-smoke', | ||
| fullyParallel: false, | ||
| forbidOnly: !!process.env.CI, | ||
| retries: process.env.CI ? 2 : 0, | ||
| workers: 1, | ||
| reporter: process.env.CI ? 'html' : 'list', | ||
| outputDir: 'test-results/setup-smoke', | ||
| use: { | ||
| baseURL, | ||
| trace: 'on-first-retry', | ||
| }, | ||
| projects: [ | ||
| { | ||
| name: 'chromium', | ||
| use: { | ||
| ...devices['Desktop Chrome'], | ||
| viewport: { width: 1440, height: 900 }, | ||
| }, | ||
| }, | ||
| ], | ||
| }); |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| import { expect, test } from '@playwright/test'; | ||
| import { createDrizzleClient } from '@kilocode/db/client'; | ||
| import { kilocode_users } from '@kilocode/db/schema'; | ||
| import { hosted_domain_specials } from '@/lib/auth/constants'; | ||
| import { randomUUID } from 'node:crypto'; | ||
|
|
||
| function isSignedInDestination(url: URL): boolean { | ||
| return url.pathname === '/profile' || url.pathname.startsWith('/organizations/'); | ||
| } | ||
|
|
||
| test.describe('local setup smoke', () => { | ||
| test.use({ storageState: { cookies: [], origins: [] } }); | ||
|
|
||
| test('signs in with fake auth and renders the profile page', async ({ page }) => { | ||
| const uniqueId = randomUUID().slice(0, 8); | ||
| const testEmail = `setup-smoke-${uniqueId}+stytchpass@example.com`; | ||
| const signInUrl = `/users/sign_in?fakeUser=${encodeURIComponent(testEmail)}&callbackPath=${encodeURIComponent('/profile')}`; | ||
| const postgresUrl = process.env.POSTGRES_URL; | ||
| if (!postgresUrl) throw new Error('POSTGRES_URL must be set for setup smoke tests'); | ||
|
|
||
| const { db, pool } = createDrizzleClient({ | ||
| connectionString: postgresUrl, | ||
| poolConfig: { | ||
| connectionTimeoutMillis: Number.parseInt(process.env.POSTGRES_CONNECT_TIMEOUT ?? '30000'), | ||
| max: 1, | ||
| }, | ||
| }); | ||
|
|
||
| try { | ||
| await db.insert(kilocode_users).values({ | ||
| id: `setup-smoke-${uniqueId}`, | ||
| google_user_email: testEmail, | ||
| google_user_name: `setup-smoke-${uniqueId}`, | ||
| google_user_image_url: '', | ||
| hosted_domain: hosted_domain_specials.fake_devonly, | ||
| stripe_customer_id: `cus_setup_smoke_${uniqueId}`, | ||
| completed_welcome_form: true, | ||
| has_validation_stytch: true, | ||
| }); | ||
| } finally { | ||
| await pool.end(); | ||
| } | ||
|
|
||
| await page.goto(signInUrl); | ||
| await page.waitForURL( | ||
| url => url.pathname === '/customer-source-survey' || isSignedInDestination(url), | ||
| { timeout: 30_000, waitUntil: 'networkidle' } | ||
| ); | ||
|
|
||
| if (new URL(page.url()).pathname === '/customer-source-survey') { | ||
| await page.getByRole('button', { name: 'Skip' }).click(); | ||
| await page.waitForURL(url => isSignedInDestination(url), { | ||
| timeout: 15_000, | ||
| waitUntil: 'networkidle', | ||
| }); | ||
| } | ||
|
|
||
| const profileResponse = await page.goto('/profile', { waitUntil: 'domcontentloaded' }); | ||
| expect(profileResponse?.ok()).toBe(true); | ||
| await expect(page).toHaveURL(/\/profile$/); | ||
| await expect(page.getByRole('link', { name: 'Your Profile' })).toBeVisible(); | ||
| await expect(page.getByRole('button', { name: 'Edit profile' })).toBeVisible(); | ||
| await expect(page.getByText(testEmail)).toBeVisible(); | ||
| }); | ||
| }); | ||
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.