Clean up code #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Package Plugin" | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
run: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Setup Go environment | |
uses: actions/setup-go@v5 | |
with: | |
go-version: "1.21" | |
- name: Install yarn dependencies | |
run: yarn install | |
env: | |
NODE_OPTIONS: '--max_old_space_size=4096' | |
- name: Build Frontend | |
run: yarn build | |
env: | |
NODE_OPTIONS: '--max_old_space_size=4096' | |
- name: Test backend | |
uses: magefile/mage-action@v3 | |
with: | |
version: latest | |
args: coverage | |
- name: Build backend | |
uses: magefile/mage-action@v3 | |
with: | |
version: latest | |
args: buildAll | |
- 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_SHA1SUM=${GRAFANA_PLUGIN_ARTIFACT}.sha1 | |
echo "plugin-id=${GRAFANA_PLUGIN_ID}" >> $GITHUB_OUTPUT | |
echo "plugin-version=${GRAFANA_PLUGIN_VERSION}" >> $GITHUB_OUTPUT | |
echo "plugin-type=${GRAFANA_PLUGIN_TYPE}" >> $GITHUB_OUTPUT | |
echo "archive=${GRAFANA_PLUGIN_ARTIFACT}" >> $GITHUB_OUTPUT | |
echo "archive-sha1sum=${GRAFANA_PLUGIN_ARTIFACT_SHA1SUM}" >> $GITHUB_OUTPUT | |
echo "github-tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT | |
shell: bash | |
- 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 | |
sha1sum ${{ steps.metadata.outputs.archive }} | cut -f1 -d' ' > ${{ steps.metadata.outputs.archive-sha1sum }} | |
shell: bash | |
- name: Archive plugin build artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: grafana-questdb-datasource.zip | |
path: ${{ steps.metadata.outputs.archive }} | |
retention-days: 7 |