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

fix: don't crash when an invalid flamebearer is passed #10

Merged
merged 11 commits into from
Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/actions/lint-plugin/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: 'lint-plugin'
inputs:
enable-version-analyzer:
description: 'Whether to analyze the version or not'
required: true
file:
description: 'the plugin file (.zip)'
required: true
runs:
using: "composite"
steps:
- name: Lint plugin
shell: bash
run: |
export PATH="$(go env GOPATH)/bin/:$PATH"
envsubst < lint.config.yaml > lint.config.yaml
git clone https://github.com/grafana/plugin-validator
pushd ./plugin-validator/pkg/cmd/plugincheck2
go install
popd

plugincheck2 -strict -config lint.config.yaml -sourceCodeUri=file://./ ${{ inputs.file }}
env:
ENABLE_VERSION_ANALYZER: ${{ inputs.enable-version-analyzer }}
DEBUG: 1

47 changes: 47 additions & 0 deletions .github/actions/package-plugin/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: 'package-plugin'
inputs:
grafana-token:
description: 'Token to be used when signing (from grafana.com)'
required: true
outputs:
archive:
description: "The plugin zip file"
value: ${{ steps.metadata.outputs.archive }}
checksum:
description: "The checksum of the zip file"
value: ${{ steps.metadata.outputs.archive-checksum }}
runs:
using: "composite"
steps:
- run: yarn sign
shell: bash
env:
GRAFANA_API_KEY: ${{ inputs.grafana-token }}
- name: Get plugin metadata
id: metadata
shell: bash
run: |
sudo apt-get install jq

export GRAFANA_PLUGIN_ID=$(cat dist/plugin.json | jq -r .id)
export GRAFANA_PLUGIN_VERSION=$(cat dist/plugin.json | jq -r .info.version)
export GRAFANA_PLUGIN_TYPE=$(cat dist/plugin.json | jq -r .type)
export GRAFANA_PLUGIN_ARTIFACT=${GRAFANA_PLUGIN_ID}-${GRAFANA_PLUGIN_VERSION}.zip
export GRAFANA_PLUGIN_ARTIFACT_CHECKSUM=${GRAFANA_PLUGIN_ARTIFACT}.md5

echo "::set-output name=plugin-id::${GRAFANA_PLUGIN_ID}"
echo "::set-output name=plugin-version::${GRAFANA_PLUGIN_VERSION}"
echo "::set-output name=plugin-type::${GRAFANA_PLUGIN_TYPE}"
echo "::set-output name=archive::${GRAFANA_PLUGIN_ARTIFACT}"
echo "::set-output name=archive-checksum::${GRAFANA_PLUGIN_ARTIFACT_CHECKSUM}"

echo ::set-output name=github-tag::${GITHUB_REF#refs/*/}

- name: Package plugin
id: packag-
shell: bash
run: |
mv dist ${{ steps.metadata.outputs.plugin-id }}
zip ${{ steps.metadata.outputs.archive }} ${{ steps.metadata.outputs.plugin-id }} -r
md5sum ${{ steps.metadata.outputs.archive }} > ${{ steps.metadata.outputs.archive-checksum }}
echo "::set-output name=checksum::$(cat ./${{ steps.metadata.outputs.archive-checksum }} | cut -d' ' -f1)"
38 changes: 38 additions & 0 deletions .github/actions/setup-node/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: 'setup-node'
description: 'Sets up nodejs'
runs:
using: "composite"
steps:
- name: Setup Node.js environment
uses: actions/setup-node@v2
with:
node-version: "14.17"

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
shell: bash

- name: Cache yarn cache
uses: actions/cache@v2
id: cache-yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-

- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-${{ matrix.node-version }}-node-modules-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.node-version }}-node-modules-

- run: yarn --frozen-lockfile
shell: bash
- name: Build
run: yarn build
shell: bash
116 changes: 11 additions & 105 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI
name: Lint

env:
CYPRESS_CACHE_FOLDER: cypress/cache
Expand All @@ -8,111 +8,17 @@ on:
branches:
- main
jobs:
build:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Setup Node.js environment
uses: actions/setup-node@v2
with:
node-version: "14.17"

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- name: Cache yarn cache
uses: actions/cache@v2
id: cache-yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-${{ matrix.node-version }}-node-modules-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.node-version }}-node-modules-

- name: Pull dependencies
run: yarn
- name: Cache Cypress Binary
id: cache-cypress-binary
uses: actions/cache@v2
with:
path: cypress/cache
key: cypress-binary-${{ hashFiles('yarn.lock') }}
- run: yarn cypress install
- name: Sign plugin
run: yarn sign
env:
GRAFANA_API_KEY: ${{ secrets.GRAFANA_API_KEY }} # Requires a Grafana API key from Grafana.com.

