Skip to content

Commit

Permalink
ci: add github action and resolve static warning (#5)
Browse files Browse the repository at this point in the history
* ci: add go check github action (#3)

Signed-off-by: xmh1011 <[email protected]>

* test: test ci

test: test ci

Signed-off-by: xmh1011 <[email protected]>

* chore: resolve static warning

Signed-off-by: xmh1011 <[email protected]>

* chore: resolve static warning

Signed-off-by: xmh1011 <[email protected]>

* chore: resolve static warning

Signed-off-by: xmh1011 <[email protected]>

* chore: resolve static warning

Signed-off-by: xmh1011 <[email protected]>

* chore: resolve static warning

Signed-off-by: xmh1011 <[email protected]>

* chore: resolve static warning

Signed-off-by: xmh1011 <[email protected]>

* chore: resolve static warning

Signed-off-by: xmh1011 <[email protected]>

---------

Signed-off-by: xmh1011 <[email protected]>
  • Loading branch information
xmh1011 authored Jan 31, 2024
1 parent 7a563df commit 300ac7e
Show file tree
Hide file tree
Showing 24 changed files with 1,664 additions and 1,539 deletions.
75 changes: 75 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Continuous Integration

on:
workflow_dispatch:
pull_request:
types: [ opened, synchronize, reopened, ready_for_review ]
paths-ignore:
- 'conf/**'
- 'docker/**'
- 'doc/**'
- 'k8s/**'
- 'scripts/**'
- '**.md'
- '.gitignore'

env:
GO111MODULE: on
GONOSUMDB: "*"
GOSUMDB: off

jobs:
CommitLint:
name: Commit Lint
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 100
- name: Run commitlint
uses: wagoid/commitlint-github-action@v5
GoLint:
name: "Code Analysis"
needs: CommitLint
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- uses: WillAbides/[email protected]
with:
go-version: "1.20"
- name: Run go version check
run: make go-version-check
- name: Run go vet check
run: make go-vet-check
- name: Run golang-ci-lint
uses: golangci/[email protected]
with:
version: v1.53
args: --timeout=10m --tests=false
only-new-issues: true
skip-pkg-cache: true
skip-build-cache: true
BuildCheck:
name: "Go Build Check"
needs: GoLint
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- uses: WillAbides/[email protected]
with:
go-version: "1.20"
- name: go mod tidy
run: make vendor
- name: go build linux
run: make build-linux && make build-linux-arm
- name: go build windows
run: make build-windows
- name: go build mac
run: make build-mac && make build-mac-arm
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ TAG=$(shell echo "${_GIT_VERSION}" | awk -F"-" '{print $$1}')
GIT_VERSION:="$(TAG)-$(GIT_COMMIT)"
BUILD_VERSION:='flashcat.cloud/categraf/config.Version=$(GIT_VERSION)'
LDFLAGS:="-w -s -X $(BUILD_VERSION)"
STYLE_CHECK_GOFILE := $$(find . -name '*.go')
GO := GO111MODULE=on go

all: build

Expand Down Expand Up @@ -52,3 +54,9 @@ pack:build-linux build-windows
rm -rf $(APP)-$(TAG).zip
tar -zcvf $(APP)-$(TAG)-linux-amd64.tar.gz conf $(APP)
zip -r $(APP)-$(TAG)-windows-amd64.zip conf $(APP).exe

go-version-check:
bash ./scripts/ci/go_version_check.sh

go-vet-check:
bash ./scripts/ci/go_vet.sh
2 changes: 1 addition & 1 deletion inputs/appdynamics/instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ type (
Sum float64 `json:"sum"`
Value float64 `json:"value"`

standardDiv float64 `json:"standardDeviation"`
StandardDiv float64 `json:"standardDeviation"`
}
)

Expand Down
2 changes: 1 addition & 1 deletion inputs/mtail/internal/exporter/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func TestMetricToGraphite(t *testing.T) {
testutil.ExpectNoDiff(t, expected, r)

histogramMetric := metrics.NewMetric("hist", "prog", metrics.Histogram, metrics.Buckets, "xxx")
lv := &metrics.LabelValue{Labels: []string{"bar"}, Value: datum.MakeBuckets([]datum.Range{{0, 10}, {10, 20}}, time.Unix(0, 0))}
lv := &metrics.LabelValue{Labels: []string{"bar"}, Value: datum.MakeBuckets([]datum.Range{{Min: 0, Max: 10}, {Min: 10, Max: 20}}, time.Unix(0, 0))}
histogramMetric.AppendLabelValue(lv)
d, _ = histogramMetric.GetDatum("bar")
datum.SetFloat(d, 1, ts)
Expand Down
2 changes: 1 addition & 1 deletion inputs/mtail/internal/exporter/prometheus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ foo{prog="test1"} 1
Program: "test",
Kind: metrics.Histogram,
Keys: []string{"a"},
LabelValues: []*metrics.LabelValue{{Labels: []string{"bar"}, Value: datum.MakeBuckets([]datum.Range{{0, 1}, {1, 2}}, time.Unix(0, 0))}},
LabelValues: []*metrics.LabelValue{{Labels: []string{"bar"}, Value: datum.MakeBuckets([]datum.Range{{Min: 0, Max: 1}, {Min: 1, Max: 2}}, time.Unix(0, 0))}},
Source: "location.mtail:37",
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func TestFileSocketStreamComparison(t *testing.T) {
defer wg.Done()
source, err := os.OpenFile(tc.logfile, os.O_RDONLY, 0)
testutil.FatalIfErr(t, err)
s, err := net.DialUnix(scheme, nil, &net.UnixAddr{sockName, scheme})
s, err := net.DialUnix(scheme, nil, &net.UnixAddr{Name: sockName, Net: scheme})
testutil.FatalIfErr(t, err)
n, err := io.Copy(s, source)
testutil.FatalIfErr(t, err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func TestReadFromSocket(t *testing.T) {
lineCountCheck := m.ExpectExpvarDeltaWithDeadline("lines_total", 3)
time.Sleep(10 * time.Millisecond)

s, err := net.DialUnix(scheme, nil, &net.UnixAddr{logFile, scheme})
s, err := net.DialUnix(scheme, nil, &net.UnixAddr{Name: logFile, Net: scheme})
testutil.FatalIfErr(t, err)
defer func() {
testutil.FatalIfErr(t, s.Close())
Expand Down
10 changes: 5 additions & 5 deletions inputs/mtail/internal/runtime/compiler/codegen/codegen.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (c *codegen) errorf(pos *position.Position, format string, args ...interfac

func (c *codegen) emit(n ast.Node, opcode code.Opcode, operand interface{}) {
// glog.V(2).Infof("emitting `%s %v' from line %d node %#v\n", opcode, operand, n.Pos().Line, n)
c.obj.Program = append(c.obj.Program, code.Instr{opcode, operand, n.Pos().Line})
c.obj.Program = append(c.obj.Program, code.Instr{Opcode: opcode, Operand: operand, SourceLine: n.Pos().Line})
}

// newLabel creates a new label to jump to.
Expand Down Expand Up @@ -136,19 +136,19 @@ func (c *codegen) VisitBefore(node ast.Node) (ast.Visitor, ast.Node) {
}

if n.Buckets[0] > 0 {
m.Buckets = append(m.Buckets, datum.Range{0, n.Buckets[0]})
m.Buckets = append(m.Buckets, datum.Range{Max: n.Buckets[0]})
}
m.Buckets = append(m.Buckets, datum.Range{n.Buckets[0], n.Buckets[1]})
m.Buckets = append(m.Buckets, datum.Range{Min: n.Buckets[0], Max: n.Buckets[1]})
min := n.Buckets[1]
for _, max := range n.Buckets[2:] {
if max <= min {
c.errorf(n.Pos(), "buckets boundaries must be sorted")
return nil, n
}
m.Buckets = append(m.Buckets, datum.Range{min, max})
m.Buckets = append(m.Buckets, datum.Range{Min: min, Max: max})
min = max
}
m.Buckets = append(m.Buckets, datum.Range{min, math.Inf(+1)})
m.Buckets = append(m.Buckets, datum.Range{Min: min, Max: math.Inf(+1)})

if len(n.Keys) == 0 {
// Calling GetDatum here causes the storage to be allocated.
Expand Down
Loading

0 comments on commit 300ac7e

Please sign in to comment.