-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
89128a4
commit a8b41dd
Showing
41 changed files
with
464 additions
and
262 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,53 +11,49 @@ on: | |
- "**/*.md" | ||
|
||
jobs: | ||
scan: | ||
runs-on: ubuntu-latest | ||
steps: | ||
# 代码签出 | ||
- uses: actions/checkout@v3 | ||
|
||
# 设定 Go 环境 | ||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version: "^1.20.0" | ||
cache: true | ||
# scan: | ||
# runs-on: ubuntu-latest | ||
# steps: | ||
# # 代码签出 | ||
# - uses: actions/checkout@v3 | ||
|
||
# Get values for cache paths to be used in later steps | ||
- name: Setup Go Cache PATH | ||
id: go-cache-paths | ||
run: | | ||
echo "go-build=$(go env GOCACHE)" >> $GITHUB_OUTPUT | ||
echo "go-mod=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT | ||
# # 设定 Go 环境 | ||
# - uses: actions/setup-go@v3 | ||
# with: | ||
# go-version: "^1.20.0" | ||
# cache: true | ||
|
||
# Cache go build cache, used to speedup go test | ||
- name: Go Build Cache | ||
uses: actions/cache@v2 | ||
with: | ||
path: ${{ steps.go-cache-paths.outputs.go-build }} | ||
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }} | ||
# # Get values for cache paths to be used in later steps | ||
# - name: Setup Go Cache PATH | ||
# id: go-cache-paths | ||
# run: | | ||
# echo "go-build=$(go env GOCACHE)" >> $GITHUB_OUTPUT | ||
# echo "go-mod=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT | ||
|
||
# Cache go mod cache, used to speedup builds | ||
- name: Go Mod Cache | ||
uses: actions/cache@v2 | ||
with: | ||
path: ${{ steps.go-cache-paths.outputs.go-mod }} | ||
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} | ||
# # Cache go build cache, used to speedup go test | ||
# - name: Go Build Cache | ||
# uses: actions/cache@v2 | ||
# with: | ||
# path: ${{ steps.go-cache-paths.outputs.go-build }} | ||
# key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }} | ||
|
||
- name: Setup govulncheck | ||
run: go install golang.org/x/vuln/cmd/govulncheck@latest | ||
# # Cache go mod cache, used to speedup builds | ||
# - name: Go Mod Cache | ||
# uses: actions/cache@v2 | ||
# with: | ||
# path: ${{ steps.go-cache-paths.outputs.go-mod }} | ||
# key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} | ||
|
||
# 代码检查潜在错误 | ||
- name: Vet (Scan for potential mistakes) | ||
run: | | ||
go vet ./internal/... | ||
go vet ./pkg/... | ||
go vet ./cmd/... | ||
# - name: Setup govulncheck | ||
# run: go install golang.org/x/vuln/cmd/govulncheck@latest | ||
|
||
govulncheck ./internal/... | ||
govulncheck ./pkg/... | ||
govulncheck ./cmd/... | ||
# # 代码检查潜在错误 | ||
# - name: Vet (Scan for potential mistakes) | ||
# run: | | ||
# go vet ./... | ||
# govulncheck ./... | ||
buildtest: | ||
name: Build Test | ||
runs-on: ubuntu-latest | ||
steps: | ||
# 代码签出 | ||
|
@@ -93,7 +89,9 @@ jobs: | |
# 测试构建 | ||
- name: Test Build | ||
run: go build -a -o "release/insights-bot" "github.com/nekomeowww/insights-bot/cmd/insights-bot" | ||
|
||
ent_check: | ||
name: Check entgo.io codegen | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
@@ -102,6 +100,19 @@ jobs: | |
go-version: "^1.20" | ||
- uses: ent/contrib/ci@master | ||
|
||
lint: | ||
name: Lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version: "^1.20.0" | ||
cache: true | ||
|
||
- uses: actions/checkout@v3 | ||
- name: golangci-lint | ||
uses: golangci/[email protected] | ||
|
||
# unittest: | ||
# # 运行目标 | ||
# runs-on: ubuntu-latest | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
linters: | ||
enable: | ||
# - contextcheck # due to https://github.com/golangci/golangci-lint/issues/3086#issuecomment-1475232706 | ||
- errcheck | ||
- gosimple | ||
# - govet # due to https://github.com/golangci/golangci-lint/issues/3086#issuecomment-1475232706 | ||
- ineffassign | ||
- staticcheck | ||
- typecheck | ||
- unused | ||
|
||
# - bodyclose # due to https://github.com/golangci/golangci-lint/issues/3086#issuecomment-1475232706 | ||
- containedctx | ||
- depguard | ||
- dupl | ||
- durationcheck | ||
- errname | ||
- exhaustive | ||
- exportloopref | ||
- forcetypeassert | ||
- godot | ||
- gofmt | ||
- goheader | ||
- goprintffuncname | ||
- gosec | ||
- musttag | ||
- nestif | ||
# - nilerr # due to https://github.com/golangci/golangci-lint/issues/3086#issuecomment-1475232706 | ||
# - noctx # due to https://github.com/golangci/golangci-lint/issues/3086#issuecomment-1475232706 | ||
- nolintlint | ||
- nosprintfhostport | ||
- prealloc | ||
- predeclared | ||
- reassign | ||
- revive | ||
- tenv | ||
- testableexamples | ||
- unconvert | ||
# - unparam # due to https://github.com/golangci/golangci-lint/issues/3086#issuecomment-1475232706 | ||
- usestdlibvars | ||
- whitespace | ||
- wsl | ||
|
||
linters-settings: | ||
wsl: | ||
allow-assign-and-call: false | ||
revive: | ||
rules: | ||
- name: blank-imports | ||
disabled: true | ||
|
||
issues: | ||
exclude: | ||
- "if statements should only be cuddled with assignments" # from wsl | ||
- "if statements should only be cuddled with assignments used in the if statement itself" # from wsl | ||
- "assignments should only be cuddled with other assignments" # from wsl. false positive case: var a bool\nb := true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.