Skip to content

Commit

Permalink
Add Grafana Bench action
Browse files Browse the repository at this point in the history
  • Loading branch information
adamyeats committed Oct 23, 2024
1 parent e8ff1eb commit 4fa0209
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 2 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/grafana-bench.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Grafana Bench
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'yarn'

- uses: actions/setup-go@v5
with:
go-version: 'stable'

- name: Build backend
uses: magefile/mage-action@v3
with:
args: buildAll
version: latest

- name: Install frontend dependencies
run: yarn install --frozen-lockfile

- name: Build frontend
run: yarn build
env:
NODE_OPTIONS: '--max_old_space_size=4096'

- name: Install and run Docker Compose
uses: hoverkraft-tech/[email protected]
with:
compose-file: './docker-compose.yml'

- name: Wait for Grafana to start
uses: nev7n/wait_for_response@v1
with:
url: 'http://localhost:3000/'
responseCode: 200
timeout: 60000
interval: 500

- name: Run Grafana Bench tests
run: |
docker run --rm \
--network=host \
--volume="./:/home/bench/tests/" \
ghcr.io/grafana/grafana-bench:v0.2.4 test \
--test-suite-base "/home/bench/tests/" \
--grafana-url "http://localhost:3000" \
--grafana-username "admin" \
--grafana-password "admin" \
--test-runner "playwright" \
--pw-prepare-cmd "yarn e2e:prepare" \
--pw-execute-cmd "yarn e2e" \
--log-level DEBUG
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"scripts": {
"build": "webpack -c ./.config/webpack/webpack.config.ts --env production",
"dev": "webpack -w -c ./.config/webpack/webpack.config.ts --env development",
"e2e:prepare": "yarn install --frozen-lockfile && yarn playwright install --with-deps",
"e2e:report": "yarn playwright show-report",
"e2e:ui": "yarn playwright test --ui",
"e2e": "playwright test",
Expand Down
13 changes: 11 additions & 2 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,21 @@ export default defineConfig<PluginOptions>({
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: `http://localhost:${process.env.PORT || 3000}`,
baseURL: process.env.GRAFANA_URL || `http://localhost:${process.env.PORT || 3000}`,

grafanaAPICredentials: {
user: process.env.GRAFANA_USER || 'admin',
password: process.env.GRAFANA_PASSWORD || 'admin',
},

launchOptions: {
executablePath: process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH,
},

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
screenshot: 'only-on-failure',
video: 'on'
video: 'on',
},

/* Configure projects for major browsers */
Expand Down

0 comments on commit 4fa0209

Please sign in to comment.