From dd6a0c25d9ab3ad3902eb55998ff6f1e5febc9cf Mon Sep 17 00:00:00 2001 From: John Thomas Date: Tue, 23 Nov 2021 14:29:32 -0500 Subject: [PATCH 1/5] [Github] Add validation job --- .github/workflows/validation.yml | 47 ++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/validation.yml diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml new file mode 100644 index 0000000..73a969a --- /dev/null +++ b/.github/workflows/validation.yml @@ -0,0 +1,47 @@ +name: Test Suite + +on: push + +jobs: + validate: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "::set-output name=dir::$(yarn cache dir)" + + - name: Load yarn cache + uses: actions/cache@v1 + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + ${{ runner.os }}-yarn- + + - name: Install Yarn dependencies + run: yarn install --frozen-lockfile + + - name: Run code linter + run: yarn run lint + + - name: Build + run: yarn run build + + - 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/*/} From 7120f2f42ee918ae4c72f4c8bdfbb288d1abb98d Mon Sep 17 00:00:00 2001 From: John Thomas Date: Tue, 23 Nov 2021 15:06:23 -0500 Subject: [PATCH 2/5] [Github] Add package step --- .github/workflows/validation.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index 73a969a..2ee7cea 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -45,3 +45,14 @@ jobs: 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: Check package version + 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 + + - 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)" From 477e718875d04e821abae26a2a040df93ace7e2e Mon Sep 17 00:00:00 2001 From: John Thomas Date: Tue, 23 Nov 2021 15:15:52 -0500 Subject: [PATCH 3/5] [Github] Remove step to check package version --- .github/workflows/validation.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index 2ee7cea..a8534f1 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -44,10 +44,6 @@ jobs: 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: Check package version - 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 - name: Package plugin id: package-plugin From 5c64976d7b796be14438b3cd54211e74a657d1e7 Mon Sep 17 00:00:00 2001 From: John Thomas Date: Tue, 23 Nov 2021 15:36:43 -0500 Subject: [PATCH 4/5] [Github] Add lint step for plugin validation --- .github/workflows/validation.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index a8534f1..6fa1ac7 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -52,3 +52,11 @@ jobs: 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: | + git clone https://github.com/grafana/plugin-validator + pushd ./plugin-validator/pkg/cmd/plugincheck + go install + popd + plugincheck ${{ steps.metadata.outputs.archive }} From f68b47b0d814fe8dffd488e0722e671cdda743e8 Mon Sep 17 00:00:00 2001 From: John Thomas Date: Tue, 23 Nov 2021 15:57:20 -0500 Subject: [PATCH 5/5] [Github] Setup Go environment --- .github/workflows/validation.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index 6fa1ac7..76fc445 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -8,6 +8,11 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Setup Go environment + uses: actions/setup-go@v2 + with: + go-version: '1.15' + - name: Get yarn cache directory path id: yarn-cache-dir-path run: echo "::set-output name=dir::$(yarn cache dir)"