Skip to content

Commit 806db0a

Browse files
authored
build: add pika_exporter to pika (OpenAtomFoundation#1388)
* add pika-exporter * add pika-exporter: fix README.md * add pika-exporter: fix README.md * add pika-exporter: remove annotation ,recover version.go * 更新远程仓库路径 * update Makefile * Create pika_exporter.yml * Delete the old version of the test file and it will no longer be compatible in the future * Remove vendor;update README.md
1 parent 058fcfd commit 806db0a

38 files changed

Lines changed: 6933 additions & 0 deletions
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Pika_exporter
2+
3+
on:
4+
push:
5+
branches: [ "unstable" ]
6+
pull_request:
7+
branches: [ "unstable" ]
8+
paths:
9+
- 'pika-tools/pika_exporter/**'
10+
11+
jobs:
12+
13+
build:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v3
17+
18+
- name: Set up Go
19+
uses: actions/setup-go@v3
20+
with:
21+
go-version: 1.19
22+
23+
- name: Build
24+
run: |
25+
cd pika-tools/pika_exporter && make -j
26+
- name: Test
27+
run: |
28+
cd pika-tools/pika_exporter && make -j

pika-tools/pika_exporter/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018 frank-ding
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

pika-tools/pika_exporter/Makefile

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# ifeq "$(GOPATH)" ""
2+
# $(error Please set the environment variable GOPATH before running `make`)
3+
# endif
4+
5+
# export PATH := $(PATH):$(GOPATH)/bin
6+
7+
# for mac
8+
BRANCH := $(shell git branch | sed 's/* \(.*\)/\1/p')
9+
# for Linux
10+
# BRANCH := $(shell git branch | sed --quiet 's/* \(.*\)/\1/p')
11+
GITREV := $(shell git rev-parse --short HEAD)
12+
BUILDTIME := $(shell date '+%F %T %Z')
13+
COMPILERVERSION := $(subst go version ,,$(shell go version))
14+
PROJNAME := pika_exporter
15+
16+
define GENERATE_VERSION_CODE
17+
cat << EOF | gofmt > version.go
18+
package main
19+
20+
const (
21+
BuildVersion = "$(BRANCH)"
22+
BuildCommitSha = "$(GITREV)"
23+
BuildDate = "$(BUILDTIME)"
24+
GoVersion = "$(COMPILERVERSION)"
25+
)
26+
EOF
27+
endef
28+
export GENERATE_VERSION_CODE
29+
30+
PACKAGES := $$(go list ./...| grep -vE 'vendor')
31+
FILES := $$(find . -name '*.go' | grep -vE 'vendor')
32+
33+
define TEST_COVER
34+
#!/bin/bash
35+
36+
set -e
37+
38+
which gocov >/dev/null || go get -v -u github.com/axw/gocov/gocov
39+
40+
COV_FILE=coverage.txt
41+
COV_TMP_FILE=coverage_tmp.txt
42+
43+
rm -f $$COV_FILE
44+
rm -f $$COV_TMP_FILE
45+
touch $$COV_TMP_FILE
46+
47+
echo "mode: count" > $$COV_FILE
48+
49+
for pkg in $(PACKAGES); do
50+
go test -v $$pkg -covermode=count -coverprofile=$$COV_TMP_FILE
51+
tail -n +2 $$COV_TMP_FILE >> $$COV_FILE || (echo "Unable to append coverage for $$pkg" && exit 1)
52+
done
53+
54+
gocov convert $$COV_FILE | gocov report | grep 'Total Coverage'
55+
56+
rm -f $$COV_FILE
57+
rm -f $$COV_TMP_FILE
58+
59+
endef
60+
export TEST_COVER
61+
62+
all: build
63+
64+
build: deps
65+
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/$(PROJNAME)
66+
67+
deps: generateVer
68+
@mkdir -p bin
69+
70+
generateVer:
71+
@echo "$$GENERATE_VERSION_CODE" | bash
72+
73+
test:
74+
@echo "$$TEST_COVER" | bash
75+
76+
race:
77+
go test -v -race $(PACKAGES)
78+
79+
check:
80+
which golint >/dev/null || go get -v -u github.com/golang/lint/golint
81+
@echo "vet"
82+
@go tool vet $(FILES) 2>&1 | awk '{print} END{if(NR>0) {exit 1}}'
83+
@echo "vet --shadow"
84+
@go tool vet --shadow $(FILES) 2>&1 | awk '{print} END{if(NR>0) {exit 1}}'
85+
@echo "golint"
86+
ifdef LINTEXCEPTION
87+
@golint $(PACKAGES) | grep -vE'$(LINTEXCEPTION)' | awk '{print} END{if(NR>0) {exit 1}}'
88+
else
89+
@golint $(PACKAGES) | awk '{print} END{if(NR>0) {exit 1}}'
90+
endif
91+
92+
errcheck:
93+
which errcheck >/dev/null || go get -v -u github.com/kisielk/errcheck
94+
errcheck -blank $(PACKAGES)
95+
96+
clean:
97+
@rm -rf bin
98+
@go clean -i ./...
99+
100+
dev: check test race build
101+
102+
update:
103+
which glide >/dev/null || curl https://glide.sh/get | sh
104+
which glide-vc || go get -v -u github.com/sgotti/glide-vc
105+
rm -r vendor
106+
ifdef PKG
107+
glide get -v --skip-test $(PKG)
108+
else
109+
glide update -v -u --skip-test
110+
endif
111+
@echo "removing test files"
112+
glide vc --only-code --no-tests --use-lock-file

pika-tools/pika_exporter/README.md

Lines changed: 152 additions & 0 deletions
Large diffs are not rendered by default.
130 KB
Loading

0 commit comments

Comments
 (0)