Skip to content

Commit 5f28b06

Browse files
authored
add lint (#191)
Signed-off-by: wfan <[email protected]>
1 parent 2fda1cb commit 5f28b06

File tree

7 files changed

+88
-3
lines changed

7 files changed

+88
-3
lines changed

.github/workflows/github-releases.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ jobs:
110110
id: setup_go
111111
# You may pin to the exact commit or the version.
112112
# uses: https://github.com/actions/setup-go/tags
113-
uses: actions/setup-go@v4
113+
uses: actions/setup-go@v5
114114
with:
115115
# go-version: stable
116116
go-version-file: './go.mod'

.github/workflows/go-test.yaml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ name: Build and Publish Docker Image
77

88
on:
99
workflow_call:
10+
secrets:
11+
CODECOV_TOKEN:
12+
required: true
1013

1114
jobs:
1215

@@ -49,7 +52,7 @@ jobs:
4952
id: setup_go
5053
# You may pin to the exact commit or the version.
5154
# uses: https://github.com/actions/setup-go/tags
52-
uses: actions/setup-go@v4
55+
uses: actions/setup-go@v5
5356
with:
5457
# go-version: stable
5558
go-version-file: './go.mod'
@@ -64,6 +67,30 @@ jobs:
6467
go version
6568
make test
6669
70+
# This action uploads coverage to Codecov.
71+
# https://github.com/codecov/codecov-action
72+
-
73+
name: Upload coverage reports to Codecov
74+
id: go-coverage
75+
uses: codecov/codecov-action@v5
76+
with:
77+
token: ${{ secrets.CODECOV_TOKEN }} # Repository upload token: https://app.codecov.io/gh/AthenZ/k8s-athenz-sia/config/general
78+
files: ./coverage.out
79+
flags: unittests
80+
fail_ci_if_error: true # set to false temporarily if the CI failed
81+
verbose: true
82+
version: "latest"
83+
84+
# This action runs golangci-lint and reports issues from linters.
85+
# https://github.com/golangci/golangci-lint-action
86+
- name: golangci-lint
87+
uses: golangci/golangci-lint-action@v7
88+
with:
89+
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
90+
version: "latest"
91+
# Optional: golangci-lint command line arguments.
92+
args: --issues-exit-code=0 -c ./.golangci.yml # or set "continue-on-error: true" in Github Actions
93+
6794
# https://github.com/apache/skywalking-eyes
6895
# issue: go version hard-coded: https://github.com/apache/skywalking-eyes/blob/5dfa68f93380a5e57259faaf95088b7f133b5778/header/action.yml#L47-L51
6996
- name: Check License Header

.github/workflows/lint.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: lint
2+
3+
on:
4+
# If any commit message in your push or the HEAD commit of your PR contains the strings
5+
# [skip ci], [ci skip], [no ci], [skip actions], or [actions skip]
6+
# workflows triggered on the push or pull_request events will be skipped.
7+
# https://github.blog/changelog/2021-02-08-github-actions-skip-pull-request-and-push-workflows-with-skip-ci/
8+
push:
9+
branches: [ main ]
10+
# Publish semver tags as releases.
11+
tags:
12+
- 'v[0-9]+.[0-9]+.[0-9]+'
13+
pull_request:
14+
branches: [ main ]
15+
16+
jobs:
17+
18+
# This job runs markdownlint and reports issues from linters.
19+
# https://github.com/DavidAnson/markdownlint-cli2-action
20+
markdownlint:
21+
name: markdownlint
22+
runs-on: ubuntu-latest
23+
permissions:
24+
contents: read
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
- name: markdownlint
29+
uses: DavidAnson/markdownlint-cli2-action@v19
30+
continue-on-error: true
31+
with:
32+
globs: |
33+
README.md
34+
CHANGELOG.md
35+
docs/*.md

.github/workflows/trigger-workflows.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ jobs: # https://docs.github.com/en/actions/learn-github-actions/contexts#context
2727
go-test:
2828
name: "Run unit test"
2929
uses: ./.github/workflows/go-test.yaml
30+
secrets:
31+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
3032

3133
set-platforms:
3234
runs-on: ubuntu-latest

.golangci.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: "2"
2+
issues:
3+
max-same-issues: 0
4+
linters:
5+
# example to exclude glg lint error
6+
# settings:
7+
# errcheck:
8+
# exclude-functions:
9+
# - "glg.*"
10+
default: all

.remarkrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"plugins": [
3+
"remark-preset-lint-consistent",
4+
"remark-preset-lint-recommended",
5+
["remark-lint-list-item-indent", false],
6+
["remark-lint-list-item-bullet-indent", false],
7+
["remark-lint-list-item-content-indent", false]
8+
]
9+
}

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ build: submodule-update
7373
test:
7474
@echo "Testing..."
7575
go test -v -failfast -timeout 1m -race -covermode=atomic -coverprofile=coverage.out ./...
76-
go tool cover -html=coverage.out -o coverage.html
76+
77+
lint:
78+
golangci-lint run -c ./.golangci.yml
7779

7880
upgrade:
7981
go list -u -m all

0 commit comments

Comments
 (0)