This document describes the local development workflow, testing infrastructure, and quality tools used in the Grafana repository. It covers hot reload configuration, build automation, CI/CD optimization, test sharding strategies, and the testing frameworks used across frontend and backend.
For information about the build system architecture, see Frontend Monorepo and Backend Build System. For feature management, see Feature Toggles.
Grafana provides multiple entry points for local development, each optimized for different workflows. The primary interface for backend development is the Makefile, while frontend development primarily uses yarn.
Development Workflow Overview
Sources: contribute/developer-guide.md99-153 .github/workflows/pr-e2e-tests.yml65 .github/workflows/pr-test-integration.yml14
The development environment relies on specific tool versions and configurations:
.nvmrc and corepack contribute/developer-guide.md11 contribute/developer-guide.md41-46lefthook, these perform linting and eslint-suppressions.json synchronization contribute/developer-guide.md50-64Build Flags and Parameters: The backend build process uses optimized flags for fast iteration:
CGO_ENABLED=0 is used in CI and local dev to produce pure Go binaries, avoiding the need for a C compiler contribute/developer-guide.md168-171 .github/workflows/pr-test-integration.yml82linux-amd64, linux-arm64, and windows-amd64 .github/workflows/release-build.yml160-181Sources: contribute/developer-guide.md1-175 .github/workflows/release-build.yml135-182 .github/workflows/pr-test-integration.yml82
Grafana uses intelligent change detection to run only necessary tests in pull requests, significantly reducing CI time. This is managed via the .github/actions/change-detection action.
Sources: .github/workflows/pr-e2e-tests.yml34-36 .github/workflows/pr-test-integration.yml52-54 .github/workflows/frontend-lint.yml28-32
Workflows check change detection outputs to skip unnecessary work. For example, the E2E test workflow detects changes and sets a run-e2e-tests output:
.github/workflows/pr-e2e-tests.yml25
The subsequent jobs use this output to decide whether to run:
.github/workflows/pr-e2e-tests.yml40
Grafana parallelizes test execution across multiple CI workers using sharding strategies.
The backend tests are split using shard.sh. The SHARD environment variable (e.g., 1/16) controls package distribution. Integration tests specifically target tests named TestIntegration:
.github/workflows/pr-test-integration.yml85-86 .github/workflows/pr-test-integration.yml130-134
E2E tests (Playwright) are sharded using a matrix strategy:
shard: [1, 2, 3, 4, 5, 6, 7, 8]shardTotal: [8]
.github/workflows/pr-e2e-tests.yml169-170Test Types:
go test .github/workflows/backend-unit-tests.yml1make devenv to spin up database containers .github/workflows/pr-test-integration.yml114 .github/workflows/pr-test-integration.yml167Grafana utilizes Playwright for its modern E2E suite, replacing legacy Cypress tests.
Playwright Setup:
Playwright tests are located in e2e-playwright/. The CI workflow downloads pre-built backend and frontend artifacts to assemble a standalone distribution for testing .github/workflows/pr-e2e-tests.yml187-203
Selector Management:
Selectors are centrally managed in packages/grafana-e2e-selectors to ensure stability across UI changes packages/grafana-e2e-selectors/src/selectors/components.ts15 packages/grafana-e2e-selectors/src/selectors/pages.ts8
E2E Utility Functions: Common flows like importing dashboards or saving changes are abstracted into utility functions:
importTestDashboard: Handles JSON dashboard imports e2e-playwright/dashboard-new-layouts/utils.ts184saveDashboard: Interacts with the Save Drawer e2e-playwright/dashboard-new-layouts/utils.ts79yarn e2e:playwright:storybook .github/workflows/pr-e2e-tests.yml154The devenv/ directory contains Docker Compose configurations and Tiltfile definitions for local infrastructure.
Frontend Service Devenv:
The devenv/frontend-service/docker-compose.yaml defines a multi-service stack:
Sources: devenv/frontend-service/docker-compose.yaml1-163 .github/workflows/pr-test-integration.yml23
| Tool | Scope | Implementation |
|---|---|---|
go test | Backend Unit/Integration | go test -run '^TestIntegration' .github/workflows/pr-test-integration.yml134 |
Playwright | E2E / Storybook | yarn e2e:playwright .github/workflows/pr-e2e-tests.yml154 |
Levitate | API Breaking Changes | check-breaking-changes.sh .github/workflows/detect-breaking-changes-levitate.yml163 |
Yarn Lint | Frontend Style | yarn run lint .github/workflows/frontend-lint.yml53 |
Release Build | Packaging | make build-targz .github/workflows/release-build.yml24 |
Sources: .github/workflows/release-build.yml1-33 .github/workflows/pr-e2e-tests.yml150-170 .github/workflows/frontend-lint.yml1-81
Refresh this wiki