-
Notifications
You must be signed in to change notification settings - Fork 0
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
dab359d
commit fc4bf1b
Showing
17 changed files
with
194 additions
and
147 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
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,81 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- staging | ||
tags: | ||
- 'v*' | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
branches: | ||
- main | ||
|
||
# 确保同一时间只运行一个工作流 | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: true | ||
|
||
permissions: | ||
contents: read | ||
pull-requests: read | ||
security-events: write | ||
|
||
jobs: | ||
verify: | ||
# 避免在 PR 和 push 时重复运行 | ||
if: | | ||
(github.event_name == 'push' && github.ref == 'refs/heads/staging') || | ||
(github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'main') || | ||
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')) | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.21' | ||
cache: true | ||
|
||
- name: Install dependencies | ||
run: go mod download | ||
|
||
- name: Run Tests | ||
run: | | ||
go test -race -coverprofile=coverage.txt -covermode=atomic ./... | ||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v3 | ||
if: success() | ||
with: | ||
file: ./coverage.txt | ||
flags: unittests | ||
fail_ci_if_error: false | ||
|
||
- name: Run golangci-lint | ||
uses: golangci/golangci-lint-action@v3 | ||
with: | ||
version: latest | ||
args: --timeout=5m | ||
skip-cache: true | ||
|
||
- name: Initialize CodeQL | ||
uses: github/codeql-action/init@v2 | ||
with: | ||
languages: go | ||
|
||
- name: Perform CodeQL Analysis | ||
uses: github/codeql-action/analyze@v2 | ||
|
||
- name: Run Tests for SonarCloud | ||
run: | | ||
go test -coverprofile=coverage.out -json > test-report.json ./... | ||
- name: SonarCloud Scan | ||
uses: SonarSource/sonarcloud-github-action@master | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,4 +1,7 @@ | ||
logs | ||
.VSCodeCounter/** | ||
.DS_Store | ||
.idea | ||
.idea | ||
coverage.txt | ||
coverage.out | ||
test-report.json |
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 |
---|---|---|
@@ -1,55 +1,57 @@ | ||
# 基本运行配置 | ||
run: | ||
timeout: 5m | ||
modules-download-mode: readonly | ||
skip-dirs-use-default: true | ||
go: '1.22' | ||
deadline: 5m | ||
tests: false | ||
skip-dirs: | ||
- vendor | ||
- third_party | ||
skip-files: | ||
- ".*\\.pb\\.go$" | ||
- ".*\\.gen\\.go$" | ||
- ".*\\.mock\\.go$" | ||
- ".*\\.tpl$" | ||
- ".*_gen\\.go$" | ||
- internal | ||
- go/pkg/mod | ||
- usr/local/go/src | ||
- opt/hostedtoolcache/go | ||
|
||
# 输出格式配置 | ||
output: | ||
format: colored-line-number | ||
print-issued-lines: true | ||
print-linter-name: true | ||
|
||
# 启用的 linters | ||
linters: | ||
disable-all: true | ||
enable: | ||
- gofmt | ||
- govet | ||
- errcheck | ||
- staticcheck | ||
- gosimple | ||
- govet | ||
- ineffassign | ||
- staticcheck | ||
- unused | ||
- gofmt | ||
- goimports | ||
- misspell | ||
- revive | ||
disable: | ||
- typecheck | ||
|
||
# linter 具体设置 | ||
linters-settings: | ||
gofmt: | ||
simplify: true | ||
goimports: | ||
local-prefixes: github.com/light-speak/lighthouse | ||
govet: | ||
check-shadowing: false | ||
enable-all: false | ||
disable: | ||
- fieldalignment | ||
- shadow | ||
revive: | ||
rules: | ||
- name: package-comments | ||
disabled: true | ||
staticcheck: | ||
go: "1.23" | ||
checks: ["all"] | ||
|
||
# 问题处理规则 | ||
issues: | ||
exclude-use-default: false | ||
max-issues-per-linter: 0 | ||
max-same-issues: 0 | ||
exclude-rules: | ||
- path: _test\.go | ||
linters: | ||
- errcheck | ||
- revive | ||
- gosec | ||
|
||
max-issues-per-linter: 0 | ||
max-same-issues: 0 |
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,6 @@ | ||
|
||
|
||
[![CI](https://github.com/username/repo/actions/workflows/main.yml/badge.svg)](https://github.com/username/repo/actions/workflows/main.yml) | ||
[![codecov](https://codecov.io/gh/username/repo/branch/main/graph/badge.svg)](https://codecov.io/gh/username/repo) | ||
[![Go Report Card](https://goreportcard.com/badge/github.com/username/repo)](https://goreportcard.com/report/github.com/username/repo) | ||
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=username_repo&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=username_repo) |
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
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.