Skip to content

Commit 1885514

Browse files
committed
Init commit
0 parents  commit 1885514

17 files changed

+13930
-0
lines changed

.github/workflows/ci.yml

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
16+
- name: Setup Node.js environment
17+
uses: actions/[email protected]
18+
with:
19+
node-version: "14.x"
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+
34+
- name: Cache node_modules
35+
id: cache-node-modules
36+
uses: actions/cache@v2
37+
with:
38+
path: node_modules
39+
key: ${{ runner.os }}-${{ matrix.node-version }}-nodemodules-${{ hashFiles('**/yarn.lock') }}
40+
restore-keys: |
41+
${{ runner.os }}-${{ matrix.node-version }}-nodemodules-
42+
43+
- name: Install dependencies
44+
run: yarn install --frozen-lockfile
45+
46+
- name: Build and test frontend
47+
run: yarn build
48+
49+
- name: Check for backend
50+
id: check-for-backend
51+
run: |
52+
if [ -f "Magefile.go" ]
53+
then
54+
echo "::set-output name=has-backend::true"
55+
fi
56+
57+
- name: Setup Go environment
58+
if: steps.check-for-backend.outputs.has-backend == 'true'
59+
uses: actions/setup-go@v2
60+
with:
61+
go-version: "1.15"
62+
63+
- name: Test backend
64+
if: steps.check-for-backend.outputs.has-backend == 'true'
65+
uses: magefile/mage-action@v1
66+
with:
67+
version: latest
68+
args: coverage
69+
70+
- name: Build backend
71+
if: steps.check-for-backend.outputs.has-backend == 'true'
72+
uses: magefile/mage-action@v1
73+
with:
74+
version: latest
75+
args: buildAll

.github/workflows/release.yml

