Skip to content

Commit

Permalink
Add E2E Cypress testing (#29)
Browse files Browse the repository at this point in the history
* Add E2E Cypress testing

* Add minimum Grafana check

* Update screenshot and README

* Update docker-compose-nginx.yml

* Update CHANGELOG.md
  • Loading branch information
mikhail-vl authored Jun 25, 2023
1 parent 1d64c9a commit 00e895f
Show file tree
Hide file tree
Showing 10 changed files with 113 additions and 15 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: E2E

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
tests:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'npm'

- name: Install dependencies
run: npm install

- name: Build
run: npm run build

- name: Start Grafana (latest version)
run: docker-compose up -d

- name: Run e2e tests
run: npm run e2e

- name: Stop Grafana
run: docker-compose down

- name: Start Grafana (minimum required version)
run: docker-compose -f docker-compose-min.yml up -d

- name: Run e2e tests
run: npm run e2e

- name: Stop Grafana
run: docker-compose -f docker-compose-min.yml down

- uses: actions/upload-artifact@v3
if: failure()
with:
path: |
cypress/videos
cypress/screenshots/actual
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
# Changelog

## 2.5.0 (2023-06-25)
## 3.0.0 (2023-06-25)

### Breaking changes

- Requires Grafana 9 and Grafana 10

### Features / Enhancements

- Update unit tests with testing-library/react (#27)
- Migrate to Plugin Tools 1.5.2 (#28)
- Update to Node 18 and npm (#28)
- Update to Grafana 10.0.0 (#28)
- Add E2E Cypress testing (#29)
- Remove Grafana 8.5 support (#29)

## 2.4.0 (2023-05-13)

Expand Down
18 changes: 7 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

![Grafana](https://img.shields.io/badge/Grafana-10.0.0-orange)
![CI](https://github.com/volkovlabs/volkovlabs-env-datasource/workflows/CI/badge.svg)
![E2E](https://github.com/volkovlabs/volkovlabs-env-datasource/workflows/E2E/badge.svg)
[![codecov](https://codecov.io/gh/VolkovLabs/volkovlabs-env-datasource/branch/main/graph/badge.svg?token=2W9VR0PG5N)](https://codecov.io/gh/VolkovLabs/volkovlabs-env-datasource)
[![CodeQL](https://github.com/VolkovLabs/volkovlabs-env-datasource/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/VolkovLabs/volkovlabs-env-datasource/actions/workflows/codeql-analysis.yml)

Expand All @@ -15,16 +16,16 @@ The Environment Data Source is a plugin for Grafana that returns environment var

## Requirements

- **Grafana 10** is supported.
- **Grafana 8.5+**, **Grafana 9.0+** is required for major version 2.
- **Grafana 8.0+** is required for major version 1.
- **Grafana 9**, and **Grafana 10** are required for major version 3.
- **Grafana 8.5+** and **Grafana 9** are required for major version 2.
- **Grafana 8** is required for major version 1.

## Getting Started

Environment Data Source is not included in the Grafana Catalog. It can be installed from our Private Repository or downloaded directly from GitHub.
Environment Data Source is not included in the Grafana Catalog. It can be installed directly from GitHub.

```bash
grafana-cli --repo https://volkovlabs.io/plugins plugins install volkovlabs-env-datasource
grafana cli --pluginUrl https://github.com/VolkovLabs/volkovlabs-env-datasource/releases/download/v3.0.0/volkovlabs-env-datasource-3.0.0.zip plugins install volkovlabs-env-datasource
```

## Highlights
Expand All @@ -38,15 +39,10 @@ grafana-cli --repo https://volkovlabs.io/plugins plugins install volkovlabs-env-
| Section | Description |
| ---------------------------- | ------------------------------------------------------------ |
| [Deployment](https://volkovlabs.io/plugins/volkovlabs-env-datasource/deployment/) | Explains deployment options for the data source. |
| [Features](https://volkovlabs.io/plugins/volkovlabs-env-datasource/features/) | Demonstrates data source features. |
| [Provisioning](https://volkovlabs.io/plugins/volkovlabs-env-datasource/provisioning/) | Demonstrates how to automatically provision the data Source. |
| [Release Notes](https://volkovlabs.io/plugins/volkovlabs-env-datasource/release/) | Stay up to date with the latest features and updates. |

### Features

| Section | Description |
| -------------------------------- | -------------------------------------------- |
| [Dashboard Variables](https://volkovlabs.io/plugins/volkovlabs-env-datasource/variables/) | Demonstrates how to use Dashboard variables. |

## Support

We provide GitHub Discussions and Premium tier support for the development plugins available via [GitHub Sponsor](https://github.com/sponsors/VolkovLabs).
Expand Down
23 changes: 23 additions & 0 deletions cypress/integration/01-view-panel.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { e2e } from '@grafana/e2e';

/**
* Dashboard
*/
const json = require('../../provisioning/dashboards/panels.json');
const testedPanel = json.panels[0];

/**
* Panel
*/
describe('Viewing a panel with a Data Source', () => {
beforeEach(() => {
e2e.flows.openDashboard({
uid: json.uid,
});
});

it('Should display a Table with Environment Variables', () => {
const currentPanel = e2e.components.Panels.Panel.title(testedPanel.title);
currentPanel.should('be.visible');
});
});
5 changes: 5 additions & 0 deletions cypress/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"compilerOptions": {
"types": ["cypress"]
}
}
15 changes: 15 additions & 0 deletions docker-compose-min.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: '3.4'

services:
grafana:
container_name: grafana
image: grafana/grafana:9.0.0
ports:
- 3000:3000
environment:
- GF_AUTH_ANONYMOUS_ENABLED=true
- GF_DEFAULT_APP_MODE=development
- GF_DASHBOARDS_DEFAULT_HOME_DASHBOARD_PATH=/etc/grafana/provisioning/dashboards/panels.json
volumes:
- ./dist:/var/lib/grafana/plugins/volkovlabs-env-datasource
- ./provisioning:/etc/grafana/provisioning
2 changes: 1 addition & 1 deletion docker-compose-nginx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
ports:
- 3000:3000/tcp
environment:
- GF_INSTALL_PLUGINS=https://github.com/VolkovLabs/volkovlabs-env-datasource/releases/download/v2.4.0/volkovlabs-env-datasource-2.4.0.zip;volkovlabs-env-datasource
- GF_INSTALL_PLUGINS=https://github.com/VolkovLabs/volkovlabs-env-datasource/releases/download/v3.0.0/volkovlabs-env-datasource-3.0.0.zip;volkovlabs-env-datasource
volumes:
- ./provisioning:/etc/grafana/provisioning

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,5 @@
"test:ci": "jest --maxWorkers 4 --coverage",
"upgrade": "npm upgrade --save"
},
"version": "2.5.0"
"version": "3.0.0"
}
Binary file modified src/img/dashboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://raw.githubusercontent.com/grafana/grafana/master/docs/sources/developers/plugins/plugin.schema.json",
"backend": true,
"dependencies": {
"grafanaDependency": ">=8.5.0",
"grafanaDependency": ">=9.0.0",
"plugins": []
},
"executable": "env_datasource_backend",
Expand Down

0 comments on commit 00e895f

Please sign in to comment.