diff --git a/.github/workflows/grafana-bench.yml b/.github/workflows/grafana-bench.yml new file mode 100644 index 00000000..04b0ed0a --- /dev/null +++ b/.github/workflows/grafana-bench.yml @@ -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/compose-action@v2.0.2 + 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 + diff --git a/package.json b/package.json index f2693435..2da714e9 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/playwright.config.ts b/playwright.config.ts index 2b3b068a..73e85542 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -26,12 +26,21 @@ export default defineConfig({ /* 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 */