Skip to content
Draft
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
70 changes: 70 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,76 @@ jobs:
- run: npm ci
- run: npm run test

e2e:
name: "e2e tests"
runs-on: ubuntu-latest
services:
perses:
image: persesdev/perses:latest
ports: ["8080:8080"]
env:
PERSES_SECURITY_READONLY: "false"
PERSES_SECURITY_ENABLE_AUTH: "false"
PERSES_SECURITY_AUTHENTICATION_PROVIDERS_ENABLE_NATIVE: "false"
PERSES_SECURITY_AUTHENTICATION_DISABLE_SIGN_UP: "true"
PERSES_PLUGIN_ENABLE_DEV: "true"
steps:
- name: checkout repository
uses: actions/checkout@v4

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm

- name: Install dependencies
run: |
npm ci
npm ci --prefix e2e

- name: Install percli
run: |
PERSES_VERSION=$(docker inspect $(docker ps -q --filter "ancestor=persesdev/perses:latest") --format '{{ index .Config.Labels "org.opencontainers.image.version" }}')
echo "Detected Latest Version: $PERSES_VERSION"
URL="https://github.com/perses/perses/releases/download/v$PERSES_VERSION/perses_${PERSES_VERSION}_linux_amd64.tar.gz"
echo "Download percli URL $URL"

curl -sL "$URL" | tar -xz
sudo mv perses /usr/local/bin/percli
chmod +x percli
percli version

- name: Install Playwright Browsers
run: npx playwright install --with-deps
working-directory: e2e

- name: Setup Perses and Start Plugins
run: |
# Handshake with server on port 8080
percli login http://localhost:8080

# It is better to keep it a static array
PLUGINS=("table" "tracetable")

for plugin in "${PLUGINS[@]}"; do
cd "$plugin" && npm run dev -- --port 3005 > /dev/null 2>&1 &

sleep 10

percli plugin start "./$plugin" http://172.17.0.1:3005

echo "Verifying running plugins:"
percli plugin list

npm run test:ci --prefix e2e -- "tests/$plugin"

echo "Releasing port 3005"
# Kill any process using port 3005
fuser -k 3005/tcp > /dev/null 2>&1 || true
sleep 2
done

type-check:
name: "type-check"
runs-on: ubuntu-latest
Expand Down
3 changes: 2 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"printWidth": 120,
"singleQuote": true,
"trailingComma": "es5"
"trailingComma": "es5",
"endOfLine": "auto"
}
8 changes: 8 additions & 0 deletions e2e/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

# Playwright
node_modules/
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
/playwright/.auth/
97 changes: 97 additions & 0 deletions e2e/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions e2e/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "e2e",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test:ci": "npx playwright test --workers=1 --reporter=github,list",
"test:install": "npx playwright install --with-deps"
},
"keywords": [],
"author": "",
"license": "ISC",
"description": "",
"devDependencies": {
"@playwright/test": "^1.58.2",
"@types/node": "^25.2.3"
}
}
30 changes: 30 additions & 0 deletions e2e/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { defineConfig, devices } from '@playwright/test';

export default defineConfig({
// Point to the parent directory of your plugin subfolders
testDir: './tests',
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
reporter: 'html',

use: {
/* Perses container is exposed on localhost:8080 */
baseURL: 'http://localhost:8080',
trace: 'on-first-retry',
screenshot: 'only-on-failure',
video: 'retain-on-failure',
},

projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
],

expect: {
timeout: 10000,
},
});
8 changes: 8 additions & 0 deletions e2e/tests/table/table.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { test, expect } from '@playwright/test';

/* WAS ONLY ADDED FOR DEMONSTRATIONS*/
test.describe('table Plugin', () => {
test('sample test should always pass', async () => {
expect(true).toBeTruthy();
});
});
8 changes: 8 additions & 0 deletions e2e/tests/tracetable/tracetable.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { test, expect } from '@playwright/test';

/* WAS ONLY ADDED FOR DEMONSTRATIONS*/
test.describe('tacetable Plugin', () => {
test('sample test should always pass', async () => {
expect(true).toBeTruthy();
});
});
Loading