Skip to content
This repository was archived by the owner on Apr 27, 2023. It is now read-only.

Commit b5f094f

Browse files
committed
chore: start using the @pyroscope/datasource-plugin lib (#4)
* chore: start using the @pyroscope/datasource-plugin lib
1 parent 3ff1797 commit b5f094f

File tree

21 files changed

+14565
-125
lines changed

21 files changed

+14565
-125
lines changed

.github/workflows/ci.yml

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ on:
44
pull_request:
55
branches:
66
- main
7+
8+
env:
9+
CYPRESS_CACHE_FOLDER: cypress/cache
10+
711
jobs:
812
build:
913
runs-on: ubuntu-latest
@@ -33,32 +37,34 @@ jobs:
3337
uses: actions/cache@v2
3438
with:
3539
path: node_modules
36-
key: ${{ runner.os }}-${{ matrix.node-version }}-nodemodules-${{ hashFiles('**/yarn.lock') }}
40+
key: ${{ runner.os }}-${{ matrix.node-version }}-node-modules-${{ hashFiles('**/yarn.lock') }}
3741
restore-keys: |
38-
${{ runner.os }}-${{ matrix.node-version }}-nodemodules-
42+
${{ runner.os }}-${{ matrix.node-version }}-node-modules-
43+
44+
- name: Cache Cypress Binary
45+
id: cache-cypress-binary
46+
uses: actions/cache@v2
47+
with:
48+
path: cypress/cache
49+
key: cypress-binary-${{ hashFiles('yarn.lock') }}
3950

40-
- name: Build plugin
41-
run: yarn build
51+
- name: Pull dependencies
52+
run: yarn
4253

4354
- name: Sign plugin
44-
run: |
45-
# We only have a single dependency, grafana-toolkit
46-
# So we install next to where it's needed
47-
yarn
48-
yarn sign
55+
run: yarn sign
4956
env:
5057
GRAFANA_API_KEY: ${{ secrets.GRAFANA_API_KEY }} # Requires a Grafana API key from Grafana.com.
5158

52-
# We reuse the same tests from the other repo, after all, why not?
53-
# TODO: run other tests that are valid here
54-
# eg: checking README etc
59+
60+
# Smoke test
61+
# We already tested it extensively in the other repository
5562
- name: Run grafana server
56-
run: docker-compose -f pyroscope/grafana-plugin/datasource/docker-compose.yml up -d
63+
run: docker-compose -f docker-compose.yml up -d
5764
- name: Run tests
58-
run: yarn --cwd pyroscope cy:datasource:ci
65+
run: yarn cy:ci
5966
env:
6067
CYPRESS_VIDEO: true
61-
CYPRESS_COMPARE_SNAPSHOTS: true
6268
- uses: actions/upload-artifact@v2
6369
if: always()
6470
with:
@@ -69,13 +75,6 @@ jobs:
6975
with:
7076
name: cypress-videos
7177
path: pyroscope/cypress/videos
72-
- uses: actions/upload-artifact@v2
73-
if: always()
74-
with:
75-
name: cypress-snapshots
76-
# TODO: scope to only store screenshots that refer to grafana
77-
path: pyroscope/cypress/snapshots
78-
7978
# Setup the go environment, since the grafana plugin linter isn't distributed as a binary
8079
- name: Setup Go environment
8180
if: steps.check-for-backend.outputs.has-backend == 'true'

.github/workflows/release.yml

Lines changed: 6 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -39,45 +39,14 @@ jobs:
3939
restore-keys: |
4040
${{ runner.os }}-${{ matrix.node-version }}-nodemodules-
4141
42-
- name: Build plugin
43-
run: yarn build
42+
- name: Pull dependencies
43+
run: yarn
4444

4545
- name: Sign plugin
46-
run: |
47-
# We only have a single dependency, grafana-toolkit
48-
# So we install next to where it's needed
49-
yarn
50-
yarn sign
46+
run: yarn sign
5147
env:
5248
GRAFANA_API_KEY: ${{ secrets.GRAFANA_API_KEY }} # Requires a Grafana API key from Grafana.com.
5349

54-
# We reuse the same tests from the other repo, after all, why not?
55-
# TODO: run other tests that are valid here
56-
# eg: checking README etc
57-
- name: Run grafana server
58-
run: docker-compose -f pyroscope/grafana-plugin/datasource/docker-compose.yml up -d
59-
- name: Run tests
60-
run: yarn --cwd pyroscope cy:datasource:ci
61-
env:
62-
CYPRESS_VIDEO: true
63-
CYPRESS_COMPARE_SNAPSHOTS: true
64-
- uses: actions/upload-artifact@v2
65-
if: always()
66-
with:
67-
name: cypress-screenshots
68-
path: pyroscope/cypress/screenshots
69-
- uses: actions/upload-artifact@v2
70-
if: always()
71-
with:
72-
name: cypress-videos
73-
path: pyroscope/cypress/videos
74-
- uses: actions/upload-artifact@v2
75-
if: always()
76-
with:
77-
name: cypress-snapshots
78-
# TODO: scope to only store screenshots that refer to grafana
79-
path: pyroscope/cypress/snapshots
80-
8150
# Setup the go environment, since the grafana plugin linter isn't distributed as a binary
8251
- name: Setup Go environment
8352
if: steps.check-for-backend.outputs.has-backend == 'true'
@@ -130,7 +99,7 @@ jobs:
13099
- name: Read changelog
131100
id: changelog
132101
run: |
133-
awk '/^## / {s++} s == 1 {print}' CHANGELOG.md > release_notes.md
102+
awk '/^## / {s++} s == 1 {print}' ${{ steps.metadata.outputs.plugin-id }}/CHANGELOG.md > release_notes.md
134103
echo "::set-output name=path::release_notes.md"
135104
136105
- name: Create tag
@@ -153,7 +122,7 @@ jobs:
153122
tag_name: 'v${{ steps.metadata.outputs.plugin-version }}'
154123
release_name: Release ${{ steps.metadata.outputs.plugin-version }}
155124
body_path: ${{ steps.changelog.outputs.path }}
156-
draft: true
125+
draft: false
157126

158127
- name: Add plugin to release
159128
id: upload-plugin-asset
@@ -179,5 +148,5 @@ jobs:
179148

180149
- name: Publish to Grafana.com
181150
run: |
182-
echo "A draft release has been created for your plugin. Please review and publish it."
151+
echo "A release has been created for your plugin. Please review and publish it."
183152
echo "To publish a new version, follow https://github.com/grafana/grafana-plugin-repository#maintain-your-plugin"

CHANGELOG.md

Lines changed: 0 additions & 11 deletions
This file was deleted.

build.sh

Lines changed: 0 additions & 43 deletions
This file was deleted.

cypress.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"baseUrl": "http://localhost:3000"
3+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"flamebearer": {
3+
"names": [
4+
"total",
5+
"runtime.main",
6+
"main.slowFunction",
7+
"main.work",
8+
"main.main",
9+
"main.fastFunction"
10+
],
11+
"levels": [
12+
[0, 988, 0, 0],
13+
[0, 988, 0, 1],
14+
[0, 214, 0, 5, 0, 3, 2, 4, 0, 771, 0, 2],
15+
[0, 214, 214, 3, 2, 1, 1, 5, 0, 771, 771, 3]
16+
],
17+
"numTicks": 988,
18+
"maxSelf": 771,
19+
"spyName": "gospy",
20+
"sampleRate": 100,
21+
"units": "samples",
22+
"format": "single"
23+
},
24+
"metadata": {
25+
"format": "single",
26+
"sampleRate": 100,
27+
"spyName": "gospy",
28+
"units": "samples"
29+
},
30+
"timeline": {
31+
"startTime": 1632335270,
32+
"samples": [989],
33+
"durationDelta": 10
34+
}
35+
}

