Skip to content

Commit c1c010e

Browse files
Docs: Set Up - AI sweep (#2263)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent ca96465 commit c1c010e

File tree

3 files changed

+51
-44
lines changed

3 files changed

+51
-44
lines changed

docusaurus/docs/set-up/index.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,20 @@ keywords:
1616
- configuration
1717
---
1818

19-
These guides walk you through setting up your development environment for Grafana plugin development. Including:
19+
# Set up your development environment
2020

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.
2434

2535
<DocLinkList />

docusaurus/docs/set-up/set-up-docker.md

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,20 @@ It's not necessary to [sign a plugin](/publish-a-plugin/sign-a-plugin.md) during
2929

3030
## Why use the Docker environment
3131

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.
3333

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.
3535

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.
3737

3838
## Get started with Docker
3939

4040
To start your plugin development project, run the following commands in the order listed:
4141

42-
1. <SyncCommand cmd="install" />: Installs frontend dependencies.
43-
1. <SyncCommand cmd="run dev" />: Builds and watches the plugin frontend code.
44-
1. `mage -v build:linux`: Builds the plugin backend code. Rerun this command every time that you edit your backend files.
45-
1. <SyncCommand cmd="run server" />: Starts a Grafana development server running on
46-
[http://localhost:3000](http://localhost:3000).
42+
1. **Install dependencies**: <SyncCommand cmd="install" /> installs frontend dependencies.
43+
1. **Build frontend**: <SyncCommand cmd="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**: <SyncCommand cmd="run server" /> starts a Grafana development server running on [http://localhost:3000](http://localhost:3000).
4746

4847
## Configure the Grafana version
4948

@@ -53,7 +52,7 @@ To test a plugin across different versions of Grafana, set an environment variab
5352

5453
## Configure the Grafana image
5554

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:
5756

5857
```yaml title="docker-compose.yaml"
5958
version: '3.7'
@@ -73,11 +72,11 @@ This example assigns the environment variable `GRAFANA_IMAGE` to the build arg `
7372

7473
## Debugging a plugin's backend
7574

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.
7976

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"
8180
{
8281
"version": "0.2.0",
8382
"configurations": [
@@ -94,7 +93,7 @@ For example, in VSCode, you can add a `launch.json` configuration like this:
9493
"substitutePath": [
9594
{
9695
"from": "${workspaceFolder}",
97-
"to": "/root/<your-plugin-id>"
96+
"to": "/root/<YOUR_PLUGIN_ID>"
9897
}
9998
]
10099
}

docusaurus/docs/set-up/set-up-github.md

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Automate your development process to minimize errors and make it faster and more
2121

2222
## The CI workflow
2323

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).
2525

2626
## The release workflow
2727

@@ -35,21 +35,19 @@ This workflow requires a Grafana Cloud API key. Before you begin, follow the ins
3535

3636
### Storing your Access Policy token as a repository secret in GitHub
3737

38-
1. Access Repository Settings:
38+
1. **Access Repository Settings**:
39+
- Go to your GitHub repository.
40+
- Navigate to the **Settings** tab.
3941

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.
4247

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.
4649

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:
5351

5452
```yaml title="release.yml"
5553
name: Release
@@ -64,34 +62,34 @@ jobs:
6462
grafana_token: ${{ secrets.GRAFANA_ACCESS_POLICY_TOKEN }}
6563
```
6664
67-
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.
6866

6967
### Triggering the workflow
7068

7169
To trigger the release workflow, push a Git tag for the plugin version that you want to release:
7270

73-
```bash
71+
```sh
7472
git tag v1.0.0
7573
git push origin v1.0.0
7674
```
7775

7876
## The compatibility check workflow
7977

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.
8179

8280
The workflow contains the following steps:
8381

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.
8987

9088
## The create plugin update workflow
9189

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.
9391

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:
9593

9694
### Use the default access token
9795

@@ -118,7 +116,7 @@ jobs:
118116

119117
### Use a personal access token
120118

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 token to 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:
122120

123121
```yaml
124122
name: Create Plugin Update
@@ -139,7 +137,7 @@ jobs:
139137

140138
## The bundle stats workflow
141139

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.
143141

144142
```yaml title="bundle-stats.yml"
145143
name: Bundle Stats
@@ -173,4 +171,4 @@ jobs:
173171

174172
#### Main stats artifact could not be found
175173

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

Comments
 (0)