-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: initial e2e tests * chore: run playwright on CI
- Loading branch information
1 parent
d4695d6
commit 673e0ac
Showing
11 changed files
with
616 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
name: E2E tests | ||
on: | ||
pull_request: | ||
|
||
permissions: | ||
contents: read | ||
id-token: write | ||
|
||
jobs: | ||
resolve-versions: | ||
name: Resolve Grafana images | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 3 | ||
outputs: | ||
matrix: ${{ steps.resolve-versions.outputs.matrix }} | ||
steps: | ||
- name: Resolve Grafana E2E versions | ||
id: resolve-versions | ||
uses: grafana/plugin-actions/e2e-version@main | ||
with: | ||
version-resolver-type: version-support-policy | ||
|
||
playwright-tests: | ||
needs: resolve-versions | ||
timeout-minutes: 60 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
GRAFANA_IMAGE: ${{fromJson(needs.resolve-versions.outputs.matrix)}} | ||
name: e2e ${{ matrix.GRAFANA_IMAGE.name }}@${{ matrix.GRAFANA_IMAGE.VERSION }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup Node.js environment | ||
uses: actions/setup-node@v4 | ||
with: | ||
cache: 'yarn' | ||
node-version-file: .nvmrc | ||
|
||
- name: Install Mage | ||
uses: magefile/mage-action@v3 | ||
with: | ||
install-only: true | ||
|
||
- name: Install yarn dependencies | ||
run: yarn install | ||
|
||
- name: Build binaries | ||
run: mage -v build:linux | ||
|
||
- name: Build frontend | ||
run: yarn build | ||
|
||
- name: Install Playwright Browsers | ||
run: yarn playwright install --with-deps | ||
|
||
- name: Start Grafana | ||
run: | | ||
docker-compose pull | ||
GRAFANA_VERSION=${{ matrix.GRAFANA_IMAGE.VERSION }} GRAFANA_IMAGE=${{ matrix.GRAFANA_IMAGE.NAME }} docker-compose up -d | ||
- 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 Playwright tests | ||
id: run-tests | ||
run: yarn playwright test | ||
|
||
- name: Publish report to GCS | ||
if: ${{ (always() && steps.run-tests.outcome == 'success') || (failure() && steps.run-tests.outcome == 'failure') && github.event.organization.login == 'grafana' }} | ||
uses: grafana/plugin-actions/publish-report@main | ||
with: | ||
grafana-version: ${{ matrix.GRAFANA_IMAGE.VERSION }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { dirname } from 'path'; | ||
import { defineConfig, devices } from '@playwright/test'; | ||
|
||
const pluginE2eAuth = `${dirname(require.resolve('@grafana/plugin-e2e'))}/auth`; | ||
|
||
/** | ||
* See https://playwright.dev/docs/test-configuration. | ||
* See https://grafana.com/developers/plugin-tools/e2e-test-a-plugin/introduction | ||
*/ | ||
export default defineConfig({ | ||
testDir: './tests', | ||
fullyParallel: true, | ||
forbidOnly: !!process.env.CI, | ||
retries: process.env.CI ? 2 : 0, | ||
timeout: 60000, | ||
expect: { | ||
timeout: 30000, | ||
}, | ||
workers: process.env.CI ? 1 : undefined, | ||
reporter: 'html', | ||
use: { | ||
baseURL: 'http://localhost:3000', | ||
trace: 'on-first-retry', | ||
}, | ||
|
||
projects: [ | ||
{ | ||
name: 'auth', | ||
testDir: pluginE2eAuth, | ||
testMatch: [/.*\.js/], | ||
}, | ||
{ | ||
name: 'run-tests', | ||
use: { | ||
...devices['Desktop Chrome'], | ||
storageState: 'playwright/.auth/admin.json', | ||
}, | ||
dependencies: ['auth'], | ||
}, | ||
], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
apiVersion: 1 | ||
|
||
deleteDatasources: | ||
- name: E2E Mock IoT SiteWise | ||
orgId: 1 | ||
|
||
datasources: | ||
- name: E2E Mock IoT SiteWise | ||
type: grafana-iot-sitewise-datasource | ||
uid: e2e-mock-iot-sitewise | ||
version: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.