Merge branch 'makefile-improvements' of github.com:dneth/grafana-zabbix into dneth-makefile-improvements
This commit is contained in:
@@ -26,40 +26,58 @@ jobs:
|
||||
build:
|
||||
working_directory: ~/alexanderzobnin/grafana-zabbix
|
||||
docker:
|
||||
- image: circleci/node:8
|
||||
- image: circleci/golang:1.13-node
|
||||
environment:
|
||||
YARN_NO_PROGRESS: "true"
|
||||
steps:
|
||||
- checkout
|
||||
- restore_cache:
|
||||
keys:
|
||||
- dependency-cache-{{ checksum "yarn.lock" }}
|
||||
- dependency-cache-npm-{{ checksum "yarn.lock" }}
|
||||
- restore_cache:
|
||||
keys:
|
||||
- dependency-cache-go-{{ checksum "go.sum" }}
|
||||
- run:
|
||||
name: yarn install
|
||||
command: 'yarn install --pure-lockfile --no-progress'
|
||||
name: Install Dependencies
|
||||
command: 'make install'
|
||||
no_output_timeout: 15m
|
||||
- save_cache:
|
||||
key: dependency-cache-{{ checksum "yarn.lock" }}
|
||||
key: dependency-cache-npm-{{ checksum "yarn.lock" }}
|
||||
paths:
|
||||
- ./node_modules
|
||||
- run: npm run build
|
||||
- save_cache:
|
||||
key: dependency-cache-go-{{ checksum "go.sum" }}
|
||||
paths:
|
||||
- ./vendor
|
||||
- /go/pkg/mod
|
||||
- run: make build
|
||||
|
||||
lint:
|
||||
working_directory: ~/alexanderzobnin/grafana-zabbix
|
||||
docker:
|
||||
- image: circleci/node:8
|
||||
- image: circleci/golang:1.13-node
|
||||
steps:
|
||||
- checkout
|
||||
- restore_cache:
|
||||
keys:
|
||||
- dependency-cache-{{ checksum "yarn.lock" }}
|
||||
- dependency-cache-npm-{{ checksum "yarn.lock" }}
|
||||
- restore_cache:
|
||||
keys:
|
||||
- dependency-cache-go-{{ checksum "go.sum" }}
|
||||
- run:
|
||||
name: yarn install
|
||||
command: 'yarn install --pure-lockfile --no-progress'
|
||||
name: Install Dependencies
|
||||
command: 'make install'
|
||||
no_output_timeout: 15m
|
||||
- save_cache:
|
||||
key: dependency-cache-{{ checksum "yarn.lock" }}
|
||||
key: dependency-cache-npm-{{ checksum "yarn.lock" }}
|
||||
paths:
|
||||
- ./node_modules
|
||||
- run: npm run lint
|
||||
- save_cache:
|
||||
key: dependency-cache-go-{{ checksum "go.sum" }}
|
||||
paths:
|
||||
- ./vendor
|
||||
- /go/pkg/mod
|
||||
- run: make lint
|
||||
|
||||
test:
|
||||
working_directory: ~/alexanderzobnin/grafana-zabbix
|
||||
@@ -67,7 +85,7 @@ jobs:
|
||||
CIRCLE_ARTIFACTS: /tmp/circleci-artifacts
|
||||
CIRCLE_TEST_REPORTS: /tmp/circleci-test-results
|
||||
docker:
|
||||
- image: circleci/node:8
|
||||
- image: circleci/golang:1.13-node
|
||||
steps:
|
||||
- checkout
|
||||
# Prepare for artifact and test results collection equivalent to how it was done on 1.0.
|
||||
@@ -76,16 +94,25 @@ jobs:
|
||||
- run: mkdir -p $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS
|
||||
- restore_cache:
|
||||
keys:
|
||||
- dependency-cache-{{ checksum "yarn.lock" }}
|
||||
- dependency-cache-npm-{{ checksum "yarn.lock" }}
|
||||
- restore_cache:
|
||||
keys:
|
||||
- dependency-cache-go-{{ checksum "go.sum" }}
|
||||
- run:
|
||||
name: yarn install
|
||||
command: 'yarn install --pure-lockfile --no-progress'
|
||||
name: Install Dependencies
|
||||
command: 'make install'
|
||||
no_output_timeout: 15m
|
||||
- save_cache:
|
||||
key: dependency-cache-{{ checksum "yarn.lock" }}
|
||||
key: dependency-cache-npm-{{ checksum "yarn.lock" }}
|
||||
paths:
|
||||
- ./node_modules
|
||||
- run: npm run ci-test
|
||||
- save_cache:
|
||||
key: dependency-cache-go-{{ checksum "go.sum" }}
|
||||
paths:
|
||||
- ./vendor
|
||||
- /go/pkg/mod
|
||||
- run: make test-ci
|
||||
- run: bash <(curl -s https://codecov.io/bash) || echo "Codecov did not collect coverage reports"
|
||||
- store_test_results:
|
||||
path: /tmp/circleci-test-results
|
||||
- store_artifacts:
|
||||
@@ -96,7 +123,7 @@ jobs:
|
||||
make-release:
|
||||
working_directory: ~/alexanderzobnin/grafana-zabbix
|
||||
docker:
|
||||
- image: circleci/node:8
|
||||
- image: circleci/golang:1.13-node
|
||||
environment:
|
||||
CI_GIT_USER: CircleCI
|
||||
CI_GIT_EMAIL: ci@grafana.com
|
||||
@@ -107,15 +134,23 @@ jobs:
|
||||
- checkout
|
||||
- restore_cache:
|
||||
keys:
|
||||
- dependency-cache-{{ checksum "yarn.lock" }}
|
||||
- dependency-cache-npm-{{ checksum "yarn.lock" }}
|
||||
- restore_cache:
|
||||
keys:
|
||||
- dependency-cache-go-{{ checksum "go.sum" }}
|
||||
- run:
|
||||
name: yarn install
|
||||
command: 'yarn install --pure-lockfile --no-progress'
|
||||
name: Install Dependencies
|
||||
command: 'make install'
|
||||
no_output_timeout: 15m
|
||||
- save_cache:
|
||||
key: dependency-cache-{{ checksum "yarn.lock" }}
|
||||
key: dependency-cache-npm-{{ checksum "yarn.lock" }}
|
||||
paths:
|
||||
- ./node_modules
|
||||
- save_cache:
|
||||
key: dependency-cache-go-{{ checksum "go.sum" }}
|
||||
paths:
|
||||
- ./vendor
|
||||
- /go/pkg/mod
|
||||
- run: ./.circleci/make-release.sh
|
||||
|
||||
build-docs:
|
||||
@@ -141,7 +176,7 @@ jobs:
|
||||
deploy-docs:
|
||||
working_directory: ~/grafana-zabbix
|
||||
docker:
|
||||
- image: circleci/node:8
|
||||
- image: circleci/golang:1.13-node
|
||||
environment:
|
||||
GH_PAGES_BRANCH: gh-pages
|
||||
CI_GIT_USER: CircleCI
|
||||
@@ -162,7 +197,7 @@ jobs:
|
||||
steps:
|
||||
- checkout
|
||||
- run: sudo pip install codespell
|
||||
- run: codespell -S './.git*,./src/img*' -L que
|
||||
- run: codespell -S './.git*,./src/img*,./go.sum' -L que
|
||||
|
||||
workflows:
|
||||
version: 2
|
||||
|
||||
@@ -29,7 +29,7 @@ RELEASE_BRANCH=release-$RELEASE_VER
|
||||
|
||||
# Build plugin
|
||||
git checkout -b $RELEASE_BRANCH
|
||||
yarn install --pure-lockfile && yarn build
|
||||
make clean install dist
|
||||
|
||||
# Commit release
|
||||
git add --force dist/
|
||||
|
||||
47
Makefile
47
Makefile
@@ -1,7 +1,44 @@
|
||||
all: frontend backend
|
||||
all: install build test lint
|
||||
|
||||
frontend:
|
||||
yarn dev-build
|
||||
# Install dependencies
|
||||
install:
|
||||
# Frontend
|
||||
yarn install --pure-lockfile
|
||||
# Backend
|
||||
go mod vendor
|
||||
GO111MODULE=off go get -u golang.org/x/lint/golint
|
||||
|
||||
backend:
|
||||
go build -o ./dist/zabbix-plugin_linux_amd64 ./pkg
|
||||
build: build-frontend build-backend
|
||||
build-frontend:
|
||||
npm run dev-build
|
||||
build-backend:
|
||||
env GOOS=linux go build -mod=vendor -o ./dist/zabbix-plugin_linux_amd64 ./pkg
|
||||
|
||||
dist: dist-frontend dist-backend
|
||||
dist-frontend:
|
||||
npm run build
|
||||
dist-backend: dist-backend-linux dist-backend-darwin dist-backend-windows
|
||||
dist-backend-windows: extension = .exe
|
||||
dist-backend-%:
|
||||
$(eval filename = zabbix-plugin_$*_amd64$(extension))
|
||||
env GOOS=$* GOARCH=amd64 go build -ldflags="-s -w" -mod=vendor -o ./dist/$(filename) ./pkg
|
||||
|
||||
.PHONY: test
|
||||
test: test-frontend test-backend
|
||||
test-frontend:
|
||||
npm run test
|
||||
test-backend:
|
||||
go test -v -mod=vendor ./pkg/...
|
||||
test-ci:
|
||||
npm run ci-test
|
||||
mkdir -p tmp/coverage/golang/
|
||||
go test -race -coverprofile=tmp/coverage/golang/coverage.txt -covermode=atomic -mod=vendor ./pkg/...
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-rm -r ./dist/
|
||||
|
||||
.PHONY: lint
|
||||
lint:
|
||||
npm run lint
|
||||
golint -set_exit_status pkg/...
|
||||
|
||||
2
go.mod
2
go.mod
@@ -10,5 +10,5 @@ require (
|
||||
github.com/hashicorp/go-plugin v1.0.1
|
||||
github.com/kr/pretty v0.1.0 // indirect
|
||||
github.com/patrickmn/go-cache v2.1.0+incompatible
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a
|
||||
)
|
||||
|
||||
7
go.sum
7
go.sum
@@ -5,6 +5,7 @@ github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dR
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
@@ -34,11 +35,17 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d h1:g9qWBGx4puODJTMVyoPrpoxPFgVGd+z1DZwjfRu4d0I=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190129075346-302c3dd5f1cc h1:WiYx1rIFmx8c0mXAFtv5D/mHyKe1+jmuP7PViuwqwuQ=
|
||||
golang.org/x/sys v0.0.0-20190129075346-302c3dd5f1cc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 h1:Nw54tB0rB7hY/N0NQvRW8DG4Yk3Q6T9cu9RcFQDu1tc=
|
||||
|
||||
@@ -22,7 +22,7 @@ module.exports = {
|
||||
"^.+\\.js$": "babel-jest",
|
||||
"^.+\\.(ts|tsx)$": "ts-jest"
|
||||
},
|
||||
"coverageDirectory": "<rootDir>/tmp/coverage/",
|
||||
"coverageDirectory": "<rootDir>/tmp/coverage/node/",
|
||||
"collectCoverage": false,
|
||||
"globals": {
|
||||
"ts-jest": {
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
"test": "jest",
|
||||
"jest": "jest --notify --watch",
|
||||
"codecov": "jest --coverage && codecov",
|
||||
"ci-test": "jest --coverage && codecov",
|
||||
"ci-test": "jest --coverage",
|
||||
"lint": "jshint --reporter=node_modules/jshint-stylish src/ & jscs src/",
|
||||
"benchmark": "webpack --config webpack/webpack.bench.conf.js && grunt bench"
|
||||
},
|
||||
|
||||
3
pkg/cache_test.go
Normal file
3
pkg/cache_test.go
Normal file
@@ -0,0 +1,3 @@
|
||||
package main
|
||||
|
||||
// Dummy test file for now
|
||||
@@ -26,7 +26,7 @@ function convertHistory(history, items, addHostName, convertPointCallback) {
|
||||
var grouped_history = _.groupBy(history, 'itemid');
|
||||
var hosts = _.uniqBy(_.flatten(_.map(items, 'hosts')), 'hostid'); //uniqBy is needed to deduplicate
|
||||
|
||||
return _.map(grouped_history, function(hist, itemid) {
|
||||
return _.map(grouped_history, function(historyPoint, itemid) {
|
||||
var item = _.find(items, {'itemid': itemid});
|
||||
var alias = item.name;
|
||||
if (_.keys(hosts).length > 1 && addHostName) { //only when actual multi hosts selected
|
||||
@@ -35,7 +35,7 @@ function convertHistory(history, items, addHostName, convertPointCallback) {
|
||||
}
|
||||
return {
|
||||
target: alias,
|
||||
datapoints: _.map(hist, convertPointCallback)
|
||||
datapoints: _.map(historyPoint, convertPointCallback)
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3,6 +3,11 @@
|
||||
"name": "Zabbix",
|
||||
"id": "alexanderzobnin-zabbix-app",
|
||||
|
||||
"metrics": true,
|
||||
"annotations": true,
|
||||
"backend": true,
|
||||
"executable": "zabbix",
|
||||
|
||||
"info": {
|
||||
"description": "Zabbix plugin for Grafana",
|
||||
"author": {
|
||||
@@ -26,8 +31,8 @@
|
||||
{"name": "Metric Editor", "path": "img/screenshot-metric_editor.png"},
|
||||
{"name": "Triggers", "path": "img/screenshot-triggers.png"}
|
||||
],
|
||||
"version": "3.10.4",
|
||||
"updated": "2019-08-08"
|
||||
"version": "4.0.0",
|
||||
"updated": "2019-10-08"
|
||||
},
|
||||
|
||||
"includes": [
|
||||
|
||||
Reference in New Issue
Block a user