Skip to content

Commit 9d384da

Browse files
committed
Add initial CI an ifindex metadata tool
Signed-off-by: Ed Warnicke <[email protected]>
1 parent a41fcfc commit 9d384da

14 files changed

+1270
-0
lines changed

.ci/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+
```

.ci/license/template.txt

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

.ci/yamllint.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
extends: default
3+
4+
yaml-files:
5+
- '*.yaml'
6+
- '*.yml'
7+
8+
rules:
9+
truthy: disable
10+
# 80 chars should be enough, but don't fail if a line is longer
11+
line-length: disable
12+
comments-indentation:
13+
ignore: .circleci/config.yml

.github/workflows/ci.yaml

+136
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
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@v2
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 .ci/yamllint.yml --strict .
17+
build-and-test:
18+
name: build and test
19+
runs-on: ${{ matrix.os }}
20+
strategy:
21+
matrix:
22+
os: [ubuntu-latest, macos-latest, windows-latest]
23+
steps:
24+
- name: Check out code
25+
uses: actions/checkout@v2
26+
- name: Setup Go
27+
uses: actions/setup-go@v1
28+
with:
29+
go-version: 1.13.4
30+
- name: Build
31+
run: go build -race ./...
32+
- name: Test
33+
run: go test -race ./...
34+
golangci-lint:
35+
name: golangci-lint
36+
runs-on: ubuntu-latest
37+
env:
38+
GOLANGCI_LINT_CONTAINER: golangci/golangci-lint:v1.23.2
39+
steps:
40+
- name: Check out code into the Go module directory
41+
uses: actions/checkout@v2
42+
- name: Pull golangci-lint docker container
43+
run: docker pull ${GOLANGCI_LINT_CONTAINER}
44+
- name: Run golangci-lint
45+
run: docker run --rm -v $(pwd):/app -w /app ${GOLANGCI_LINT_CONTAINER} golangci-lint run
46+
47+
excludeFmtErrorf:
48+
name: exclude fmt.Errorf
49+
runs-on: ubuntu-latest
50+
steps:
51+
- uses: actions/checkout@v2
52+
- name: Exclude fmt.Errorf
53+
run: |
54+
if grep -r --include=*.go fmt.Errorf . ; then
55+
echo "Please use errors.Errorf (or errors.New or errors.Wrap or errors.Wrapf) as appropriate rather than fmt.Errorf"
56+
exit 1
57+
fi
58+
59+
restrictNSMDeps:
60+
name: Restrict dependencies on github.com/networkservicemesh/*
61+
runs-on: ubuntu-latest
62+
steps:
63+
- uses: actions/checkout@v2
64+
- name: Restrict dependencies on github.com/networkservicemesh/*
65+
run: |
66+
for i in $(grep github.com/networkservicemesh/ go.mod |grep -v '^module' | sed 's;.*\(github.com\/networkservicemesh\/[a-zA-z\/]*\).*;\1;g' | sort -u);do
67+
if [ "${i}" != "github.com/networkservicemesh/sdk" ] && [ "${i}" != "github.com/networkservicemesh/api" ]; then
68+
echo Dependency on "${i}" is forbidden
69+
exit 1
70+
fi
71+
done
72+
73+
checkgomod:
74+
name: check go.mod and go.sum
75+
runs-on: ubuntu-latest
76+
steps:
77+
- uses: actions/checkout@v2
78+
- uses: actions/setup-go@v1
79+
with:
80+
go-version: 1.13
81+
- run: go mod tidy
82+
- name: Check for changes in go.mod or go.sum
83+
run: |
84+
git diff --name-only --exit-code go.mod || ( echo "Run go tidy" && false )
85+
git diff --name-only --exit-code go.sum || ( echo "Run go tidy" && false )
86+
license:
87+
name: license header check
88+
runs-on: ubuntu-latest
89+
steps:
90+
- uses: actions/checkout@v2
91+
- uses: actions/setup-go@v1
92+
with:
93+
go-version: 1.13
94+
- name: Install go-header
95+
run: 'go get github.com/denis-tingajkin/[email protected]'
96+
- name: Run go-header
97+
run: |
98+
eval $(go env)
99+
${GOPATH}/bin/go-header
100+
excludereplace:
101+
name: Exclude replace in go.mod
102+
runs-on: ubuntu-latest
103+
steps:
104+
- name: Check out the code
105+
uses: actions/checkout@v2
106+
- name: Exclude replace in go.mod
107+
run: |
108+
grep -v 'replace github.com/satori/go.uuid' go.mod | grep ^replace || exit 0
109+
exit 1
110+
captureRunEnv:
111+
name: Capture CI Run Env
112+
runs-on: ubuntu-latest
113+
steps:
114+
- run: printenv
115+
automerge:
116+
name: automerge
117+
runs-on: ubuntu-latest
118+
needs:
119+
- build-and-test
120+
if: github.actor == 'nsmbot' && github.base_ref == 'master' && github.event_name == 'pull_request'
121+
steps:
122+
- name: Check out the code
123+
uses: actions/checkout@v2
124+
- name: Fetch master
125+
run: |
126+
git remote -v
127+
git fetch --depth=1 origin master
128+
- name: Only allow go.mod and go.sum changes
129+
run: |
130+
find . -type f ! -name 'go.mod' ! -name 'go.sum' -exec git diff --exit-code origin/master -- {} +
131+
- name: Automerge nsmbot PR
132+
uses: ridedott/merge-me-action@master
133+
with:
134+
GITHUB_LOGIN: nsmbot
135+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
136+

.github/workflows/codeql-analysis.yml

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
---
2+
# For most projects, this workflow file will not need changing; you simply need
3+
# to commit it to your repository.
4+
#
5+
# You may wish to alter this file to override the set of languages analyzed,
6+
# or to provide custom queries or build logic.
7+
name: "CodeQL"
8+
9+
on:
10+
push:
11+
branches: [master]
12+
pull_request:
13+
# The branches below must be a subset of the branches above
14+
branches: [master]
15+
schedule:
16+
- cron: '0 5 * * 0'
17+
18+
jobs:
19+
analyze:
20+
name: Analyze
21+
runs-on: ubuntu-latest
22+
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
# Override automatic language detection by changing the below list
27+
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
28+
language: ['go']
29+
# Learn more...
30+
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection
31+
32+
steps:
33+
- name: Checkout repository
34+
uses: actions/checkout@v2
35+
with:
36+
# We must fetch at least the immediate parents so that if this is
37+
# a pull request then we can checkout the head.
38+
fetch-depth: 2
39+
40+
# If this run was triggered by a pull request event, then checkout
41+
# the head of the pull request instead of the merge commit.
42+
- run: git checkout HEAD^2
43+
if: ${{ github.event_name == 'pull_request' }}
44+
45+
# Initializes the CodeQL tools for scanning.
46+
- name: Initialize CodeQL
47+
uses: github/codeql-action/init@v1
48+
with:
49+
languages: ${{ matrix.language }}
50+
# If you wish to specify custom queries, you can do so here or in a config file.
51+
# By default, queries listed here will override any specified in a config file.
52+
# Prefix the list here with "+" to use these queries and those in the config file.
53+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
54+
55+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
56+
# If this step fails, then you should remove it and run the build manually (see below)
57+
- name: Autobuild
58+
uses: github/codeql-action/autobuild@v1
59+
60+
# ℹ️ Command-line programs to run using the OS shell.
61+
# 📚 https://git.io/JvXDl
62+
63+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
64+
# and modify them (or add more) to build your code if your project
65+
# uses a compiled language
66+
67+
# - run: |
68+
# make bootstrap
69+
# make release
70+
71+
- name: Perform CodeQL Analysis
72+
uses: github/codeql-action/analyze@v1

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

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
name: Pull Request on update/* Branch Push
3+
on:
4+
push:
5+
branches:
6+
- update/**
7+
jobs:
8+
auto-pull-request:
9+
name: Pull Request on update/* Branch Push
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
- name: Construct PR message
14+
run: |
15+
PULL_REQUEST_BODY=$(git log -1)
16+
echo ${PULL_REQUEST_BODY}
17+
echo "::set-env name=PULL_REQUEST_BODY::${PULL_REQUEST_BODY}"
18+
- name: pull-request-action
19+
uses: vsoch/[email protected]
20+
env:
21+
GITHUB_TOKEN: ${{ secrets.NSM_BOT_GITHUB_TOKEN }}
22+
BRANCH_PREFIX: "update/"
23+
PULL_REQUEST_BRANCH: "master"

.gitignore

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Binaries for programs and plugins
2+
*.exe
3+
*.exe~
4+
*.dll
5+
*.so
6+
*.dylib
7+
8+
# Test binary, built with `go test -c`
9+
*.test
10+
11+
# Output of the go coverage tool, specifically when used with LiteIDE
12+
*.out
13+
14+
# Dependency directories (remove the comment below to include it)
15+
# vendor/
16+
17+
.idea/

0 commit comments

Comments
 (0)