Build Docker image on slim base (#3204)
* Build Docker image on slim base * Run Playwright tests against Docker container For Playwright end-to-end tests in CI, instead of running a development webserver with `yarn dev`, build and deploy a Docker container for Element Call and use that as the webserver to test against. * Shut down playwright webserver gracefully When using a containerized webserver, this stops the container once tests finish. * Increase Playwright timeout in CI --------- Co-authored-by: fkwp <github-fkwp@w4ve.de>
This commit is contained in:
committed by
GitHub
parent
e0ce58b2a2
commit
13fac57b01
6
.github/workflows/test.yaml
vendored
6
.github/workflows/test.yaml
vendored
@@ -30,7 +30,7 @@ jobs:
|
|||||||
fail_ci_if_error: true
|
fail_ci_if_error: true
|
||||||
playwright:
|
playwright:
|
||||||
name: Run end-to-end tests
|
name: Run end-to-end tests
|
||||||
timeout-minutes: 10
|
timeout-minutes: 30
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
||||||
@@ -49,9 +49,9 @@ jobs:
|
|||||||
docker compose -f playwright-backend-docker-compose.yml -f playwright-backend-docker-compose.override.yml pull
|
docker compose -f playwright-backend-docker-compose.yml -f playwright-backend-docker-compose.override.yml pull
|
||||||
docker compose -f playwright-backend-docker-compose.yml -f playwright-backend-docker-compose.override.yml up -d
|
docker compose -f playwright-backend-docker-compose.yml -f playwright-backend-docker-compose.override.yml up -d
|
||||||
docker ps
|
docker ps
|
||||||
- name: Copy config file
|
|
||||||
run: cp config/config.devenv.json public/config.json
|
|
||||||
- name: Run Playwright tests
|
- name: Run Playwright tests
|
||||||
|
env:
|
||||||
|
USE_DOCKER: 1
|
||||||
run: yarn playwright test
|
run: yarn playwright test
|
||||||
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
|
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
|
||||||
if: ${{ !cancelled() }}
|
if: ${{ !cancelled() }}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ COPY ./dist /dist
|
|||||||
WORKDIR /dist/assets
|
WORKDIR /dist/assets
|
||||||
RUN gzip -k ../index.html *.js *.map *.css *.wasm *-app-*.json
|
RUN gzip -k ../index.html *.js *.map *.css *.wasm *-app-*.json
|
||||||
|
|
||||||
FROM nginxinc/nginx-unprivileged:alpine
|
FROM nginxinc/nginx-unprivileged:alpine-slim
|
||||||
|
|
||||||
COPY --from=builder ./dist /app
|
COPY --from=builder ./dist /app
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,10 @@ Please see LICENSE in the repository root for full details.
|
|||||||
|
|
||||||
import { defineConfig, devices } from "@playwright/test";
|
import { defineConfig, devices } from "@playwright/test";
|
||||||
|
|
||||||
|
const baseURL = process.env.USE_DOCKER
|
||||||
|
? "http://localhost:8080"
|
||||||
|
: "https://localhost:3000";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See https://playwright.dev/docs/test-configuration.
|
* See https://playwright.dev/docs/test-configuration.
|
||||||
*/
|
*/
|
||||||
@@ -25,7 +29,7 @@ export default defineConfig({
|
|||||||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
||||||
use: {
|
use: {
|
||||||
/* Base URL to use in actions like `await page.goto('/')`. */
|
/* Base URL to use in actions like `await page.goto('/')`. */
|
||||||
baseURL: "https://localhost:3000",
|
baseURL,
|
||||||
|
|
||||||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
||||||
trace: "on-first-retry",
|
trace: "on-first-retry",
|
||||||
@@ -73,9 +77,13 @@ export default defineConfig({
|
|||||||
|
|
||||||
/* Run your local dev server before starting the tests */
|
/* Run your local dev server before starting the tests */
|
||||||
webServer: {
|
webServer: {
|
||||||
command: "yarn dev",
|
command: "./scripts/playwright-webserver-command.sh",
|
||||||
url: "https://localhost:3000",
|
url: baseURL,
|
||||||
reuseExistingServer: !process.env.CI,
|
reuseExistingServer: !process.env.CI,
|
||||||
ignoreHTTPSErrors: true,
|
ignoreHTTPSErrors: true,
|
||||||
|
gracefulShutdown: {
|
||||||
|
signal: "SIGTERM",
|
||||||
|
timeout: 500,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -69,7 +69,18 @@ const CONFIG_JSON = {
|
|||||||
* Set the Element Call URL in the dev tool settings using `window.mxSettingsStore` via `page.evaluate`.
|
* Set the Element Call URL in the dev tool settings using `window.mxSettingsStore` via `page.evaluate`.
|
||||||
* @param page
|
* @param page
|
||||||
*/
|
*/
|
||||||
async function setDevToolElementCallDevUrl(page: Page): Promise<void> {
|
const setDevToolElementCallDevUrl = process.env.USE_DOCKER
|
||||||
|
? async (page: Page): Promise<void> => {
|
||||||
|
await page.evaluate(() => {
|
||||||
|
window.mxSettingsStore.setValue(
|
||||||
|
"Developer.elementCallUrl",
|
||||||
|
null,
|
||||||
|
"device",
|
||||||
|
"http://localhost:8080/room",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
: async (page: Page): Promise<void> => {
|
||||||
await page.evaluate(() => {
|
await page.evaluate(() => {
|
||||||
window.mxSettingsStore.setValue(
|
window.mxSettingsStore.setValue(
|
||||||
"Developer.elementCallUrl",
|
"Developer.elementCallUrl",
|
||||||
@@ -78,7 +89,7 @@ async function setDevToolElementCallDevUrl(page: Page): Promise<void> {
|
|||||||
"https://localhost:3000/room",
|
"https://localhost:3000/room",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a new user and returns page, clientHandle and mxId.
|
* Registers a new user and returns page, clientHandle and mxId.
|
||||||
|
|||||||
10
scripts/playwright-webserver-command.sh
Executable file
10
scripts/playwright-webserver-command.sh
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
if [ -n "$USE_DOCKER" ]; then
|
||||||
|
set -ex
|
||||||
|
yarn build
|
||||||
|
docker build -t element-call:testing .
|
||||||
|
exec docker run --rm --name element-call-testing -p 8080:8080 -v ./config/config.devenv.json:/app/config.json:ro,Z element-call:testing
|
||||||
|
else
|
||||||
|
cp config/config.devenv.json public/config.json
|
||||||
|
exec yarn dev
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user