Skip to content
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

build: Fix e2e tests for builds on v0.78 #2315

Merged
merged 14 commits into from
Dec 26, 2024
92 changes: 26 additions & 66 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
- 'release/**'
- 'feature/**'
env:
DOCKER_TAG: edge
DHC_VERSION: 0.35.2

jobs:
build:
Expand All @@ -24,40 +24,19 @@ jobs:
cancel-in-progress: true

steps:
- name: Check installed fonts
run: 'fc-list : family'
- name: Checkout
uses: actions/checkout@v4

- uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'npm'

- name: Cache node modules
id: cache-node-modules
uses: actions/cache@v4
with:
path: |
node_modules
packages/*/node_modules
key: e2e-node-modules-${{ hashFiles('package-lock.json')}}

- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci --no-audit

- name: Build
run: npm run build
- name: Build and Save docker image
run: |
docker build -t e2e-ci:test -f ./tests/docker-scripts/Dockerfile .
docker save e2e-ci -o e2e-ci.tar.gz

- name: Upload build for test jobs
- name: Store docker build for test matrix
uses: actions/upload-artifact@v4
with:
name: web-build
path: |
*
!node_modules
name: image-cache
path: e2e-ci.tar.gz
retention-days: 1

e2e-tests:
Expand All @@ -70,68 +49,51 @@ jobs:
strategy:
fail-fast: false
matrix:
config: [chromium-1-1, firefox-1-1, webkit-1-2, webkit-2-2]
config: [chromium-1-1, firefox-1-1]

steps:
- name: Download build
uses: actions/download-artifact@v4
with:
name: web-build

- name: Run core server:${{ env.DOCKER_TAG }}
run: |
docker pull --quiet ghcr.io/deephaven/server:${{ env.DOCKER_TAG }}
docker run --detach --publish 10000:10000 --name dh-core-server -v ./tests/docker-scripts/data:/data --env "START_OPTS=-Xmx4g -DAuthHandlers=io.deephaven.auth.AnonymousAuthenticationHandler -Ddeephaven.application.dir=./data/app.d" ghcr.io/deephaven/server:${{ env.DOCKER_TAG }}
- name: Checkout
uses: actions/checkout@v4

- name: Cache node modules
id: cache-node-modules
uses: actions/cache@v4
- name: Download docker image for test matrix
uses: actions/download-artifact@v4
with:
path: |
node_modules
packages/*/node_modules
key: e2e-node-modules-${{ hashFiles('package-lock.json')}}

- name: Install Playwright dependencies
run: PLAYWRIGHT_BROWSERS_PATH=0 npx playwright install --with-deps

- name: Playwright version
run: npx playwright --version
name: image-cache

- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci --no-audit
- name: Load docker image
run: docker load -i e2e-ci.tar.gz

- name: Extract browser config
id: config
env:
MATRIX_CONFIG: ${{ matrix.config }}
run: |
echo "browser=${MATRIX_CONFIG:0:-4}" >> $GITHUB_OUTPUT
echo "shard=${MATRIX_CONFIG: -3:1}" >> $GITHUB_OUTPUT
echo "shardTotal=${MATRIX_CONFIG: -1:1}" >> $GITHUB_OUTPUT
echo "BROWSER=${MATRIX_CONFIG:0:-4}" >> $GITHUB_ENV
echo "SHARD=${MATRIX_CONFIG: -3:1}" >> $GITHUB_ENV
echo "SHARD_TOTAL=${MATRIX_CONFIG: -1:1}" >> $GITHUB_ENV

- name: Run Playwright tests
run: PLAYWRIGHT_BROWSERS_PATH=0 npx playwright test --config=playwright-ci.config.ts --reporter=blob --project=${{ steps.config.outputs.browser }} --shard=${{ steps.config.outputs.shard }}/${{ steps.config.outputs.shardTotal }}
- name: Run tests
run: './tests/docker-scripts/run.sh e2e-ci-matrix'

- name: Upload Playwright report
uses: actions/upload-artifact@v4
if: always()
if: ${{ !cancelled() }}
with:
name: playwright-report-blob-${{ matrix.config }}
path: blob-report/
retention-days: 1

- name: Dump server logs
if: failure()
run: docker logs dh-core-server > /tmp/server-log.txt
run: docker logs dhc-server > /tmp/server-log.txt

- name: Upload server logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: server-logs-${{ matrix.config }}
path: /tmp/server-log.txt
retention-days: 14

merge-reports:
if: ${{ !cancelled() }}
Expand All @@ -149,8 +111,6 @@ jobs:
mkdir -p all-blob-reports
mv playwright-report-blob-chromium-1-1/report-1.zip all-blob-reports/chromium-1-1.zip
mv playwright-report-blob-firefox-1-1/report-1.zip all-blob-reports/firefox-1-1.zip
mv playwright-report-blob-webkit-1-2/report-1.zip all-blob-reports/webkit-1-2.zip
mv playwright-report-blob-webkit-2-2/report-2.zip all-blob-reports/webkit-2-2.zip
npx playwright merge-reports --reporter html,github ./all-blob-reports

- name: Upload HTML report
Expand Down
14 changes: 7 additions & 7 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ const config: PlaywrightTestConfig = {
},
},
},

{
name: 'webkit',
use: {
...devices['Desktop Safari'],
},
},
// Disabling WebKit for v0.78, it's flakey and updating to the latest Playwright would require updating all the snapshots and reverifying them
// {
// name: 'webkit',
// use: {
// ...devices['Desktop Safari'],
// },
// },
],
};

