Merge branch 'dneth-makefile-improvements' into backend

This commit is contained in:
Alexander Zobnin
2019-12-12 11:38:32 +03:00
11 changed files with 1617 additions and 1756 deletions

View File

@@ -26,40 +26,58 @@ jobs:
build: build:
working_directory: ~/alexanderzobnin/grafana-zabbix working_directory: ~/alexanderzobnin/grafana-zabbix
docker: docker:
- image: circleci/node:8 - image: circleci/golang:1.13-node
environment:
YARN_NO_PROGRESS: "true"
steps: steps:
- checkout - checkout
- restore_cache: - restore_cache:
keys: keys:
- dependency-cache-{{ checksum "yarn.lock" }} - dependency-cache-npm-{{ checksum "yarn.lock" }}
- restore_cache:
keys:
- dependency-cache-go-{{ checksum "go.sum" }}
- run: - run:
name: yarn install name: Install Dependencies
command: 'yarn install --pure-lockfile --no-progress' command: 'make install'
no_output_timeout: 15m no_output_timeout: 15m
- save_cache: - save_cache:
key: dependency-cache-{{ checksum "yarn.lock" }} key: dependency-cache-npm-{{ checksum "yarn.lock" }}
paths: paths:
- ./node_modules - ./node_modules
- run: npm run build - save_cache:
key: dependency-cache-go-{{ checksum "go.sum" }}
paths:
- ./vendor
- /go/pkg/mod
- run: make build
lint: lint:
working_directory: ~/alexanderzobnin/grafana-zabbix working_directory: ~/alexanderzobnin/grafana-zabbix
docker: docker:
- image: circleci/node:8 - image: circleci/golang:1.13-node
steps: steps:
- checkout - checkout
- restore_cache: - restore_cache:
keys: keys:
- dependency-cache-{{ checksum "yarn.lock" }} - dependency-cache-npm-{{ checksum "yarn.lock" }}
- restore_cache:
keys:
- dependency-cache-go-{{ checksum "go.sum" }}
- run: - run:
name: yarn install name: Install Dependencies
command: 'yarn install --pure-lockfile --no-progress' command: 'make install'
no_output_timeout: 15m no_output_timeout: 15m
- save_cache: - save_cache:
key: dependency-cache-{{ checksum "yarn.lock" }} key: dependency-cache-npm-{{ checksum "yarn.lock" }}
paths: paths:
- ./node_modules - ./node_modules
- run: npm run lint - save_cache:
key: dependency-cache-go-{{ checksum "go.sum" }}
paths:
- ./vendor
- /go/pkg/mod
- run: make lint
test: test:
working_directory: ~/alexanderzobnin/grafana-zabbix working_directory: ~/alexanderzobnin/grafana-zabbix
@@ -67,7 +85,7 @@ jobs:
CIRCLE_ARTIFACTS: /tmp/circleci-artifacts CIRCLE_ARTIFACTS: /tmp/circleci-artifacts
CIRCLE_TEST_REPORTS: /tmp/circleci-test-results CIRCLE_TEST_REPORTS: /tmp/circleci-test-results
docker: docker:
- image: circleci/node:8 - image: circleci/golang:1.13-node
steps: steps:
- checkout - checkout
# Prepare for artifact and test results collection equivalent to how it was done on 1.0. # 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 - run: mkdir -p $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS
- restore_cache: - restore_cache:
keys: keys:
- dependency-cache-{{ checksum "yarn.lock" }} - dependency-cache-npm-{{ checksum "yarn.lock" }}
- restore_cache:
keys:
- dependency-cache-go-{{ checksum "go.sum" }}
- run: - run:
name: yarn install name: Install Dependencies
command: 'yarn install --pure-lockfile --no-progress' command: 'make install'
no_output_timeout: 15m no_output_timeout: 15m
- save_cache: - save_cache:
key: dependency-cache-{{ checksum "yarn.lock" }} key: dependency-cache-npm-{{ checksum "yarn.lock" }}
paths: paths:
- ./node_modules - ./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: - store_test_results:
path: /tmp/circleci-test-results path: /tmp/circleci-test-results
- store_artifacts: - store_artifacts:
@@ -96,7 +123,7 @@ jobs:
make-release: make-release:
working_directory: ~/alexanderzobnin/grafana-zabbix working_directory: ~/alexanderzobnin/grafana-zabbix
docker: docker:
- image: circleci/node:8 - image: circleci/golang:1.13-node
environment: environment:
CI_GIT_USER: CircleCI CI_GIT_USER: CircleCI
CI_GIT_EMAIL: ci@grafana.com CI_GIT_EMAIL: ci@grafana.com
@@ -107,15 +134,23 @@ jobs:
- checkout - checkout
- restore_cache: - restore_cache:
keys: keys:
- dependency-cache-{{ checksum "yarn.lock" }} - dependency-cache-npm-{{ checksum "yarn.lock" }}
- restore_cache:
keys:
- dependency-cache-go-{{ checksum "go.sum" }}
- run: - run:
name: yarn install name: Install Dependencies
command: 'yarn install --pure-lockfile --no-progress' command: 'make install'
no_output_timeout: 15m no_output_timeout: 15m
- save_cache: - save_cache:
key: dependency-cache-{{ checksum "yarn.lock" }} key: dependency-cache-npm-{{ checksum "yarn.lock" }}
paths: paths:
- ./node_modules - ./node_modules
- save_cache:
key: dependency-cache-go-{{ checksum "go.sum" }}
paths:
- ./vendor
- /go/pkg/mod
- run: ./.circleci/make-release.sh - run: ./.circleci/make-release.sh
build-docs: build-docs:
@@ -141,7 +176,7 @@ jobs:
deploy-docs: deploy-docs:
working_directory: ~/grafana-zabbix working_directory: ~/grafana-zabbix
docker: docker:
- image: circleci/node:8 - image: circleci/golang:1.13-node
environment: environment:
GH_PAGES_BRANCH: gh-pages GH_PAGES_BRANCH: gh-pages
CI_GIT_USER: CircleCI CI_GIT_USER: CircleCI
@@ -162,7 +197,7 @@ jobs:
steps: steps:
- checkout - checkout
- run: sudo pip install codespell - run: sudo pip install codespell
- run: codespell -S './.git*,./src/img*' -L que - run: codespell -S './.git*,./src/img*,./go.sum' -L que
workflows: workflows:
version: 2 version: 2