# Smoke test
# We already tested it extensively in the other repository
- name: Run grafana server
run: docker-compose -f docker-compose.yml up -d

- name: Run tests
run: yarn cy:ci
env:
CYPRESS_VIDEO: true
- uses: actions/upload-artifact@v2
if: always()
with:
name: cypress-screenshots
path: pyroscope/cypress/screenshots
- uses: actions/upload-artifact@v2
if: always()
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-node/
- run: yarn sign
- uses: ./.github/actions/package-plugin/
id: package-plugin
with:
name: cypress-videos
path: pyroscope/cypress/videos

# Setup the go environment, since the grafana plugin linter isn't distributed as a binary
- name: Setup Go environment
if: steps.check-for-backend.outputs.has-backend == 'true'
uses: actions/setup-go@v2
grafana-token: ${{ secrets.GRAFANA_API_KEY }}
- uses: ./.github/actions/lint-plugin/
with:
go-version: "1.16"

- name: Get plugin metadata
id: metadata
run: |
sudo apt-get install jq

export GRAFANA_PLUGIN_ID=$(cat dist/plugin.json | jq -r .id)
export GRAFANA_PLUGIN_VERSION=$(cat dist/plugin.json | jq -r .info.version)
export GRAFANA_PLUGIN_TYPE=$(cat dist/plugin.json | jq -r .type)
export GRAFANA_PLUGIN_ARTIFACT=${GRAFANA_PLUGIN_ID}-${GRAFANA_PLUGIN_VERSION}.zip
export GRAFANA_PLUGIN_ARTIFACT_CHECKSUM=${GRAFANA_PLUGIN_ARTIFACT}.md5

echo "::set-output name=plugin-id::${GRAFANA_PLUGIN_ID}"
echo "::set-output name=plugin-version::${GRAFANA_PLUGIN_VERSION}"
echo "::set-output name=plugin-type::${GRAFANA_PLUGIN_TYPE}"
echo "::set-output name=archive::${GRAFANA_PLUGIN_ARTIFACT}"
echo "::set-output name=archive-checksum::${GRAFANA_PLUGIN_ARTIFACT_CHECKSUM}"

echo ::set-output name=github-tag::${GITHUB_REF#refs/*/}

- name: Package plugin
id: package-plugin
run: |
mv dist ${{ steps.metadata.outputs.plugin-id }}
zip ${{ steps.metadata.outputs.archive }} ${{ steps.metadata.outputs.plugin-id }} -r
md5sum ${{ steps.metadata.outputs.archive }} > ${{ steps.metadata.outputs.archive-checksum }}
echo "::set-output name=checksum::$(cat ./${{ steps.metadata.outputs.archive-checksum }} | cut -d' ' -f1)"

- name: Lint plugin
run: |
export PATH="$(go env GOPATH)/bin/:$PATH"

git clone https://github.com/grafana/plugin-validator
pushd ./plugin-validator/pkg/cmd/plugincheck2
go install
popd
plugincheck2 -config lint.config.yaml ${{ steps.metadata.outputs.archive }}
file: ${{ steps.package-plugin.outputs.archive }}
enable-version-analyzer: false
20 changes: 20 additions & 0 deletions .github/workflows/conventional-commits.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: conventional-pr
on:
pull_request:
branches:
- main
types:
- opened
- edited
- synchronize
jobs:
lint-pr:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: CondeNast/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
commitTitleMatch: "false"
ignoreCommits: "true"
38 changes: 38 additions & 0 deletions .github/workflows/cypress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Cypress

env:
CYPRESS_CACHE_FOLDER: cypress/cache

on:
pull_request:
branches:
- main
jobs:
cypress:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-node/
- name: Cache Cypress Binary
id: cache-cypress-binary
uses: actions/cache@v2
with:
path: cypress/cache
key: cypress-binary-${{ hashFiles('yarn.lock') }}
- run: yarn cypress install
- name: Run grafana server
run: docker-compose -f docker-compose.yml up -d
- name: Run tests
run: yarn cy:ci
env:
CYPRESS_VIDEO: true
- uses: actions/upload-artifact@v2
if: always()
with:
name: cypress-screenshots
path: pyroscope/cypress/screenshots
- uses: actions/upload-artifact@v2
if: always()
with:
name: cypress-videos
path: pyroscope/cypress/videos
14 changes: 14 additions & 0 deletions .github/workflows/release-please.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
on:
push:
branches:
- main
name: release-please
jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: google-github-actions/release-please-action@v3
with:
release-type: node
package-name: release-please-action
token: ${{ secrets.RELEASE_PLEASE_TOKEN }}
Loading