From c1168b0f179d01c98dbe06ad78784411a45e8f5e Mon Sep 17 00:00:00 2001 From: bziobrowski <26925920+bziobrowski@users.noreply.github.com> Date: Thu, 22 Feb 2024 10:16:03 +0100 Subject: [PATCH] Test plugin packaging --- .github/workflows/package.yml | 79 +++++++++++++++++++ ...ge.yml => pull-request-image.yml_disabled} | 0 2 files changed, 79 insertions(+) create mode 100644 .github/workflows/package.yml rename .github/workflows/{pull-request-image.yml => pull-request-image.yml_disabled} (100%) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml new file mode 100644 index 0000000..10d839a --- /dev/null +++ b/.github/workflows/package.yml @@ -0,0 +1,79 @@ +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 diff --git a/.github/workflows/pull-request-image.yml b/.github/workflows/pull-request-image.yml_disabled similarity index 100% rename from .github/workflows/pull-request-image.yml rename to .github/workflows/pull-request-image.yml_disabled