Skip to content

Commit d639f0b

Browse files
committed
WIP: Run E2E against Grafana Cloud
1 parent 680a2ea commit d639f0b

File tree

3 files changed

+146
-3
lines changed

3 files changed

+146
-3
lines changed

.github/workflows/cloud-e2e.yml

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
name: Grafana Cloud E2E tests
2+
3+
on:
4+
schedule:
5+
- cron: '0 9 * * *' # Daily at 09:00 UTC
6+
7+
# TODO: test, remove later
8+
push:
9+
branches:
10+
- main
11+
pull_request:
12+
13+
defaults:
14+
run:
15+
shell: bash
16+
17+
permissions:
18+
contents: read
19+
20+
jobs:
21+
# @TODO: Remove the `build` job later
22+
build:
23+
name: Build
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v5
27+
with:
28+
persist-credentials: false
29+
30+
- uses: step-security/harden-runner@v2 # zizmor: ignore[unpinned-uses]
31+
with:
32+
egress-policy: audit
33+
34+
- uses: actions/setup-go@v6
35+
with:
36+
go-version: 'stable'
37+
38+
- name: Build backend
39+
uses: magefile/mage-action@6f50bbb8ea47d56e62dee92392788acbc8192d0b
40+
with:
41+
args: buildAll
42+
version: latest
43+
44+
- name: Install frontend dependencies
45+
run: npm ci --no-audit --fund=false
46+
47+
- name: Build frontend
48+
run: npm run build
49+
env:
50+
NODE_OPTIONS: '--max_old_space_size=4096'
51+
52+
- name: Upload dist artifacts
53+
uses: actions/upload-artifact@v4
54+
with:
55+
if-no-files-found: error
56+
name: dist-artifacts
57+
path: dist
58+
retention-days: 2
59+
60+
e2e:
61+
name: Bench Tests
62+
needs: build
63+
runs-on: ubuntu-latest
64+
timeout-minutes: 60
65+
66+
permissions:
67+
contents: read
68+
id-token: write
69+
70+
steps:
71+
- uses: actions/checkout@v5
72+
with:
73+
persist-credentials: false
74+
75+
- uses: step-security/harden-runner@v2 # zizmor: ignore[unpinned-uses]
76+
with:
77+
egress-policy: audit
78+
79+
- name: Setup Node.js environment
80+
uses: actions/setup-node@v6
81+
with:
82+
node-version-file: .nvmrc
83+
cache: 'npm'
84+
85+
- name: Download GitHub artifact
86+
uses: actions/download-artifact@v5
87+
with:
88+
name: dist-artifacts
89+
path: dist
90+
91+
- name: Get secrets from Vault
92+
id: get-secrets
93+
# Only execute this action in a trusted context
94+
if: |
95+
github.event_name != 'pull_request' ||
96+
github.event.pull_request.head.repo.full_name == github.repository
97+
uses: grafana/shared-workflows/actions/get-vault-secrets@get-vault-secrets/v1.3.0
98+
with:
99+
common_secrets: |
100+
PLAYWRIGHT_GRAFANA_PASSWORD=data-sources/e2e:grafana-pw
101+
PLAYWRIGHT_GRAFANA_USERNAME=data-sources/e2e:grafana-username
102+
repo_secrets: |
103+
DS_INSTANCE_HOST=ds-instance:host
104+
DS_INSTANCE_PASSWORD=ds-instance:password
105+
DS_INSTANCE_PORT=ds-instance:port
106+
DS_INSTANCE_USERNAME=ds-instance:username
107+
export_env: false
108+
109+
- name: Install npm dependencies
110+
run: |
111+
if [ -f yarn.lock ]; then
112+
yarn install --frozen-lockfile --non-interactive
113+
else
114+
npm ci --no-audit --fund=false
115+
fi
116+
117+
- name: Install Playwright Browsers
118+
run: npx playwright install --with-deps chromium
119+
120+
- name: Wait for Grafana to start
121+
uses: grafana/plugin-actions/wait-for-grafana@wait-for-grafana/v1.0.2
122+
with:
123+
url: "https://datasourcese2e.grafana-dev.net/login"
124+
125+
- name: Run Grafana Bench tests
126+
run: |
127+
set -euo pipefail
128+
docker run \
129+
--rm \
130+
--network=host \
131+
--volume "$PWD:/tests" \
132+
us-docker.pkg.dev/grafanalabs-global/docker-grafana-bench-prod/grafana-bench-playwright:v0.6.3 test \
133+
--grafana-admin-password "${{ fromJSON(steps.get-secrets.outputs.secrets).PLAYWRIGHT_GRAFANA_PASSWORD }}" \
134+
--grafana-admin-user "${{ fromJSON(steps.get-secrets.outputs.secrets).PLAYWRIGHT_GRAFANA_USERNAME }}" \
135+
--grafana-url "https://datasourcese2e.grafana-dev.net" \
136+
--log-level debug \
137+
--pw-execute "npm run e2e" \
138+
--pw-prepare "npm install --frozen-lockfile; npx playwright install" \
139+
--test-env-vars "CI=true" \
140+
--test-runner playwright
141+

.github/workflows/push.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ jobs:
1616
contents: read
1717
id-token: write
1818
with:
19-
plugin-version-suffix: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || '' }}
2019
go-version: '1.24'
2120
golangci-lint-version: '2.1.6'
21+
plugin-version-suffix: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || '' }}

playwright.config.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { dirname } from 'path';
2+
13
import { defineConfig, devices } from '@playwright/test';
24
import type { PluginOptions } from '@grafana/plugin-e2e';
35

@@ -42,14 +44,14 @@ export default defineConfig<PluginOptions>({
4244
projects: [
4345
{
4446
name: 'auth',
45-
testDir: 'node_modules/@grafana/plugin-e2e/dist/auth',
47+
testDir: `${dirname(require.resolve('@grafana/plugin-e2e'))}/auth`,
4648
testMatch: [/.*\.js/],
4749
},
4850
{
4951
name: 'run-tests',
5052
use: {
5153
...devices['Desktop Chrome'],
52-
storageState: 'playwright/.auth/admin.json',
54+
storageState: `playwright/.auth/${process.env.GRAFANA_ADMIN_USER || 'admin'}.json`,
5355
},
5456
dependencies: ['auth'],
5557
},

0 commit comments

Comments
 (0)