+164
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*" # Run workflow on version tags, e.g. v1.0.0.
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v2
14+
15+
- name: Setup Node.js environment
16+
uses: actions/[email protected]
17+
with:
18+
node-version: "14.x"
19+
20+
- name: Setup Go environment
21+
uses: actions/setup-go@v2
22+
with:
23+
go-version: "1.15"
24+
25+
- name: Get yarn cache directory path
26+
id: yarn-cache-dir-path
27+
run: echo "::set-output name=dir::$(yarn cache dir)"
28+
29+
- name: Cache yarn cache
30+
uses: actions/cache@v2
31+
id: cache-yarn-cache
32+
with:
33+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
34+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
35+
restore-keys: |
36+
${{ runner.os }}-yarn-
37+
38+
- name: Cache node_modules
39+
id: cache-node-modules
40+
uses: actions/cache@v2
41+
with:
42+
path: node_modules
43+
key: ${{ runner.os }}-${{ matrix.node-version }}-nodemodules-${{ hashFiles('**/yarn.lock') }}
44+
restore-keys: |
45+
${{ runner.os }}-${{ matrix.node-version }}-nodemodules-
46+
47+
- name: Install dependencies
48+
run: yarn install --frozen-lockfile;
49+
if: |
50+
steps.cache-yarn-cache.outputs.cache-hit != 'true' ||
51+
steps.cache-node-modules.outputs.cache-hit != 'true'
52+
53+
- name: Build and test frontend
54+
run: yarn build
55+
56+
- name: Check for backend
57+
id: check-for-backend
58+
run: |
59+
if [ -f "Magefile.go" ]
60+
then
61+
echo "::set-output name=has-backend::true"
62+
fi
63+
64+
- name: Test backend
65+
if: steps.check-for-backend.outputs.has-backend == 'true'
66+
uses: magefile/mage-action@v1
67+
with:
68+
version: latest
69+
args: coverage
70+
71+
- name: Build backend
72+
if: steps.check-for-backend.outputs.has-backend == 'true'
73+
uses: magefile/mage-action@v1
74+
with:
75+
version: latest
76+
args: buildAll
77+
78+
- name: Sign plugin
79+
run: yarn sign
80+
env:
81+
GRAFANA_API_KEY: ${{ secrets.GRAFANA_API_KEY }} # Requires a Grafana API key from Grafana.com.
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: Read changelog
103+
id: changelog
104+
run: |
105+
awk '/^## / {s++} s == 1 {print}' CHANGELOG.md > release_notes.md
106+
echo "::set-output name=path::release_notes.md"
107+
108+
- name: Check package version
109+
run: if [ "v${{ steps.metadata.outputs.plugin-version }}" != "${{ steps.metadata.outputs.github-tag }}" ]; then printf "\033[0;31mPlugin version doesn't match tag name\033[0m\n"; exit 1; fi
110+
111+
- name: Package plugin
112+
id: package-plugin
113+
run: |
114+
mv dist ${{ steps.metadata.outputs.plugin-id }}
115+
zip ${{ steps.metadata.outputs.archive }} ${{ steps.metadata.outputs.plugin-id }} -r
116+
md5sum ${{ steps.metadata.outputs.archive }} > ${{ steps.metadata.outputs.archive-checksum }}
117+
echo "::set-output name=checksum::$(cat ./${{ steps.metadata.outputs.archive-checksum }} | cut -d' ' -f1)"
118+
119+
- name: Lint plugin
120+
run: |
121+
git clone https://github.com/grafana/plugin-validator
122+
pushd ./plugin-validator/cmd/plugincheck
123+
go install
124+
popd
125+
plugincheck ${{ steps.metadata.outputs.archive }}
126+
127+
- name: Create release
128+
id: create_release
129+
uses: actions/create-release@v1
130+
env:
131+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
132+
with:
133+
tag_name: ${{ github.ref }}
134+
release_name: Release ${{ github.ref }}
135+
body_path: ${{ steps.changelog.outputs.path }}
136+
draft: true
137+
138+
- name: Add plugin to release
139+
id: upload-plugin-asset
140+
uses: actions/upload-release-asset@v1
141+
env:
142+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
143+
with:
144+
upload_url: ${{ steps.create_release.outputs.upload_url }}
145+
asset_path: ./${{ steps.metadata.outputs.archive }}
146+
asset_name: ${{ steps.metadata.outputs.archive }}
147+
asset_content_type: application/zip
148+
149+
- name: Add checksum to release
150+
id: upload-checksum-asset
151+
uses: actions/upload-release-asset@v1
152+
env:
153+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
154+
with:
155+
upload_url: ${{ steps.create_release.outputs.upload_url }}
156+
asset_path: ./${{ steps.metadata.outputs.archive-checksum }}
157+
asset_name: ${{ steps.metadata.outputs.archive-checksum }}
158+
asset_content_type: text/plain
159+
160+
- name: Publish to Grafana.com
161+
run: |
162+
echo A draft release has been created for your plugin. Please review and publish it. Then submit your plugin to grafana.com/plugins by opening a PR to https://github.com/grafana/grafana-plugin-repository with the following entry:
163+
echo
164+
echo '{ "id": "${{ steps.metadata.outputs.plugin-id }}", "type": "${{ steps.metadata.outputs.plugin-type }}", "url": "https://github.com/${{ github.repository }}", "versions": [ { "version": "${{ steps.metadata.outputs.plugin-version }}", "commit": "${{ github.sha }}", "url": "https://github.com/${{ github.repository }}", "download": { "any": { "url": "https://github.com/${{ github.repository }}/releases/download/v${{ steps.metadata.outputs.plugin-version }}/${{ steps.metadata.outputs.archive }}", "md5": "${{ steps.package-plugin.outputs.checksum }}" } } } ] }' | jq .

.gitignore

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
8+
node_modules/
9+
10+
# Runtime data
11+
pids
12+
*.pid
13+
*.seed
14+
*.pid.lock
15+
16+
# Directory for instrumented libs generated by jscoverage/JSCover
17+
lib-cov
18+
19+
# Coverage directory used by tools like istanbul
20+
coverage
21+
22+
# Compiled binary addons (https://nodejs.org/api/addons.html)
23+
dist/
24+
artifacts/
25+
work/
26+
ci/
27+
e2e-results/
28+
29+
# Editor
30+
.idea
31+
.vscode

.prettierrc.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
...require("./node_modules/@grafana/toolkit/src/config/prettier.plugin.config.json"),
3+
};

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Changelog
2+
3+
## 1.0.0 (Unreleased)
4+
5+
Initial release.

0 commit comments

Comments
 (0)