Skip to content

Commit

Permalink
build: add some ci
Browse files Browse the repository at this point in the history
Signed-off-by: ZhangJian He <[email protected]>
  • Loading branch information
hezhangjian committed Dec 3, 2024
1 parent 6490c53 commit 5e194d7
Show file tree
Hide file tree
Showing 10 changed files with 139 additions and 7 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/commit_lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: commit lint
on:
pull_request:
branches:
- main

jobs:
commitlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: wagoid/commitlint-github-action@v5
22 changes: 22 additions & 0 deletions .github/workflows/go_ci_lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: go ci Lint
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: latest
args: --timeout 3m0s
23 changes: 23 additions & 0 deletions .github/workflows/go_imports.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: go imports
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 'stable'
- name: install goimports
run: go install golang.org/x/tools/cmd/goimports@latest
- name: run goimports
run: goimports -w .
- name: check for unformatted code
run: git diff --exit-code
22 changes: 22 additions & 0 deletions .github/workflows/go_mod_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: go mod check

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
go_mod_check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
- name: Run Go Mod Check Action
uses: shoothzj/go-mod-check-action@main
with:
prohibitIndirectDepUpdate: 'true'
26 changes: 26 additions & 0 deletions .github/workflows/go_unit_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: go unit test

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
go_unit_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
- name: setup ZooKeeper
uses: shoothzj/setup-zookeeper-action@main
- name: Run coverage
run: go test ./... -coverpkg=./... -race -coverprofile=coverage.txt -covermode=atomic
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
13 changes: 13 additions & 0 deletions .github/workflows/line_lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: line lint
on:
pull_request:
branches:
- main
jobs:
line_lint:
name: line lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: linelint
uses: shoothzj/linelint@main
16 changes: 13 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
# file system
.DS_Store

# ide
.idea/**
.vscode/**
!.idea/icon.svg
!.idea/vcs.xml

target/*

# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
*.idea

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
vendor/
# Go workspace file
go.work
6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions samples/gateway/gateway_demo.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ func updateSubDeviceStats() {
gatewayDevice.Client.SubDeviceStatusRespHandler = func(response model.SubDeviceStatusResp) {
if len(response.SuccessfulDevices) > 0 {
glog.Infof("success update device status.")
for _, sucessDevice := range response.SuccessfulDevices {
glog.Infof("update device : %s status: %s", sucessDevice.DeviceId, sucessDevice.Status)
for _, successDevice := range response.SuccessfulDevices {
glog.Infof("update device : %s status: %s", successDevice.DeviceId, successDevice.Status)
}
}
if len(response.FailedDevices) > 0 {
Expand Down
2 changes: 0 additions & 2 deletions sdk_info

This file was deleted.

0 comments on commit 5e194d7

Please sign in to comment.