Skip to content

Latest commit

 

History

History
103 lines (79 loc) · 4.74 KB

CONTRIBUTING.md

File metadata and controls

103 lines (79 loc) · 4.74 KB

Development process

There are following scripts defined in package.json:

  • build:prod – production-ready build of frontend part
  • build:dev - development build (no uglify etc.) of frontend part
  • build:watch - automatically rebuild frontend TypeScript+HTML part of codebase on change (handy while developing)
  • test - runs frontend test suite using Jest
  • test:watch - runs frontend test suite using Jest in watch mode. Automatically reruns tests on source change.
  • sign - runs grafana plugin sign in dist directory

Each script can be run using NPM or Yarn package managers:

npm run <script>

or

yarn run <script>

(for example npm run build)

For test examples please see spec folder. We strongly encourage contributors to add tests to check new changes or functionality.

Docker-compose environment for development

This is a simple environment which mounts the current dist directory inside the grafana container. The grafana container connects to the docker clickhouse database container. Also grafana container contains some datasource and dashboards installed via /etc/grafana/provisioning/ folder.

To run the development environment install Docker and docker-compose:

docker-compose up --no-deps -d grafana clickhouse

after that open http://localhost:3000/ to open grafana instance with one clickhouse datasource

Frontend Builder

The frontend builder is the docker container used to transpile the typescript source code into the javascript found in the dist dir. This will affect the grafana query and configuration functionality.

To develop using docker, the process looks like:

  1. change source files
  2. docker-compose up frontend_builder
  3. docker-compose restart grafana
  4. open http://localhost:3000/

To develop without build inside a docker, the development process for frontend part of code looks like:

  1. change source files
  2. npm run test
  3. npm run build:dev
  4. docker-compose restart grafana
  5. open http://localhost:3000/

Backend Builder

The backend builder is the docker container used to compile the golang source code into the vertamedia-clickhouse-plugin_linux_amd64 binary in the dist dir. This will affect the grafana service used for running queries for alerting. The entrypoint for the go code is at pkg/main.go.

To develop using docker, the development process for backend part of code looks like:

  1. change source files
  2. docker-compose up backend_builder
  3. docker-compose restart grafana
  4. open http://localhost:3000/

To format your go code, use the command:

docker-compose run --rm backend_builder go fmt .

The resulting alerts should look like this image

How to make a new release

#!/usr/bin/env bash
set +x
export GITHUB_LOGIN="<your_github_login>"
export GITHUB_EMAIL="<your_github_email>"
export GITHUB_TOKEN="<your_github_token>"
set -xeuo pipefail
  • run ./release.sh with following parameters:
    • ./release.sh patch - for minor hotfix releases
    • ./release.sh minor - for minor and backward compatible improvements releases
    • ./release.sh major - for major or backward incompatible improvements releases
  • this script will run frontend_builder, backend_builder, plugin_signer via docker-compose and run tests and make git commit + git push if test pass

Final manual steps