cypress/integration/smoke.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
describe('smoke', () => {
2+
// Since we are testing the datasource plugin only
3+
// We don't do any assertions against the panel
4+
it('makes requests to the datasource', () => {
5+
cy.intercept('**/render*', {
6+
fixture: 'simple-golang-app-cpu.json',
7+
}).as('render');
8+
9+
cy.visit('http://localhost:3000/d/single-panel/pyroscope-demo?orgId=1');
10+
11+
cy.intercept(
12+
'http://localhost:3000/api/datasources/proxy/1/render/render?format=json&from=now-5m&until=now&queryType=randomWalk&refId=A&datasource=Pyroscope&query=pyroscope.server.cpu'
13+
).as('renderRequest');
14+
15+
cy.wait('@renderRequest');
16+
});
17+
});

cypress/plugins/index.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/// <reference types="cypress" />
2+
// ***********************************************************
3+
// This example plugins/index.js can be used to load plugins
4+
//
5+
// You can change the location of this file or turn off loading
6+
// the plugins file with the 'pluginsFile' configuration option.
7+
//
8+
// You can read more here:
9+
// https://on.cypress.io/plugins-guide
10+
// ***********************************************************
11+
12+
// This function is called when a project is opened or re-opened (e.g. due to
13+
// the project's config changing)
14+
15+
/**
16+
* @type {Cypress.PluginConfig}
17+
*/
18+
// eslint-disable-next-line no-unused-vars
19+
module.exports = (on, config) => {
20+
// `on` is used to hook into various events Cypress emits
21+
// `config` is the resolved Cypress config
22+
}

cypress/support/commands.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// ***********************************************
2+
// This example commands.js shows you how to
3+
// create various custom commands and overwrite
4+
// existing commands.
5+
//
6+
// For more comprehensive examples of custom
7+
// commands please read more here:
8+
// https://on.cypress.io/custom-commands
9+
// ***********************************************
10+
//
11+
//
12+
// -- This is a parent command --
13+
// Cypress.Commands.add('login', (email, password) => { ... })
14+
//
15+
//
16+
// -- This is a child command --
17+
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
18+
//
19+
//
20+
// -- This is a dual command --
21+
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
22+
//
23+
//
24+
// -- This will overwrite an existing command --
25+
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })

cypress/support/index.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// ***********************************************************
2+
// This example support/index.js is processed and
3+
// loaded automatically before your test files.
4+
//
5+
// This is a great place to put global configuration and
6+
// behavior that modifies Cypress.
7+
//
8+
// You can change the location of this file or turn off
9+
// automatically serving support files with the
10+
// 'supportFile' configuration option.
11+
//
12+
// You can read more here:
13+
// https://on.cypress.io/configuration
14+
// ***********************************************************
15+
16+
// Import commands.js using ES2015 syntax:
17+
import './commands'
18+
19+
// Alternatively you can use CommonJS syntax:
20+
// require('./commands')

0 commit comments

Comments
 (0)