Expand Down
55 changes: 33 additions & 22 deletions tests/docker-scripts/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,44 +1,55 @@
# This is a workaround for copying all package.json files w/ directory structure
# without needing to list every file as a COPY command
# The copy --from=copy-packages command will be a cache hit if the package.json files didn't change
FROM alpine AS copy-packages
WORKDIR /work/
COPY . /tmp/web-client-ui
COPY package.json package-lock.json skip.js ./
# cd first so the cp doesn't include /tmp/web-client-ui in the paths
RUN cd /tmp/web-client-ui && cp --parents ./packages/*/package.json /work/

# syntax=docker/dockerfile:1
# Dockerfile for updating the snapshots.
# Expects to be run from the root of the web-client-ui repo
FROM mcr.microsoft.com/playwright:v1.37.1-jammy AS playwright
WORKDIR /work/

# Update packages list and install some build tools.
# Installing fonts-dejavu-core so we have some common fonts with the GH actions
# runner that can be used to render unicode fonts. See README for more info.
# Update packages list and install some build tools
RUN set -eux; \
apt-get update; \
apt-get install build-essential --yes; \
apt-get install fonts-dejavu-core --yes;
apt-get install build-essential --yes;

# print installed fonts for debugging
RUN fc-list : family;

# Copy just the .nvmrc first and install nvm/node/npm first as these will change the least often
# https://docs.docker.com/build/cache/
COPY .nvmrc .

# Set the default shell so the correct node/npm is used after install
# https://stackoverflow.com/a/60137919
SHELL ["/bin/bash", "--login", "-i", "-c"]
# nvm needs to be run in a bash shell
SHELL ["/bin/bash", "--login", "-c"]
# The default `.bashrc` bails on the first line if not in interactive shell.
# We can just empty it so that the nvm install below will actually run when sourcing
# `.bashrc`
RUN echo "" > /root/.bashrc
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
RUN source /root/.bashrc && nvm install
SHELL ["/bin/bash", "--login", "-c"]

# This is a workaround for copying all package.json files w/ directory structure
# without needing to list every file as a COPY command
# The copy --from=copy-packages command will be a cache hit if the package.json files didn't change
FROM alpine AS copy-packages
WORKDIR /work/
COPY . /tmp/web-client-ui
COPY package.json package-lock.json skip.js ./
# cd first so the cp doesn't include /tmp/web-client-ui in the paths
RUN cd /tmp/web-client-ui && cp --parents ./packages/*/package.json /work/

FROM playwright AS build
WORKDIR /work/
# Now clobber the default node installed by the playwright
# image so that the commands in docker compose entrypoint will
# also use the correct version of node without running in bash
RUN ln -s $(which node) /usr/local/bin/nodejs
RUN ln -s $(which node) /usr/local/bin/node
RUN ln -s $(which npm) /usr/local/bin/npm


# Copy the package.json files
COPY --from=copy-packages /work/ .

# Confirm node version is correct for debugging
RUN node --version

# Disable the postinstall script, or npm ci will try and build and the files won't be there
# We don't need the postinstall since we're going to rebuild right after
RUN SKIP_POSTINSTALL=1 npm ci
Expand All @@ -49,5 +60,5 @@ RUN SKIP_POSTINSTALL=1 npm ci
# https://stackoverflow.com/a/34300129
COPY . .

# Now build the app
RUN npm run build
# Now build the app with our playwright.css included
RUN VITE_PLAYWRIGHT_CSS=1 npm run build
21 changes: 18 additions & 3 deletions tests/docker-scripts/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
version: '3.8'

services:
dhc-server:
image: ghcr.io/deephaven/server:${DHC_VERSION:-edge}
container_name: dhc-server
image: ghcr.io/deephaven/server:${DHC_VERSION:-0.35.2}
pull_policy: always
volumes:
- ./data:/data
Expand All @@ -11,6 +10,22 @@ services:
environment:
- START_OPTS=-Xmx4g -DAuthHandlers=io.deephaven.auth.AnonymousAuthenticationHandler -Ddeephaven.console.type=python -Ddeephaven.application.dir=./data/app.d

e2e-ci-matrix:
# requires the image built by CI to be provided
image: e2e-ci:test
ipc: host
environment:
- VITE_PROXY_URL=http://dhc-server:10000
volumes:
- ../../tests:/work/tests
- ../../test-results:/work/test-results
- ../../playwright-report:/work/playwright-report
- ../../blob-report:/work/blob-report
entrypoint: 'npm run e2e -- --config=playwright-ci.config.ts --reporter=blob --project=${BROWSER:-chromium} --shard=${SHARD:-1}/${SHARD_TOTAL:-1}'
depends_on:
dhc-server:
condition: service_healthy

web-ui-tests:
build:
context: ../../
Expand Down
Binary file modified tests/styleguide.spec.ts-snapshots/grids-tree-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/styleguide.spec.ts-snapshots/grids-tree-firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/styleguide.spec.ts-snapshots/grids-tree-webkit-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tests/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export function generateVarName(prefix = 'v'): string {
* @param browser
*/
export async function logBrowserInfo(): Promise<void> {
const launchers = [chromium, firefox, webkit];
const launchers = [chromium, firefox];

await Promise.all(
launchers.map(async launcher => {
Expand Down
Loading