You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docusaurus/docs/set-up/index.md
+14-4Lines changed: 14 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,10 +16,20 @@ keywords:
16
16
- configuration
17
17
---
18
18
19
-
These guides walk you through setting up your development environment for Grafana plugin development. Including:
19
+
# Set up your development environment
20
20
21
-
- Running a development Grafana server with your plugin installed using Docker
22
-
- Setting up GitHub workflows to automate your development and release process
23
-
- Extending configurations for ESLint, Prettier, Jest, TypeScript, and Webpack
21
+
This section helps you configure a complete development environment for Grafana plugin development. You'll learn how to set up local development tools and automate your development workflow.
22
+
23
+
Before you begin, ensure you have the following:
24
+
25
+
- A Grafana plugin project created with [`create-plugin`](/get-started.md)
26
+
- Docker installed on your system
27
+
- A GitHub repository for your plugin (optional, for CI/CD setup)
28
+
29
+
These guides cover essential development environment setup:
30
+
31
+
-**Docker environment**: Run a development Grafana server with your plugin installed using Docker.
32
+
-**GitHub workflows**: Set up GitHub workflows to automate your development and release process.
33
+
-**Configuration extensions**: Extend configurations for ESLint, Prettier, Jest, TypeScript, and Webpack.
Copy file name to clipboardExpand all lines: docusaurus/docs/set-up/set-up-docker.md
+13-14Lines changed: 13 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,21 +29,20 @@ It's not necessary to [sign a plugin](/publish-a-plugin/sign-a-plugin.md) during
29
29
30
30
## Why use the Docker environment
31
31
32
-
We have chosen to use Docker because it simplifies the process of creating, deploying, and running applications. It allows you to create consistent and isolated environments for your plugin. This makes it easy to manage dependencies and ensure that the plugin runs the same way across different machines.
32
+
Docker simplifies the process of creating, deploying, and running applications. It lets you create consistent and isolated environments for your plugin. This makes it easy to manage dependencies and ensures that your plugin runs the same way across different machines.
33
33
34
-
With the `create-plugin` tool, the Docker container is configured with the necessary variables to allow easy access to Grafana and to load plugins without the need for them to be signed. The plugin tool also adds a live reload feature that allows you to make your frontend code changes to trigger refreshes in the browser, and changing the backend code will make the plugin binary to automatically reload.
34
+
The `create-plugin` tool configures the Docker container with the necessary variables to allow easy access to Grafana and load plugins without signing them. The plugin tool also adds a live reload feature that triggers browser refreshes when you make frontend code changes, and automatically reloads the plugin binary when you change backend code.
35
35
36
-
The docker environment also allows you to attach a debugger to the plugin backend code, making the development process easier.
36
+
The Docker environment also lets you attach a debugger to the plugin backend code, making the development process easier.
37
37
38
38
## Get started with Docker
39
39
40
40
To start your plugin development project, run the following commands in the order listed:
1.**Build frontend**: <SyncCommandcmd="run dev" /> builds and watches the plugin frontend code.
44
+
1.**Build backend**: `mage -v build:linux` builds the plugin backend code. Rerun this command every time you edit your backend files.
45
+
1.**Start server**: <SyncCommandcmd="run server" /> starts a Grafana development server running on [http://localhost:3000](http://localhost:3000).
47
46
48
47
## Configure the Grafana version
49
48
@@ -53,7 +52,7 @@ To test a plugin across different versions of Grafana, set an environment variab
53
52
54
53
## Configure the Grafana image
55
54
56
-
The default Docker image in the plugin tool is `grafana-enterprise`. If you want to override this image, alter the `docker-compose.yaml` by changing the `grafana_image` build argument like so:
55
+
The default Docker image in the plugin tool is `grafana-enterprise`. To override this image, alter the `docker-compose.yaml` by changing the `grafana_image` build argument:
57
56
58
57
```yaml title="docker-compose.yaml"
59
58
version: '3.7'
@@ -73,11 +72,11 @@ This example assigns the environment variable `GRAFANA_IMAGE` to the build arg `
73
72
74
73
## Debugging a plugin's backend
75
74
76
-
If you're developing a plugin with a backend part, run `npm run server` with `DEVELOPMENT=true`. The docker compose file exposes the port `2345` for debugging, from a headless delve instance that will run inside the docker environment.
77
-
You can attach a debugger client to this port to debug your backend code.
78
-
For example, in VSCode, you can add a `launch.json` configuration like this:
75
+
If you're developing a plugin with a backend part, run `npm run server` with `DEVELOPMENT=true`. The Docker Compose file exposes port `2345` for debugging, from a headless delve instance that runs inside the Docker environment.
79
76
80
-
```json
77
+
You can attach a debugger client to this port to debug your backend code. For example, in VS Code, add a `launch.json` configuration:
78
+
79
+
```json title="launch.json"
81
80
{
82
81
"version": "0.2.0",
83
82
"configurations": [
@@ -94,7 +93,7 @@ For example, in VSCode, you can add a `launch.json` configuration like this:
Copy file name to clipboardExpand all lines: docusaurus/docs/set-up/set-up-github.md
+24-26Lines changed: 24 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,7 @@ Automate your development process to minimize errors and make it faster and more
21
21
22
22
## The CI workflow
23
23
24
-
The CI (`ci.yml`) workflow is designed to lint, type check, and build the frontend and backend. It is also used to run tests on your plugin every time you push changes to your repository. The `create-plugin` tool helps to catch any issues early in the development process, before they become bigger problems. For more information on end-to-end testing as part of the CI workflow, refer to our [documentation](/e2e-test-a-plugin/ci.md).
24
+
The CI (`ci.yml`) workflow lints, type checks, and builds the frontend and backend. It also runs tests on your plugin every time you push changes to your repository. The `create-plugin` tool helps catch any issues early in the development process, before they become bigger problems. For more information on end-to-end testing as part of the CI workflow, refer to our [documentation](/e2e-test-a-plugin/ci.md).
25
25
26
26
## The release workflow
27
27
@@ -35,21 +35,19 @@ This workflow requires a Grafana Cloud API key. Before you begin, follow the ins
35
35
36
36
### Storing your Access Policy token as a repository secret in GitHub
37
37
38
-
1. Access Repository Settings:
38
+
1.**Access Repository Settings**:
39
+
- Go to your GitHub repository.
40
+
- Navigate to the **Settings** tab.
39
41
40
-
- Go to your GitHub repository.
41
-
- Navigate to the "Settings" tab.
42
+
2. In the left sidebar, click on **Secrets and Variables** > **Actions**.
43
+
3. Click on the **New repository secret** button.
44
+
4.**Add Secret Information**:
45
+
- Enter the name for your secret: `GRAFANA_ACCESS_POLICY_TOKEN`.
46
+
- Paste the Access Policy Token value into the **Secret** field.
42
47
43
-
2. In the left sidebar, click on Secrets and Variables -> Actions
44
-
3. Click on the "New repository secret" button.
45
-
4. Add Secret Information:
48
+
5. Click on the **Add secret** button to save the secret.
46
49
47
-
- Enter name for your secret - GRAFANA_ACCESS_POLICY_TOKEN.
48
-
- Paste the Access Policy Token value into the "Secret" field.
49
-
50
-
5. Click on the "Add secret" button to save the secret.
51
-
52
-
Once the secret is stored, you can access it in your GitHub Actions workflow:
50
+
After you store the secret, you can access it in your GitHub Actions workflow:
In this example, the `secrets.GRAFANA_ACCESS_POLICY_TOKEN` variable is used to access the stored token securely within your GitHub Actions workflow. Make sure to adjust the workflow according to your specific needs and the language/environment you are working with.
65
+
In this example, the `secrets.GRAFANA_ACCESS_POLICY_TOKEN` variable accesses the stored token securely within your GitHub Actions workflow. Adjust the workflow according to your specific needs and the language or environment you're working with.
68
66
69
67
### Triggering the workflow
70
68
71
69
To trigger the release workflow, push a Git tag for the plugin version that you want to release:
72
70
73
-
```bash
71
+
```sh
74
72
git tag v1.0.0
75
73
git push origin v1.0.0
76
74
```
77
75
78
76
## The compatibility check workflow
79
77
80
-
The compatibility check (`is-compatible.yml`) workflow is designed to check the Grafana API compatibility of your plugin every time you push changes to your repository. This helps to catch potential frontend runtime issues before they occur.
78
+
The compatibility check (`is-compatible.yml`) workflow checks the Grafana API compatibility of your plugin every time you push changes to your repository. This helps catch potential frontend runtime issues before they occur.
81
79
82
80
The workflow contains the following steps:
83
81
84
-
1. Finding `@grafana` npm packages in your plugin.
85
-
1. Extracting the exported types of the specified version.
86
-
1. Comparing the differences between that version and the latest version.
87
-
1. Looking for usages of those changed APIs inside your plugin.
88
-
1. Reporting any potential incompatibilities.
82
+
1. **Find packages**: Finds `@grafana` npm packages in your plugin.
83
+
1. **Extract types**: Extracts the exported types of the specified version.
84
+
1. **Compare versions**: Compares the differences between that version and the latest version.
85
+
1. **Check usage**: Looks for usages of those changed APIs inside your plugin.
86
+
1. **Report issues**: Reports any potential incompatibilities.
89
87
90
88
## The create plugin update workflow
91
89
92
-
The create plugin update (`cp-update.yml`) workflow is designed to automate keeping your plugins development environment and dependencies up to date. It periodically checks the latest version of create-plugin listed on the npm registry and compares it to the version used by your plugin. If there is a newer version available the workflow will run the `create-plugin update` command, update the frontend dependency lockfile, then create a PR with the changes for review.
90
+
The create plugin update (`cp-update.yml`) workflow automates keeping your plugin's development environment and dependencies up to date. It periodically checks the latest version of create-plugin listed on the npm registry and compares it to the version used by your plugin. If there's a newer version available, the workflow runs the `create-plugin update` command, updates the frontend dependency lockfile, then creates a PR with the changes for review.
93
91
94
-
This workflow requires content and pull request write access to your plugins repo to be able to push changes and open PRs. Choose from the following two options:
92
+
This workflow requires content and pull request write access to your plugin's repo to push changes and open PRs. Choose from the following two options:
95
93
96
94
### Use the default access token
97
95
@@ -118,7 +116,7 @@ jobs:
118
116
119
117
### Use a personal access token
120
118
121
-
To use this option you must create a Github [fine-grained personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens) with access to the plugin repository and permission to read and write both `contents` and `pull requests`. Once created add the tokento the plugin repository action secrets and then pass it to the action like so:
119
+
To use this option, you must create a GitHub [fine-grained personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens) with access to the plugin repository and permission to read and write both `contents` and `pull requests`. After you create the token, add it to the plugin repository action secrets and then pass it to the action:
122
120
123
121
```yaml
124
122
name: Create Plugin Update
@@ -139,7 +137,7 @@ jobs:
139
137
140
138
## The bundle stats workflow
141
139
142
-
The bundle stats (`bundle-stats.yml`) workflow is intended to help developers keep an eye on the size of their plugins frontend assets. Changes in PRs trigger this workflow which will compare two webpack stats files; one from the default branch and the other from the PR. It then calculates differences between these assets sizes and posts a formatted comment to the PR giving an overview of any size differences.
140
+
The bundle stats (`bundle-stats.yml`) workflow helps developers monitor the size of their plugin's frontend assets. Changes in PRs trigger this workflow, which compares two webpack stats files:one from the default branch and the other from the PR. It then calculates differences between these asset sizes and posts a formatted comment to the PR with an overview of any size differences.
143
141
144
142
```yaml title="bundle-stats.yml"
145
143
name: Bundle Stats
@@ -173,4 +171,4 @@ jobs:
173
171
174
172
#### Main stats artifact could not be found
175
173
176
-
If you see this warning during bundle size workflow runs it means that the workflow failed to find the github artifact that contains the main branch stats file. The file can be generated by either merging a PR to main, pushing a commit to main, or manually running the workflow with workflow_dispatch.
174
+
If you see this warning during bundle size workflow runs, it means that the workflow failed to find the GitHub artifact that contains the main branch stats file. You can generate the file by merging a PR to main, pushing a commit to main, or manually running the workflow with `workflow_dispatch`.
0 commit comments