Skip to content

ci: Development workflow #1017

ci: Development workflow

ci: Development workflow #1017

Workflow file for this run

name: CI
on:
push:
branches:
- main
pull_request:
paths-ignore:
- docs/*
- docs/sources/**
branches:
- main
env:
BUNDLEWATCH_GITHUB_TOKEN: ${{secrets.BUNDLEWATCH_GITHUB_TOKEN}}
permissions:
contents: read
id-token: write
jobs:
frontend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'yarn'
- name: Install dependencies
run: yarn install --immutable
# lint
- name: Check TS types
run: yarn typecheck
- name: Lint
run: yarn lint
- name: Unit tests
run: yarn test:ci
- name: Report test coverage
uses: MishaKav/[email protected]
with:
title: Unit test coverage
- name: Build frontend
run: yarn build
- name: Check bundlesize
run: yarn run bundlewatch
- name: Compatibility check
run: npx @grafana/levitate@latest is-compatible --path src/module.ts --target @grafana/data,@grafana/ui,@grafana/runtime
- name: Setup plugin signing
uses: grafana/shared-workflows/actions/get-vault-secrets@main
with:
vault_instance: ops
common_secrets: |
SIGN_PLUGIN_ACCESS_POLICY_TOKEN=plugins/sign-plugin-access-policy-token:token
# create MANIFEST in dist
- name: Sign plugin
run: yarn sign
env:
GRAFANA_ACCESS_POLICY_TOKEN: ${{ env.SIGN_PLUGIN_ACCESS_POLICY_TOKEN }}
- uses: actions/upload-artifact@v4
if: always()
with:
name: build-frontend
path: dist
retention-days: 1
end-to-end:
runs-on: ubuntu-latest
timeout-minutes: 15
needs: [frontend]
steps:
- uses: actions/checkout@v4
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'yarn'
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
pattern: build-*
merge-multiple: true
path: dist
# E2E tests
# switch to "npm run" in order to prevent "Usage Error: Couldn't find the node_modules state file - running an install might help (findPackageLocation)" when using yarn
- name: Start Grafana server
run: npm run e2e:ci:server:up
- name: Prepare e2e tests
run: npm run e2e:ci:prepare
# commented to save time during the build (building this action takes ~30s)
# the next step "Prepare e2e test" takes ~20s, which gives us the time needed
# uncomment it if you experience flakiness
# - uses: cygnetdigital/[email protected]
# with:
# url: 'http://localhost:3000/a/grafana-pyroscope-app/single'
# responseCode: '200'
# timeout: 20000
# interval: 500
- name: Launch e2e tests
run: npm run e2e:ci
- name: Stop Grafana server
run: npm run e2e:ci:server:down
- uses: actions/upload-artifact@v4
if: always()
with:
name: e2e-test-reports-and-results
path: |
e2e/test-reports
e2e/test-results
retention-days: 15
package:
name: Package signed plugin
needs: [ frontend ]
environment: pull-requests
runs-on: ubuntu-latest
outputs:
package_id: ${{ steps.metadata.outputs.package_id }}
steps:
# Required to correctly auth to GCS
- name: Prepare - GCS
uses: actions/checkout@v4
- name: Prepare - Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-frontend
path: dist
- name: Get plugin metadata
id: metadata
run: |
sudo apt-get install jq
export GRAFANA_PLUGIN_ID=$(cat dist/plugin.json | jq -r .id)
export SHA=${{ github.event.pull_request.head.sha || github.sha }}
export PACKAGE_ID=${GRAFANA_PLUGIN_ID}-${SHA}
echo "plugin_id=${GRAFANA_PLUGIN_ID}" >> $GITHUB_OUTPUT
echo "package_id=${PACKAGE_ID}" >> $GITHUB_OUTPUT
echo "sha=${SHA}" >> $GITHUB_OUTPUT
echo "archive_name=${PACKAGE_ID}.zip" >> $GITHUB_OUTPUT
- name: Debug
run: echo archive_name=${{ steps.metadata.outputs.archive_name }}, plugin_id=${{ steps.metadata.outputs.plugin_id }}
- name: Package plugin
run: |
mv dist ${{ steps.metadata.outputs.plugin_id }}
zip ${{ steps.metadata.outputs.archive_name }} ${{ steps.metadata.outputs.plugin_id }} -r
- name: Login to GCS
uses: 'google-github-actions/auth@v2'
with:
workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GCS_SERVICE_ACCOUNT }}
- name: Upload to GCS
uses: 'google-github-actions/upload-cloud-storage@v1'
with:
path: ./
destination: 'grafana-pyroscope-app/test'
glob: '*.zip'
deploy-to-dev:
name: Deploy PR to dev (dry run)
needs: [ package ]
runs-on: ubuntu-latest
environment: pull-requests
steps:
- name: Publish to dev
run: echo Deploying ${{ needs.package.outputs.sha }} deployed to dev
# - name: Deploy to dev
# uses: grafana/shared-workflows/actions/[email protected]
# with:
# instance: "ops"
# namespace: "phlare-cd"
# workflow_template: "deploy-plugin-dev"
# parameters: |
# plugintag=${{ needs.package.outputs.sha }}
# extra_args: "--name deploy-plugin-dev-${{ needs.package.outputs.sha }} --dry-run"
# log_level: "debug"