View File

@@ -29,7 +29,7 @@ RELEASE_BRANCH=release-$RELEASE_VER
# Build plugin # Build plugin
git checkout -b $RELEASE_BRANCH git checkout -b $RELEASE_BRANCH
yarn install --pure-lockfile && yarn build make clean install dist
# Commit release # Commit release
git add --force dist/ git add --force dist/

View File

@@ -1,7 +1,44 @@
all: frontend backend all: install build test lint
frontend: # Install dependencies
install:
# Frontend
yarn install --pure-lockfile
# Backend
go mod vendor
GO111MODULE=off go get -u golang.org/x/lint/golint
build: build-frontend build-backend
build-frontend:
yarn dev-build yarn dev-build
build-backend:
env GOOS=linux go build -mod=vendor -o ./dist/zabbix-plugin_linux_amd64 ./pkg
backend: dist: dist-frontend dist-backend
go build -o ./dist/zabbix-plugin_linux_amd64 ./pkg dist-frontend:
yarn 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:
yarn test
test-backend:
go test -v -mod=vendor ./pkg/...
test-ci:
yarn 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:
yarn lint
golint -set_exit_status pkg/...

2
go.mod
View File

@@ -10,5 +10,5 @@ require (
github.com/hashicorp/go-plugin v1.0.1 github.com/hashicorp/go-plugin v1.0.1
github.com/kr/pretty v0.1.0 // indirect github.com/kr/pretty v0.1.0 // indirect
github.com/patrickmn/go-cache v2.1.0+incompatible 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
View File

@@ -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.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 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 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/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 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 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.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= 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 h1:g9qWBGx4puODJTMVyoPrpoxPFgVGd+z1DZwjfRu4d0I=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 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/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 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-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 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 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= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 h1:Nw54tB0rB7hY/N0NQvRW8DG4Yk3Q6T9cu9RcFQDu1tc=

View File

@@ -22,7 +22,7 @@ module.exports = {
"^.+\\.js$": "babel-jest", "^.+\\.js$": "babel-jest",
"^.+\\.(ts|tsx)$": "ts-jest" "^.+\\.(ts|tsx)$": "ts-jest"
}, },
"coverageDirectory": "<rootDir>/tmp/coverage/", "coverageDirectory": "<rootDir>/tmp/coverage/node/",
"collectCoverage": false, "collectCoverage": false,
"globals": { "globals": {
"ts-jest": { "ts-jest": {

View File

@@ -11,7 +11,7 @@
"test": "jest", "test": "jest",
"jest": "jest --notify --watch", "jest": "jest --notify --watch",
"codecov": "jest --coverage && codecov", "codecov": "jest --coverage && codecov",
"ci-test": "jest --coverage && codecov", "ci-test": "jest --coverage",
"lint": "jshint --reporter=node_modules/jshint-stylish src/ & jscs src/", "lint": "jshint --reporter=node_modules/jshint-stylish src/ & jscs src/",
"benchmark": "webpack --config webpack/webpack.bench.conf.js && grunt bench" "benchmark": "webpack --config webpack/webpack.bench.conf.js && grunt bench"
}, },

3
pkg/cache_test.go Normal file
View File

@@ -0,0 +1,3 @@
package main
// Dummy test file for now

View File

@@ -26,7 +26,7 @@ function convertHistory(history, items, addHostName, convertPointCallback) {
var grouped_history = _.groupBy(history, 'itemid'); var grouped_history = _.groupBy(history, 'itemid');
var hosts = _.uniqBy(_.flatten(_.map(items, 'hosts')), 'hostid'); //uniqBy is needed to deduplicate 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 item = _.find(items, {'itemid': itemid});
var alias = item.name; var alias = item.name;
if (_.keys(hosts).length > 1 && addHostName) { //only when actual multi hosts selected if (_.keys(hosts).length > 1 && addHostName) { //only when actual multi hosts selected
@@ -35,7 +35,7 @@ function convertHistory(history, items, addHostName, convertPointCallback) {
} }
return { return {
target: alias, target: alias,
datapoints: _.map(hist, convertPointCallback) datapoints: _.map(historyPoint, convertPointCallback)
}; };
}); });
} }

View File

@@ -26,8 +26,8 @@
{"name": "Metric Editor", "path": "img/screenshot-metric_editor.png"}, {"name": "Metric Editor", "path": "img/screenshot-metric_editor.png"},
{"name": "Triggers", "path": "img/screenshot-triggers.png"} {"name": "Triggers", "path": "img/screenshot-triggers.png"}
], ],
"version": "3.10.4", "version": "4.0.0-alpha",
"updated": "2019-08-08" "updated": "2019-10-08"
}, },
"includes": [ "includes": [
@@ -42,7 +42,7 @@
], ],
"dependencies": { "dependencies": {
"grafanaVersion": "6.x", "grafanaVersion": "6.4",
"plugins": [] "plugins": []
} }
} }

3215
yarn.lock

File diff suppressed because it is too large Load Diff