Skip to content

Commit

Permalink
update workflows (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
briangann authored Oct 18, 2023
1 parent a023726 commit ebf34a6
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 35 deletions.
33 changes: 20 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 18
check-latest: true
cache: yarn
cache-dependency-path: yarn.lock

- name: Install dependencies
run: yarn install --immutable

Expand Down Expand Up @@ -51,44 +53,49 @@ jobs:

- name: Test backend
if: steps.check-for-backend.outputs.has-backend == 'true'
uses: magefile/mage-action@v1
uses: magefile/mage-action@v2
with:
version: latest
args: coverage

- name: Build backend
if: steps.check-for-backend.outputs.has-backend == 'true'
uses: magefile/mage-action@v1
uses: magefile/mage-action@v2
with:
version: latest
args: buildAll

- name: E2E - Check for Frontend Tests
id: check-for-e2e-frontend-tests
- name: Check for E2E
id: check-for-e2e
run: |
if [ -d "cypress" ]
then
echo "has-e2e-frontend-tests=true" >> $GITHUB_OUTPUT
echo "has-e2e=true" >> $GITHUB_OUTPUT
fi
- name: E2E - Start grafana docker
if: steps.check-for-e2e-frontend-tests.outputs.has-e2e-frontend-tests == 'true'
run: yarn server -d
- name: Start grafana docker
if: steps.check-for-e2e.outputs.has-e2e == 'true'
run: docker-compose up -d

- name: E2E - Run tests
if: steps.check-for-e2e-frontend-tests.outputs.has-e2e-frontend-tests == 'true'
- name: Run e2e tests
id: run-e2e-tests
if: steps.check-for-e2e.outputs.has-e2e == 'true'
run: yarn e2e

- name: E2E - Archive Output
- name: Stop grafana docker
if: steps.check-for-e2e.outputs.has-e2e == 'true'
run: docker-compose down

- name: Archive E2E output
uses: actions/upload-artifact@v3
if: steps.check-for-e2e-frontend-tests.outputs.has-e2e-frontend-tests == 'true'
if: steps.check-for-e2e.outputs.has-e2e == 'true' && steps.run-e2e-tests.outcome != 'success'
with:
name: cypress-videos
path: cypress/videos
retention-days: 5

- name: E2E - Stop grafana docker
if: steps.check-for-e2e-frontend-tests.outputs.has-e2e-frontend-tests == 'true'
if: steps.check-for-e2e.outputs.has-e2e-frontend-tests == 'true'
run: docker-compose down

- name: Code Climate - Check environment
Expand Down
44 changes: 22 additions & 22 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ jobs:
release:
runs-on: ubuntu-latest
env:
GRAFANA_API_KEY: ${{ secrets.GRAFANA_API_KEY }} # Requires a Grafana API key from Grafana.com.
GRAFANA_ACCESS_POLICY_TOKEN: ${{ secrets.GRAFANA_ACCESS_POLICY_TOKEN }}
steps:
- uses: actions/checkout@v3

- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: '18'
check-latest: true
cache: 'yarn'
cache-dependency-path: yarn.lock

- name: Setup Go environment
uses: actions/setup-go@v3
Expand All @@ -40,27 +41,27 @@ jobs:
- name: Test backend
if: steps.check-for-backend.outputs.has-backend == 'true'
uses: magefile/mage-action@v1
uses: magefile/mage-action@v2
with:
version: latest
args: coverage

- name: Build backend
if: steps.check-for-backend.outputs.has-backend == 'true'
uses: magefile/mage-action@v1
uses: magefile/mage-action@v2
with:
version: latest
args: buildAll

- name: Warn missing Grafana API key
- name: Warn missing Grafana access policy token
run: |
echo Please generate a Grafana API key: https://grafana.com/docs/grafana/latest/developers/plugins/sign-a-plugin/#generate-an-api-key
echo Once done please follow the instructions found here: https://github.com/$\{{github.repository}}/blob/main/README.md#using-github-actions-release-workflow
if: ${{ env.GRAFANA_API_KEY == '' }}
echo Please generate a Grafana access policy token: https://grafana.com/docs/grafana/latest/developers/plugins/sign-a-plugin/#generate-a-token
echo Once done please follow the instructions found here: https://github.com/${{github.repository}}/blob/main/README.md#using-github-actions-release-workflow
if: ${{ env.GRAFANA_ACCESS_POLICY_TOKEN == '' }}

- name: Sign plugin
run: yarn sign
if: ${{ env.GRAFANA_API_KEY != '' }}
if: ${{ env.GRAFANA_ACCESS_POLICY_TOKEN != '' }}

- name: Get plugin metadata
id: metadata
Expand Down Expand Up @@ -91,51 +92,50 @@ jobs:
run: |
printf "Checking package version versus github tag";
printf "metadata version: v${{ steps.metadata.outputs.plugin-version }}";
printf "github-tag version: v${{ steps.metadata.outputs.github-tag }}";
printf "github-tag version: ${{ steps.metadata.outputs.github-tag }}";
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";
printf "metadata version: v${{ steps.metadata.outputs.plugin-version }}";
printf "github-tag version: ${{ steps.metadata.outputs.github-tag }}";
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 "checksum=$(cat ./$\{{ steps.metadata.outputs.archive-checksum }} | cut -d' ' -f1)" >> $GITHUB_OUTPUT
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 "checksum=$(cat ./${{ steps.metadata.outputs.archive-checksum }} | cut -d' ' -f1)" >> $GITHUB_OUTPUT
- name: Validate plugin
run: |
git clone https://github.com/grafana/plugin-validator
pushd ./plugin-validator/pkg/cmd/plugincheck2
go install
popd
plugincheck2 -config ./plugin-validator/config/default.yaml $\{{ steps.metadata.outputs.archive }}
plugincheck2 -config ./plugin-validator/config/default.yaml ${{ steps.metadata.outputs.archive }}
- name: Create Github release
uses: softprops/action-gh-release@v1
with:
draft: true
generate_release_notes: true
files: |
./$\{{ steps.metadata.outputs.archive }}
./$\{{ steps.metadata.outputs.archive-checksum }}
./${{ steps.metadata.outputs.archive }}
./${{ steps.metadata.outputs.archive-checksum }}
body: |
**This Github draft release has been created for your plugin.**
_Note: if this is the first release for your plugin please consult the [distributing-your-plugin section](https://github.com/$\{{github.repository}}/blob/main/README.md#distributing-your-plugin) of the README_
_Note: if this is the first release for your plugin please consult the [distributing-your-plugin section](https://github.com/${{github.repository}}/blob/main/README.md#distributing-your-plugin) of the README_
If you would like to submit this release to Grafana please consider the following steps:
- Check the Validate plugin step in the [release workflow](https://github.com/$\{{github.repository}}/commit/$\{{github.sha}}/checks/$\{{github.run_id}}) for any warnings that need attention
- Check the Validate plugin step in the [release workflow](https://github.com/${{github.repository}}/commit/${{github.sha}}/checks/${{github.run_id}}) for any warnings that need attention
- Navigate to https://grafana.com/auth/sign-in/ to sign into your account
- Once logged in click **My Plugins** in the admin navigation
- Click the **Submit Plugin** button
- Fill in the Plugin Submission form:
- Paste this [.zip asset link](https://github.com/$\{{ github.repository }}/releases/download/v$\{{ steps.metadata.outputs.plugin-version }}/$\{{ steps.metadata.outputs.archive }}) in the Plugin URL field
- Paste this [.zip.md5 link](https://github.com/$\{{ github.repository }}/releases/download/v$\{{ steps.metadata.outputs.plugin-version }}/$\{{ steps.metadata.outputs.archive-checksum }}) in the MD5 field
- Paste this [.zip asset link](https://github.com/${{ github.repository }}/releases/download/v${{ steps.metadata.outputs.plugin-version }}/${{ steps.metadata.outputs.archive }}) in the Plugin URL field
- Paste this [.zip.md5 link](https://github.com/${{ github.repository }}/releases/download/v${{ steps.metadata.outputs.plugin-version }}/${{ steps.metadata.outputs.archive-checksum }}) in the MD5 field
Once done please remove these instructions and publish this release.

0 comments on commit ebf34a6

Please sign in to comment.