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
10 changes: 9 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1088,6 +1088,14 @@ jobs:
bun-version: ${{ matrix.bun-version }}
deno-version: ${{ matrix.deno-version }}

- name: Start E2E databases
background: true
working-directory: ${{ runner.temp }}/test-application
run: |
if [ -f docker-compose.yml ]; then
docker compose up -d --wait
fi

# Installs Playwright while the app builds. Keep it right before the build: the runner sets up a background
# composite action's steps from the job's shared `github` context, which fails with "Collection was modified" if
# a foreground step starts at that moment. Starting next to `download-artifact` also made it fail to read the event file.
Expand All @@ -1106,7 +1114,7 @@ jobs:
env:
SENTRY_E2E_WORKSPACE_ROOT: ${{ github.workspace }}

- wait: [install-playwright]
- wait-all:

- name: Run E2E test
working-directory: ${{ runner.temp }}/test-application
Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/optional-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ jobs:
artifacts-run-id: ${{ inputs.build_run_id }}
github-token: ${{ github.token }}

- name: Start E2E databases
background: true
working-directory: ${{ runner.temp }}/test-application
run: |
if [ -f docker-compose.yml ]; then
docker compose up -d --wait
fi

# Installs Playwright while the app builds. Keep it right before the build: the runner sets up a background
# composite action's steps from the job's shared `github` context, which fails with "Collection was modified" if
# a foreground step starts at that moment. Starting next to `download-artifact` also made it fail to read the event file.
Expand All @@ -101,7 +109,7 @@ jobs:
timeout-minutes: 7
run: ${{ matrix.build-command || 'pnpm test:build' }}

- wait: [install-playwright]
- wait-all:

