Skip to content

Commit

Permalink
Merge branch 'testing-actions' into uncached-e2e-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wusteven815 committed Feb 28, 2024
2 parents 65eed6b + 05dcc22 commit ee36c00
Show file tree
Hide file tree
Showing 12 changed files with 82 additions and 46 deletions.
40 changes: 3 additions & 37 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
push:
branches:
- main
- test-273-e2e
- 'release/**'
pull_request:
branches:
Expand All @@ -13,11 +12,6 @@ on:

jobs:
e2e-test:
services:
registry:
image: registry:2
ports:
- 5000:5000
runs-on: ubuntu-22.04
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -26,36 +20,8 @@ jobs:
- name: Checkout
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 i @playwright/test

- name: Start Deephaven
run: npm run docker -- --detach

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

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

- name: Run Playwright tests
run: PLAYWRIGHT_BROWSERS_PATH=0 npx playwright test
- name: Run tests
run: "./tools/run_docker.sh e2e-tests"

- name: Upload Playwright report
uses: actions/upload-artifact@v4
Expand All @@ -67,7 +33,7 @@ jobs:

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

- name: Upload server logs
if: failure()
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ COPY --link docker/config/deephaven.prop /opt/deephaven/config/deephaven.prop
COPY --link docker/data /data

# Set the environment variable to enable the JS plugins embedded in Python
ENV DEEPHAVEN_ENABLE_PY_JS=true
ENV DEEPHAVEN_ENABLE_PY_JS=true
27 changes: 27 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,35 @@ services:
pull: true
ports:
- '${DEEPHAVEN_PORT:-10000}:10000'
expose:
- 10000
volumes:
- ./docker/data/:/data
- ./tests/app.d:/app.d
environment:
- START_OPTS=-Xmx4g -DAuthHandlers=io.deephaven.auth.AnonymousAuthenticationHandler -Ddeephaven.console.type=python -Ddeephaven.application.dir=./app.d

e2e-tests:
build:
dockerfile: ./tests/Dockerfile
ports:
- 9323:9323
ipc: host
expose:
- 9323
volumes:
- ./tests:/work/tests
- ./test-results:/work/test-results
- ./playwright-report:/work/playwright-report
entrypoint: "npx playwright test --config=playwright-ci.config.ts"
depends_on:
deephaven-plugins:
condition: service_healthy

update-snapshots:
extends:
service: e2e-tests
entrypoint: 'npx playwright test --config=playwright-ci.config.ts --update-snapshots'
depends_on:
deephaven-plugins:
condition: service_healthy
1 change: 1 addition & 0 deletions docker/config/deephaven.prop
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ includefiles=dh-defaults.prop
deephaven.console.type=python

# Add all plugins that you want installed here
deephaven.jsPlugins.@deephaven/js-plugin-plotly=/opt/deephaven/config/plugins/plugins/plotly/src/js
deephaven.jsPlugins.@deephaven/js-plugin-matplotlib=/opt/deephaven/config/plugins/plugins/matplotlib/src/js
deephaven.jsPlugins.@deephaven/js-plugin-ui=/opt/deephaven/config/plugins/plugins/ui/src/js

Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"./plugins/*/src/js/"
],
"scripts": {
"docker": "docker compose up --build",
"docker": "docker compose up deephaven-plugins --build",
"start": "run-p \"start:packages -- {@}\" serve:plugins --",
"build": "lerna run build --stream",
"serve:plugins": "vite",
Expand All @@ -15,7 +15,9 @@
"test:ci": "run-p test:ci:*",
"test:ci:unit": "jest --config jest.config.unit.cjs --ci --cacheDirectory $PWD/.jest-cache",
"test:ci:lint": "jest --config jest.config.lint.cjs --ci --cacheDirectory $PWD/.jest-cache",
"e2e": "playwright test"
"e2e": "playwright run",
"e2e:docker": "./tools/run_docker.sh e2e-tests",
"e2e:update-snapshots": "./tools/run_docker.sh update-snapshots"
},
"devDependencies": {
"@deephaven/babel-preset": "^0.40.0",
Expand Down
13 changes: 13 additions & 0 deletions playwright-ci.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { PlaywrightTestConfig } from '@playwright/test';
import DefaultConfig from './playwright.config';

const config: PlaywrightTestConfig = {
...DefaultConfig,
use: {
...DefaultConfig.use,
baseURL: 'http://deephaven-plugins:10000/ide/',
},
reporter: [['github'], ['html']],
};

export default config;
9 changes: 9 additions & 0 deletions tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# 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.41.2-jammy AS playwright
WORKDIR /work/

RUN npm install @playwright/[email protected]
COPY playwright.config.ts .
COPY playwright-ci.config.ts .
2 changes: 1 addition & 1 deletion tests/express.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { openPanel, gotoPage } from './utils';

test('Express loads', async ({ page }) => {
await gotoPage(page, '');
await openPanel(page, 'express_fig');
await openPanel(page, 'express_fig', '.js-plotly-plot');
await expect(page.locator('.iris-chart-panel')).toHaveScreenshot(
'express_fig.png'
);
Expand Down
2 changes: 1 addition & 1 deletion tests/matplotlib.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { openPanel, gotoPage } from './utils';

test('Matplotlib loads', async ({ page }) => {
await gotoPage(page, '');
await openPanel(page, 'matplotlib_fig');
await openPanel(page, 'matplotlib_fig', '.matplotlib-view');
await expect(
page.getByRole('img', { name: 'Matplotlib render' })
).toHaveScreenshot('matplotlib_plot.png');
Expand Down
2 changes: 1 addition & 1 deletion tests/ui.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { openPanel, gotoPage } from './utils';

test('UI loads', async ({ page }) => {
await gotoPage(page, '');
await openPanel(page, 'ui_component');
await openPanel(page, 'ui_component', '.ui-portal-panel');
await expect(page.locator('.ui-portal-panel')).toHaveScreenshot(
'ui_component.png'
);
Expand Down
11 changes: 8 additions & 3 deletions tests/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,15 @@ export async function gotoPage(
* Opens a panel by clicking on the Panels button and then the panel button
* @param page The page
* @param name The name of the panel
* @param panelLocator The locator for the panel, passed to `page.locator`
*/
export async function openPanel(page: Page, name: string) {
export async function openPanel(
page: Page,
name: string,
panelLocator = '.dh-panel'
) {
await test.step(`Open panel (${name})`, async () => {
const panelCount = await page.locator('.dh-panel').count();
const panelCount = await page.locator(panelLocator).count();

// open app panels menu
const appPanels = page.getByRole('button', {
Expand All @@ -46,7 +51,7 @@ export async function openPanel(page: Page, name: string) {
await targetPanel.click();

// check for panel to be loaded
await expect(page.locator('.dh-panel')).toHaveCount(panelCount + 1);
await expect(page.locator(panelLocator)).toHaveCount(panelCount + 1);
await expect(page.locator('.loading-spinner')).toHaveCount(0);
});
}
13 changes: 13 additions & 0 deletions tools/run_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

# Set pwd to this directory
pushd "$(dirname "$0")"

# Start the containers
docker compose run --service-ports --rm --build "$@"
exit_code=$?
docker compose down

# Reset pwd
popd
exit $exit_code

0 comments on commit ee36c00

Please sign in to comment.