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

Commit 310f67b

Browse files
authored
fix: don't crash when an invalid flamebearer is passed (#10)
Handles when the pyroscope panel is used alongside a different datasource, which previously would crash the panel, but now we display a better (but simple) message: <img width="1186" alt="Screenshot 2023-03-16 at 17 54 51" src="https://user-images.githubusercontent.com/6951209/225710290-50b819cb-8429-461f-8ce2-0291a839432c.png"> Also moves the code from the main repo to this one.
1 parent 6ab95f9 commit 310f67b

25 files changed

+608
-316
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: 'lint-plugin'
2+
inputs:
3+
enable-version-analyzer:
4+
description: 'Whether to analyze the version or not'
5+
required: true
6+
file:
7+
description: 'the plugin file (.zip)'
8+
required: true
9+
runs:
10+
using: "composite"
11+
steps:
12+
- name: Lint plugin
13+
shell: bash
14+
run: |
15+
export PATH="$(go env GOPATH)/bin/:$PATH"
16+
envsubst < lint.config.yaml > lint.config.yaml
17+
git clone https://github.com/grafana/plugin-validator
18+
pushd ./plugin-validator/pkg/cmd/plugincheck2
19+
go install
20+
popd
21+
22+
plugincheck2 -strict -config lint.config.yaml -sourceCodeUri=file://./ ${{ inputs.file }}
23+
env:
24+
ENABLE_VERSION_ANALYZER: ${{ inputs.enable-version-analyzer }}
25+
DEBUG: 1
26+
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: 'package-plugin'
2+
inputs:
3+
grafana-token:
4+
description: 'Token to be used when signing (from grafana.com)'
5+
required: true
6+
outputs:
7+
archive:
8+
description: "The plugin zip file"
9+
value: ${{ steps.metadata.outputs.archive }}
10+
checksum:
11+
description: "The checksum of the zip file"
12+
value: ${{ steps.metadata.outputs.archive-checksum }}
13+
runs:
14+
using: "composite"
15+
steps:
16+
- run: yarn sign
17+
shell: bash
18+
env:
19+
GRAFANA_API_KEY: ${{ inputs.grafana-token }}
20+
- name: Get plugin metadata
21+
id: metadata
22+
shell: bash
23+
run: |
24+
sudo apt-get install jq
25+
26+
export GRAFANA_PLUGIN_ID=$(cat dist/plugin.json | jq -r .id)
27+
export GRAFANA_PLUGIN_VERSION=$(cat dist/plugin.json | jq -r .info.version)
28+
export GRAFANA_PLUGIN_TYPE=$(cat dist/plugin.json | jq -r .type)
29+
export GRAFANA_PLUGIN_ARTIFACT=${GRAFANA_PLUGIN_ID}-${GRAFANA_PLUGIN_VERSION}.zip
30+
export GRAFANA_PLUGIN_ARTIFACT_CHECKSUM=${GRAFANA_PLUGIN_ARTIFACT}.md5
31+
32+
echo "::set-output name=plugin-id::${GRAFANA_PLUGIN_ID}"
33+
echo "::set-output name=plugin-version::${GRAFANA_PLUGIN_VERSION}"
34+
echo "::set-output name=plugin-type::${GRAFANA_PLUGIN_TYPE}"
35+
echo "::set-output name=archive::${GRAFANA_PLUGIN_ARTIFACT}"
36+
echo "::set-output name=archive-checksum::${GRAFANA_PLUGIN_ARTIFACT_CHECKSUM}"
37+
38+
echo ::set-output name=github-tag::${GITHUB_REF#refs/*/}
39+
40+
- name: Package plugin
41+
id: packag-
42+
shell: bash
43+
run: |
44+
mv dist ${{ steps.metadata.outputs.plugin-id }}
45+
zip ${{ steps.metadata.outputs.archive }} ${{ steps.metadata.outputs.plugin-id }} -r
46+
md5sum ${{ steps.metadata.outputs.archive }} > ${{ steps.metadata.outputs.archive-checksum }}
47+
echo "::set-output name=checksum::$(cat ./${{ steps.metadata.outputs.archive-checksum }} | cut -d' ' -f1)"
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: 'setup-node'
2+
description: 'Sets up nodejs'
3+
runs:
4+
using: "composite"
5+
steps:
6+
- name: Setup Node.js environment
7+
uses: actions/setup-node@v2
8+
with:
9+
node-version: "14.17"
10+
11+
- name: Get yarn cache directory path
12+
id: yarn-cache-dir-path
13+
run: echo "::set-output name=dir::$(yarn cache dir)"
14+
shell: bash
15+
16+
- name: Cache yarn cache
17+
uses: actions/cache@v2
18+
id: cache-yarn-cache
19+
with:
20+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
21+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
22+
restore-keys: |
23+
${{ runner.os }}-yarn-
24+
25+
- name: Cache node_modules
26+
id: cache-node-modules
27+
uses: actions/cache@v2
28+
with:
29+
path: node_modules
30+
key: ${{ runner.os }}-${{ matrix.node-version }}-node-modules-${{ hashFiles('**/yarn.lock') }}
31+
restore-keys: |
32+
${{ runner.os }}-${{ matrix.node-version }}-node-modules-
33+
34+
- run: yarn --frozen-lockfile
35+
shell: bash
36+
- name: Build
37+
run: yarn build
38+
shell: bash

.github/workflows/ci.yml

Lines changed: 11 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: CI
1+
name: Lint
22

33
env:
44
CYPRESS_CACHE_FOLDER: cypress/cache
@@ -8,111 +8,17 @@ on:
88
branches:
99
- main
1010
jobs:
11-
build:
11+
lint:
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v2
15-
16-
- name: Setup Node.js environment
17-
uses: actions/setup-node@v2
18-
with:
19-
node-version: "14.17"
20-
21-
- name: Get yarn cache directory path
22-
id: yarn-cache-dir-path
23-
run: echo "::set-output name=dir::$(yarn cache dir)"
24-
25-
- name: Cache yarn cache
26-
uses: actions/cache@v2
27-
id: cache-yarn-cache
28-
with:
29-
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
30-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
31-
restore-keys: |
32-
${{ runner.os }}-yarn-
33-
- name: Cache node_modules
34-
id: cache-node-modules
35-
uses: actions/cache@v2
36-
with:
37-
path: node_modules
38-
key: ${{ runner.os }}-${{ matrix.node-version }}-node-modules-${{ hashFiles('**/yarn.lock') }}
39-
restore-keys: |
40-
${{ runner.os }}-${{ matrix.node-version }}-node-modules-
41-
42-
- name: Pull dependencies
43-
run: yarn
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') }}
50-
- run: yarn cypress install
51-
- name: Sign plugin
52-
run: yarn sign
53-
env:
54-
GRAFANA_API_KEY: ${{ secrets.GRAFANA_API_KEY }} # Requires a Grafana API key from Grafana.com.
55-
56-
# Smoke test
57-
# We already tested it extensively in the other repository
58-
- name: Run grafana server
59-
run: docker-compose -f docker-compose.yml up -d
60-
61-
- name: Run tests
62-
run: yarn cy:ci
63-
env:
64-
CYPRESS_VIDEO: true
65-
- uses: actions/upload-artifact@v2
66-
if: always()
67-
with:
68-
name: cypress-screenshots
69-
path: pyroscope/cypress/screenshots
70-
- uses: actions/upload-artifact@v2
71-
if: always()
14+
- uses: actions/checkout@v3
15+
- uses: ./.github/actions/setup-node/
16+
- run: yarn sign
17+
- uses: ./.github/actions/package-plugin/
18+
id: package-plugin
7219
with:
73-
name: cypress-videos
74-
path: pyroscope/cypress/videos
75-
76-
# Setup the go environment, since the grafana plugin linter isn't distributed as a binary
77-
- name: Setup Go environment
78-
if: steps.check-for-backend.outputs.has-backend == 'true'
79-
uses: actions/setup-go@v2
20+
grafana-token: ${{ secrets.GRAFANA_API_KEY }}
21+
- uses: ./.github/actions/lint-plugin/
8022
with:
81-
go-version: "1.16"
82-
83-
- name: Get plugin metadata
84-
id: metadata
85-
run: |
86-
sudo apt-get install jq
87-
88-
export GRAFANA_PLUGIN_ID=$(cat dist/plugin.json | jq -r .id)
89-
export GRAFANA_PLUGIN_VERSION=$(cat dist/plugin.json | jq -r .info.version)
90-
export GRAFANA_PLUGIN_TYPE=$(cat dist/plugin.json | jq -r .type)
91-
export GRAFANA_PLUGIN_ARTIFACT=${GRAFANA_PLUGIN_ID}-${GRAFANA_PLUGIN_VERSION}.zip
92-
export GRAFANA_PLUGIN_ARTIFACT_CHECKSUM=${GRAFANA_PLUGIN_ARTIFACT}.md5
93-
94-
echo "::set-output name=plugin-id::${GRAFANA_PLUGIN_ID}"
95-
echo "::set-output name=plugin-version::${GRAFANA_PLUGIN_VERSION}"
96-
echo "::set-output name=plugin-type::${GRAFANA_PLUGIN_TYPE}"
97-
echo "::set-output name=archive::${GRAFANA_PLUGIN_ARTIFACT}"
98-
echo "::set-output name=archive-checksum::${GRAFANA_PLUGIN_ARTIFACT_CHECKSUM}"
99-
100-
echo ::set-output name=github-tag::${GITHUB_REF#refs/*/}
101-
102-
- name: Package plugin
103-
id: package-plugin
104-
run: |
105-
mv dist ${{ steps.metadata.outputs.plugin-id }}
106-
zip ${{ steps.metadata.outputs.archive }} ${{ steps.metadata.outputs.plugin-id }} -r
107-
md5sum ${{ steps.metadata.outputs.archive }} > ${{ steps.metadata.outputs.archive-checksum }}
108-
echo "::set-output name=checksum::$(cat ./${{ steps.metadata.outputs.archive-checksum }} | cut -d' ' -f1)"
109-
110-
- name: Lint plugin
111-
run: |
112-
export PATH="$(go env GOPATH)/bin/:$PATH"
113-
114-
git clone https://github.com/grafana/plugin-validator
115-
pushd ./plugin-validator/pkg/cmd/plugincheck2
116-
go install
117-
popd
118-
plugincheck2 -config lint.config.yaml ${{ steps.metadata.outputs.archive }}
23+
file: ${{ steps.package-plugin.outputs.archive }}
24+
enable-version-analyzer: false
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: conventional-pr
2+
on:
3+
pull_request:
4+
branches:
5+
- main
6+
types:
7+
- opened
8+
- edited
9+
- synchronize
10+
jobs:
11+
lint-pr:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
- uses: CondeNast/conventional-pull-request-action@v0.2.0
16+
env:
17+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
with:
19+
commitTitleMatch: "false"
20+
ignoreCommits: "true"

.github/workflows/cypress.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Cypress
2+
3+
env:
4+
CYPRESS_CACHE_FOLDER: cypress/cache
5+
6+
on:
7+
pull_request:
8+
branches:
9+
- main
10+
jobs:
11+
cypress:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
- uses: ./.github/actions/setup-node/
16+
- name: Cache Cypress Binary
17+
id: cache-cypress-binary
18+
uses: actions/cache@v2
19+
with:
20+
path: cypress/cache
21+
key: cypress-binary-${{ hashFiles('yarn.lock') }}
22+
- run: yarn cypress install
23+
- name: Run grafana server
24+
run: docker-compose -f docker-compose.yml up -d
25+
- name: Run tests
26+
run: yarn cy:ci
27+
env:
28+
CYPRESS_VIDEO: true
29+
- uses: actions/upload-artifact@v2
30+
if: always()
31+
with:
32+
name: cypress-screenshots
33+
path: pyroscope/cypress/screenshots
34+
- uses: actions/upload-artifact@v2
35+
if: always()
36+
with:
37+
name: cypress-videos
38+
path: pyroscope/cypress/videos

.github/workflows/release-please.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
on:
2+
push:
3+
branches:
4+
- main
5+
name: release-please
6+
jobs:
7+
release-please:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: google-github-actions/release-please-action@v3
11+
with:
12+
release-type: node
13+
package-name: release-please-action
14+
token: ${{ secrets.RELEASE_PLEASE_TOKEN }}

0 commit comments

Comments
 (0)