Skip to content

Commit 74fc93f

Browse files
author
Ryan Tidwell
committed
Initial github actions and misc. housekeeping items
This change introduces initial github actions. Also included are basic liniting, licensing, code of conduct, and other boilerplate items for the repository. See #1 Signed-off-by: Ryan Tidwell <[email protected]>
1 parent af22258 commit 74fc93f

11 files changed

+411
-1
lines changed

.github/workflows/ci.yaml

+112
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
---
2+
name: ci
3+
on: pull_request
4+
jobs:
5+
yamllint:
6+
name: yamllint
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Check out code into the Go module directory
10+
uses: actions/checkout@v1
11+
- name: Setup Python
12+
uses: actions/setup-python@v1
13+
- name: Install yamllint
14+
run: pip install --user yamllint
15+
- name: Run yamllint
16+
run: ~/.local/bin/yamllint -c .yamllint.yml --strict .
17+
shellcheck:
18+
name: shellcheck
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v1
22+
- name: shellcheck
23+
uses: reviewdog/action-shellcheck@v1
24+
with:
25+
github_token: ${{ secrets.github_token }}
26+
reporter: github-check
27+
build:
28+
name: build
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v1
32+
- uses: actions/setup-go@v1
33+
with:
34+
go-version: 1.13
35+
- run: |
36+
go build -race ./...
37+
test:
38+
name: test
39+
runs-on: ubuntu-latest
40+
steps:
41+
- uses: actions/checkout@v1
42+
- uses: actions/setup-go@v1
43+
with:
44+
go-version: 1.13
45+
- name: Install gotestsum
46+
run: go get gotest.tools/[email protected]
47+
- name: Run tests
48+
run: |
49+
eval $(go env)
50+
mkdir -p ~/junit/
51+
${GOPATH}/bin/gotestsum --junitfile ~/junit/unit-tests.xml -- -race -short $(go list ./...)
52+
golangci-lint:
53+
name: golangci-lint
54+
runs-on: ubuntu-latest
55+
steps:
56+
- name: Check out code into the Go module directory
57+
uses: actions/checkout@v1
58+
- name: golangci-lint
59+
uses: reviewdog/action-golangci-lint@v1
60+
with:
61+
github_token: ${{ secrets.github_token }}
62+
reporter: github-check
63+
64+
excludeFmtErrorf:
65+
name: exclude fmt.Errorf
66+
runs-on: ubuntu-latest
67+
steps:
68+
- name: Exclude fmt.Errorf
69+
run: |
70+
if grep -r --include=*.go fmt.Errorf . ; then
71+
echo "Please use errors.Errorf (or errors.New or errors.Wrap or errors.Wrapf) as appropriate rather than fmt.Errorf"
72+
exit 1
73+
fi
74+
restrictNSMDeps:
75+
name: Restrict dependencies on github.com/networkservicemesh/*
76+
runs-on: ubuntu-latest
77+
steps:
78+
- name: Restrict dependencies on github.com/networkservicemesh/*
79+
run: |
80+
for i in $(grep github.com/networkservicemesh/ go.mod | gsed 's;.*\(github.com\/networkservicemesh\/[a-zA-z\/]*\).*;\1;g' | sort -u);do
81+
if [ "${i}" != "github.com/networkservicemesh/sdk" ] && [ "${i}" != "github.com/networkservicemesh/networkservicemesh/controlplane/api" ]; then
82+
echo Dependency on "${i}" is forbidden
83+
exit 1
84+
fi
85+
done
86+
checkgomod:
87+
name: check go.mod and go.sum
88+
runs-on: ubuntu-latest
89+
steps:
90+
- uses: actions/checkout@v1
91+
- uses: actions/setup-go@v1
92+
with:
93+
go-version: 1.13
94+
- run: go mod tidy
95+
- name: Check for changes in go.mod or go.sum
96+
run: |
97+
git diff --name-only --exit-code go.mod || ( echo "Run go tidy" && false )
98+
git diff --name-only --exit-code go.sum || ( echo "Run go tidy" && false )
99+
license:
100+
name: license header check
101+
runs-on: ubuntu-latest
102+
steps:
103+
- uses: actions/checkout@v1
104+
- uses: actions/setup-go@v1
105+
with:
106+
go-version: 1.13
107+
- name: Install go-header
108+
run: 'go get github.com/denis-tingajkin/[email protected]'
109+
- name: Run go-header
110+
run: |
111+
eval $(go env)
112+
${GOPATH}/bin/go-header

.github/workflows/pr-for-updates.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
---
3+
name: Pull Request on update/* Branch Push
4+
on:
5+
push:
6+
branches:
7+
- update/*
8+
jobs:
9+
auto-pull-request:
10+
name: Pull Request on update/* Branch Push
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: pull-request-action
14+
uses: vsoch/pull-request-action@master
15+
env:
16+
GITHUB_TOKEN: ${{ secrets.NSM_BOT_GITHUB_TOKEN }}
17+
BRANCH_PREFIX: "update/"
18+
PULL_REQUEST_BRANCH: "master"

.go-header.yaml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
year: 2020
3+
goroutine-count: 6
4+
scope:
5+
policy: "diff"
6+
master-branch: "origin/master"
7+
rules:
8+
- template-path: ".license/template.txt"
9+
paths:
10+
- ".*[.]go$"
11+
exclude-paths:
12+
- ".*[.]pb"
13+
custom-patterns:
14+
- name: NSM COPYRIGHT HOLDERS
15+
pattern: "Copyright (c) {YEAR} {COPYRIGHT HOLDER}"
16+
separator: "\n//\n// "

.golangci.yaml

+158
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
---
2+
run:
3+
# concurrency: 6
4+
timeout: 1m
5+
issues-exit-code: 1
6+
tests: true
7+
linters-settings:
8+
errcheck:
9+
check-type-assertions: false
10+
check-blank: false
11+
govet:
12+
check-shadowing: true
13+
settings:
14+
printf:
15+
funcs:
16+
- (github.com/sirupsen/logrus.FieldLogger).Infof
17+
- (github.com/sirupsen/logrus.FieldLogger).Warnf
18+
- (github.com/sirupsen/logrus.FieldLogger).Errorf
19+
- (github.com/sirupsen/logrus.FieldLogger).Fatalf
20+
golint:
21+
min-confidence: 0.8
22+
goimports:
23+
local-prefixes: github.com/networkservicemesh/sdk-kernel/
24+
gocyclo:
25+
min-complexity: 15
26+
maligned:
27+
suggest-new: true
28+
dupl:
29+
threshold: 150
30+
goconst:
31+
min-len: 2
32+
min-occurrences: 2
33+
depguard:
34+
list-type: blacklist
35+
include-go-root: false
36+
packages:
37+
- errors
38+
packages-with-error-message:
39+
# specify an error message to output when a blacklisted package is used
40+
- errors: "Please use \"github.com/pkg/errors\" instead of \"errors\" in go imports"
41+
misspell:
42+
locale: US
43+
unparam:
44+
check-exported: false
45+
nakedret:
46+
max-func-lines: 30
47+
prealloc:
48+
simple: true
49+
range-loops: true
50+
for-loops: false
51+
gocritic:
52+
enabled-checks:
53+
- appendAssign
54+
- assignOp
55+
- appendCombine
56+
- argOrder
57+
- badCall
58+
- badCond
59+
- boolExprSimplify
60+
- builtinShadow
61+
- captLocal
62+
- caseOrder
63+
- codegenComment
64+
- commentFormatting
65+
- commentedOutCode
66+
- commentedOutImport
67+
- defaultCaseOrder
68+
- deprecatedComment
69+
- docStub
70+
- dupArg
71+
- dupBranchBody
72+
- dupCase
73+
- dupImport
74+
- dupSubExpr
75+
- elseif
76+
- emptyFallthrough
77+
- emptyStringTest
78+
- equalFold
79+
- evalOrder
80+
- exitAfterDefer
81+
- flagDeref
82+
- flagName
83+
- hexLiteral
84+
- hugeParam
85+
- ifElseChain
86+
- importShadow
87+
- indexAlloc
88+
- initClause
89+
- methodExprCall
90+
- nestingReduce
91+
- newDeref
92+
- nilValReturn
93+
- octalLiteral
94+
- offBy1
95+
- paramTypeCombine
96+
- ptrToRefParam
97+
- rangeExprCopy
98+
- rangeValCopy
99+
- regexpMust
100+
- regexpPattern
101+
- singleCaseSwitch
102+
- sloppyLen
103+
- sloppyReassign
104+
- stringXbytes
105+
- switchTrue
106+
- typeAssertChain
107+
- typeSwitchVar
108+
- typeUnparen
109+
- unlabelStmt
110+
- unnamedResult
111+
- unnecessaryBlock
112+
- underef
113+
- unlambda
114+
- unslice
115+
- valSwap
116+
- weakCond
117+
- wrapperFunc
118+
- yodaStyleExpr
119+
linters:
120+
disable-all: true
121+
enable:
122+
# - rowserrcheck
123+
- bodyclose
124+
- deadcode
125+
- depguard
126+
- dogsled
127+
- dupl
128+
- errcheck
129+
- funlen
130+
- gochecknoinits
131+
- goconst
132+
- gocritic
133+
- gocyclo
134+
- gofmt
135+
- goimports
136+
- golint
137+
- gosec
138+
- gosimple
139+
- govet
140+
- ineffassign
141+
- interfacer
142+
# - lll
143+
- misspell
144+
- nakedret
145+
- scopelint
146+
- staticcheck
147+
- structcheck
148+
- stylecheck
149+
- typecheck
150+
- unconvert
151+
- unparam
152+
# - unused
153+
- varcheck
154+
- whitespace
155+
issues:
156+
exclude-use-default: false
157+
max-issues-per-linter: 0
158+
max-same-issues: 0

.license/README.md

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
## Copyright headers for source code
2+
This folder contains the copyright templates for source files of NSM project.
3+
4+
Below is an example of valid copyright header for `.go` files:
5+
```
6+
// Copyright (c) 2020 Doc.ai and/or its affiliates.
7+
//
8+
// Copyright (c) 2020 Cisco and/or its affiliates.
9+
//
10+
// SPDX-License-Identifier: Apache-2.0
11+
//
12+
// Licensed under the Apache License, Version 2.0 (the "License");
13+
// you may not use this file except in compliance with the License.
14+
// You may obtain a copy of the License at:
15+
//
16+
// http://www.apache.org/licenses/LICENSE-2.0
17+
//
18+
// Unless required by applicable law or agreed to in writing, software
19+
// distributed under the License is distributed on an "AS IS" BASIS,
20+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21+
// See the License for the specific language governing permissions and
22+
// limitations under the License.
23+
```
24+
Note you can use your company name instead of `Cisco and/or its affiliates`.
25+
Also, source code files can have multi copyright holders, for example:
26+
```
27+
// Copyright (c) 2020 Doc.ai and/or its affiliates.
28+
//
29+
// Copyright (c) 2020 Cisco and/or its affiliates.
30+
//
31+
// Copyright (c) 2020 Red Hat Inc. and/or its affiliates.
32+
//
33+
// Copyright (c) 2020 VMware, Inc.
34+
//
35+
// SPDX-License-Identifier: Apache-2.0
36+
//
37+
// Licensed under the Apache License, Version 2.0 (the "License");
38+
// you may not use this file except in compliance with the License.
39+
// You may obtain a copy of the License at:
40+
//
41+
// http://www.apache.org/licenses/LICENSE-2.0
42+
//
43+
// Unless required by applicable law or agreed to in writing, software
44+
// distributed under the License is distributed on an "AS IS" BASIS,
45+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
46+
// See the License for the specific language governing permissions and
47+
// limitations under the License.
48+
```

.license/boilerplate.txt

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright (c) 2020 Doc.ai and/or its affiliates.
2+
//
3+
// Copyright (c) 2020 Cisco and/or its affiliates.
4+
//
5+
// Copyright (c) 2020 VMware, Inc.
6+
//
7+
// SPDX-License-Identifier: Apache-2.0
8+
//
9+
// Licensed under the Apache License, Version 2.0 (the "License");
10+
// you may not use this file except in compliance with the License.
11+
// You may obtain a copy of the License at:
12+
//
13+
// http://www.apache.org/licenses/LICENSE-2.0
14+
//
15+
// Unless required by applicable law or agreed to in writing, software
16+
// distributed under the License is distributed on an "AS IS" BASIS,
17+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
// See the License for the specific language governing permissions and
19+
// limitations under the License.

.license/template.txt

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// {NSM COPYRIGHT HOLDERS}
2+
//
3+
// SPDX-License-Identifier: Apache-2.0
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.

0 commit comments

Comments
 (0)