- name: Run E2E test
working-directory: ${{ runner.temp }}/test-application
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,5 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
// `--wait` blocks until the healthchecks in docker-compose.yml pass, so the app
// can connect immediately.
export default async function globalSetup() {
// Each run copies this app to a fresh temp dir, so `docker compose` doesn't
Comment thread
nicohrubec marked this conversation as resolved.
Resolved
// recognize a leftover container from a previous (e.g. interrupted) run as
// part of the same project - but the container names are fixed, so the daemon
// still refuses to create new ones. Force-remove any stale leftovers first.
for (const container of ['e2e-tests-create-remix-app-v2-mysql', 'e2e-tests-create-remix-app-v2-redis']) {
try {
execSync(`docker rm -f ${container}`, { stdio: 'ignore' });
} catch {
// no stale container to remove
}
}
execSync('docker compose up -d --wait', { cwd: __dirname, stdio: 'inherit' });
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ const getStartCommand = () => {

const config = getPlaywrightConfig({
startCommand: getStartCommand(),
// Nuxt opens its port before the development server can handle requests.
url: 'http://localhost:3030',
});

export default {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const getStartCommand = () => {

const config = getPlaywrightConfig({
startCommand: getStartCommand(),
// Nuxt opens its port before the development server can handle requests.
url: 'http://localhost:3030',
});

export default {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,5 @@ import { fileURLToPath } from 'url';
const __dirname = dirname(fileURLToPath(import.meta.url));

export default async function globalSetup() {
// Each run copies this app to a fresh temp dir, so `docker compose` doesn't

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just aligning the behavior here with what we do in other e2e applications that use a compose file

// recognize a leftover container from a previous (e.g. interrupted) run as
// part of the same project - but the container names are fixed, so the daemon
// still refuses to create new ones. Force-remove any stale leftovers first.
for (const container of [
'e2e-tests-react-router-7-instrumentation-redis',
'e2e-tests-react-router-7-instrumentation-mysql',
]) {
try {
execSync(`docker rm -f ${container}`, { stdio: 'ignore' });
} catch {
// no stale container to remove
}
}
execSync('docker compose up -d --wait', { cwd: __dirname, stdio: 'inherit' });
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { execSync } from 'child_process';
import { dirname } from 'path';
import { fileURLToPath } from 'url';

const __dirname = dirname(fileURLToPath(import.meta.url));

export default async function globalTeardown() {
execSync('docker compose down --volumes', {
cwd: __dirname,
stdio: 'inherit',
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ const config = getPlaywrightConfig(
port: 3030,
},
// Boot Redis before the tests run, outside the webServer startup-timeout window.
{ globalSetup: fileURLToPath(new URL('./global-setup.mjs', import.meta.url)) },
{
globalSetup: fileURLToPath(new URL('./global-setup.mjs', import.meta.url)),
globalTeardown: fileURLToPath(new URL('./global-teardown.mjs', import.meta.url)),
},
);

export default config;
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,5 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
// pull happens outside Playwright's webServer startup-timeout window. `--wait`
// blocks until the healthcheck passes;
export default async function globalSetup() {
// Each run copies this app to a fresh temp dir, so `docker compose` doesn't
// recognize a leftover container from a previous (e.g. interrupted) run as
// part of the same project - but the container name is fixed, so the daemon
// still refuses to create a new one. Force-remove any stale leftover first.
try {
execSync('docker rm -f e2e-tests-react-router-7-redis', { stdio: 'ignore' });
} catch {
// no stale container to remove
}
execSync('docker compose up -d --wait', { cwd: __dirname, stdio: 'inherit' });
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { execSync } from 'child_process';
import { dirname } from 'path';
import { fileURLToPath } from 'url';

const __dirname = dirname(fileURLToPath(import.meta.url));

export default async function globalTeardown() {
execSync('docker compose down --volumes', {
cwd: __dirname,
stdio: 'inherit',
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ const config = getPlaywrightConfig(
port: 3030,
},
// Boot Redis before the tests run, outside the webServer startup-timeout window.
{ globalSetup: fileURLToPath(new URL('./global-setup.mjs', import.meta.url)) },
{
globalSetup: fileURLToPath(new URL('./global-setup.mjs', import.meta.url)),
globalTeardown: fileURLToPath(new URL('./global-teardown.mjs', import.meta.url)),
},
);

export default config;
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,5 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
// pull happens outside Playwright's webServer startup-timeout window. `--wait`
// blocks until the healthcheck passes;
export default async function globalSetup() {
// Each run copies this app to a fresh temp dir, so `docker compose` doesn't
// recognize a leftover container from a previous (e.g. interrupted) run as
// part of the same project - but the container name is fixed, so the daemon
// still refuses to create a new one. Force-remove any stale leftover first.
try {
execSync('docker rm -f e2e-tests-react-router-8-redis e2e-tests-react-router-8-mysql', { stdio: 'ignore' });
} catch {
// no stale container to remove
}
execSync('docker compose up -d --wait', { cwd: __dirname, stdio: 'inherit' });
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { execSync } from 'child_process';
import { dirname } from 'path';
import { fileURLToPath } from 'url';

const __dirname = dirname(fileURLToPath(import.meta.url));

export default async function globalTeardown() {
execSync('docker compose down --volumes', {
cwd: __dirname,
stdio: 'inherit',
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ const config = getPlaywrightConfig(
port: 3030,
},
// Boot Redis before the tests run, outside the webServer startup-timeout window.
{ globalSetup: fileURLToPath(new URL('./global-setup.mjs', import.meta.url)) },
{
globalSetup: fileURLToPath(new URL('./global-setup.mjs', import.meta.url)),
globalTeardown: fileURLToPath(new URL('./global-teardown.mjs', import.meta.url)),
},
);

export default config;
3 changes: 2 additions & 1 deletion dev-packages/test-utils/src/playwright-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export function getPlaywrightConfig(
options?: {
startCommand?: string;
port?: number;
url?: string;
eventProxyPort?: number;
eventProxyFile?: string;
},
Expand Down Expand Up @@ -89,7 +90,7 @@ export function getPlaywrightConfig(
// TS just can't infer that and thinks it could also be undefined or an object.
config.webServer.push({
command: startCommand,
port: appPort,
...(options?.url ? { url: options.url } : { port: appPort }),
stdout: 'pipe',
stderr: 'pipe',
env: {
Expand Down
Loading