Skip to content

Commit 7e02ad2

Browse files
committed
Feat: add golangci-lint ci
Signed-off-by: fengshunli <[email protected]>
1 parent d7db7c6 commit 7e02ad2

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed

.github/workflows/ci.yaml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- develop
8+
- release-*
9+
pull_request: {}
10+
workflow_dispatch: {}
11+
12+
env:
13+
GO_VERSION: 1.18
14+
15+
jobs:
16+
17+
verify:
18+
runs-on: ubuntu-22.04
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v3
22+
- name: Verify Code
23+
run: make verify
24+
25+
golangci-lint:
26+
runs-on: ubuntu-22.04
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v3
30+
with:
31+
submodules: true
32+
- name: Setup Go
33+
uses: actions/setup-go@v4
34+
with:
35+
go-version: ${{ env.GO_VERSION }}
36+
- name: Lint golang code
37+
uses: golangci/golangci-lint-action@v3
38+
with:
39+
version: v1.50.0
40+
args: --timeout 10m -v
41+
skip-cache: true

Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,6 @@ test:
6363

6464
upload:
6565
@NOSCMD=$(NOSCMD) bash build/package/upload.sh $(VERSION)
66+
67+
verify:
68+
scripts/verify_mod.sh

scripts/verify_mod.sh

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2022 The OpenYurt Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -e
18+
set -u
19+
20+
YURT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)"
21+
22+
go mod tidy
23+
24+
if [ ! -z "$(git diff ${YURT_ROOT}/go.mod ${YURT_ROOT}/go.sum)" ]; then
25+
echo "Verify go mod error, please ensure go.mod has been tidied"
26+
exit -1
27+
fi

0 commit comments

Comments
 (0)