diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml new file mode 100644 index 0000000..76fc445 --- /dev/null +++ b/.github/workflows/validation.yml @@ -0,0 +1,67 @@ +name: Test Suite + +on: push + +jobs: + validate: + runs-on: ubuntu-latest + 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)" + + - 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}" + + - 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: | + git clone https://github.com/grafana/plugin-validator + pushd ./plugin-validator/pkg/cmd/plugincheck + go install + popd + plugincheck ${{ steps.metadata.outputs.archive }}