Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update from update/networkservicemesh/cmd-template #31

Merged
merged 1 commit into from
Aug 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 85 additions & 27 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,42 @@ jobs:
- uses: actions/checkout@v2
- name: shellcheck
uses: fkautz/[email protected]
build:
name: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v1
with:
go-version: 1.13.4
- run: |
go build -race ./...
build-win:
name: build-win
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v1
with:
go-version: 1.13.4
- run: |
go build -race ./...
build-osx:
name: build-osx
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v1
with:
go-version: 1.13.4
- run: |
go build -race ./...
golangci-lint:
name: golangci-lint
runs-on: ubuntu-latest
env:
GOLANGCI_LINT_CONTAINER: golangci/golangci-lint:v1.28.1
GOLANGCI_LINT_CONTAINER: golangci/golangci-lint:v1.28.3
if: github.repository != 'networkservicemesh/cmd-template'
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
Expand Down Expand Up @@ -58,7 +89,7 @@ jobs:
- name: Restrict dependencies on github.com/networkservicemesh/*
run: |
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
if [ "${i}" != "github.com/networkservicemesh/sdk-vppagent" ] && [ "${i}" != "github.com/networkservicemesh/sdk" ] && [ "${i}" != "github.com/networkservicemesh/api" ]; then
if [ "${i}" != "github.com/networkservicemesh/sdk" ] && [ "${i}" != "github.com/networkservicemesh/api" ]; then
echo Dependency on "${i}" is forbidden
exit 1
fi
Expand All @@ -77,20 +108,29 @@ jobs:
run: |
git diff --name-only --exit-code go.mod || ( echo "Run go tidy" && false )
git diff --name-only --exit-code go.sum || ( echo "Run go tidy" && false )
license:
name: license header check

gogenerate:
name: Check generated files
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: arduino/setup-protoc@master
with:
version: '3.8.0'
- uses: actions/setup-go@v1
with:
go-version: 1.13.4
- name: Install go-header
run: 'go get github.com/denis-tingajkin/[email protected]'
- name: Run go-header
go-version: 1.13
- name: Install proto-gen-go
run: go get -u github.com/golang/protobuf/[email protected]
- name: Install proto-gen-go
run: go get github.com/searKing/golang/tools/cmd/go-syncmap
- name: Generate files
run: go generate ./...
- name: Check for changes in generated code
run: |
eval $(go env)
${GOPATH}/bin/go-header
git diff -- '*.pb.go' || ( echo "Rerun go generate ./... locally and resubmit" && false )
git diff -- '*.gen.go' || ( echo "Rerun go generate ./... locally and resubmit" && false )

excludereplace:
name: Exclude Replace in go.mod
runs-on: ubuntu-latest
Expand All @@ -106,26 +146,19 @@ jobs:
runs-on: ubuntu-latest
steps:
- run: printenv
gogenerate:
name: gogenerate
docker:
name: Docker Build & Test
runs-on: ubuntu-latest
if: github.repository != 'networkservicemesh/cmd-template'
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v1
with:
go-version: 1.13.4
- name: Generate files
run: go generate ./...
- name: Check for changes in generated code
run: |
git diff -- internal/imports/imports.go || ( echo "Rerun go generate ./... locally and resubmit" && false )
docker:
name: Docker Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- run: docker build .
- run: docker run --rm $(docker build -q --target test .)
- name: Build container
run: docker build .
- name: Run tests
run: docker run --rm $(docker build -q . --target test)
- name: Find merged PR
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: jwalton/gh-find-current-pr@v1
Expand All @@ -142,11 +175,37 @@ jobs:
pr-${{ steps.findPr.outputs.pr }}
commit-${{ github.sha }}
latest
pushImage:
name: Push docker image
runs-on: ubuntu-latest
env:
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DOCKER_USER: ${{ secrets.DOCKER_LOGIN }}
TAG: master
ORG: networkservicemeshci
CGO_ENABLED: 0
NAME: ${{ github.event.repository.name }}
needs:
- automerge
if: github.actor == 'nsmbot' && github.base_ref == 'master' && github.event_name == 'pull_request' && github.repository != 'networkservicemesh/cmd-template'
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v1
with:
go-version: 1.13.4
- name: Build ${NAME} image
run: docker build . -t "${ORG}/${NAME}:${TAG}" --target runtime
- name: Push ${NAME} image
run: |
docker login -u $DOCKER_USER -p $DOCKER_PASSWORD
docker push "${ORG}/${NAME}:${TAG}"
docker image rm "${ORG}/${NAME}:${TAG}"

automerge:
name: automerge
runs-on: ubuntu-latest
needs:
- build
- docker
if: github.actor == 'nsmbot' && github.base_ref == 'master' && github.event_name == 'pull_request'
steps:
Expand All @@ -156,9 +215,8 @@ jobs:
run: |
git remote -v
git fetch --depth=1 origin master
- name: Only allow go.mod and go.sum changes
run: |
find . -type f ! -name 'go.mod' ! -name 'go.sum' -exec git diff --exit-code origin/master -- {} +
- name: NSMBot should update only config files
run: find . -type f ! -name 'go.mod' ! -name 'go.sum' ! -name '*.yaml' ! -name '*.yml' ! -name '*.txt' ! -name '*.md' ! -name '*.conf' -exec git diff --exit-code origin/master -- {} +
- name: Automerge nsmbot PR
uses: ridedott/merge-me-action@master
with:
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/docker-push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
name: push
on:
push:
branches:
- master
jobs:
pushImage:
name: Push docker image
runs-on: ubuntu-latest
env:
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DOCKER_USER: ${{ secrets.DOCKER_LOGIN }}
TAG: master
ORG: networkservicemeshci
CGO_ENABLED: 0
NAME: ${{ github.event.repository.name }}
if: github.repository != 'networkservicemesh/cmd-template'
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v1
with:
go-version: 1.13.4
- name: Build ${NAME} image
run: docker build . -t "${ORG}/${NAME}:${TAG}" --target runtime
- name: Push ${NAME} image
run: |
docker login -u $DOCKER_USER -p $DOCKER_PASSWORD
docker push "${ORG}/${NAME}:${TAG}"
docker image rm "${ORG}/${NAME}:${TAG}"
61 changes: 61 additions & 0 deletions .github/workflows/update-cmd-repositories.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
name: Update dependent repositories
on:
push:
branches:
- master

jobs:
update-dependent-repositories:
strategy:
matrix:
repository: [cmd-registry-proxy-dns, cmd-nsc, cmd-registry-memory, cmd-nsmgr]
name: Update ${{ matrix.repository }}
runs-on: ubuntu-latest
if: github.repository == 'networkservicemesh/cmd-template'
steps:
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v2
with:
path: ${{ github.repository }}
repository: ${{ github.repository }}
token: ${{ secrets.NSM_BOT_GITHUB_TOKEN }}
- name: Find merged PR
uses: jwalton/gh-find-current-pr@v1
id: findPr
with:
github-token: ${{ github.token }}
- name: Create commit message
working-directory: ${{ github.repository }}
run: |
echo "Update common CI files to latest version from ${{ github.repository }}@master ${{ github.repository }}#${{ steps.findPr.outputs.pr }}" >> /tmp/commit-message
echo "" >> /tmp/commit-message
echo "${{ github.repository }} PR link: https://github.com/${{ github.repository }}/pull/${{ steps.findPr.outputs.pr }}" >> /tmp/commit-message
echo "" >> /tmp/commit-message
echo "${{ github.repository }} commit message:" >> /tmp/commit-message
git log -1 >> /tmp/commit-message
echo "Commit Message:"
cat /tmp/commit-message
- name: Checkout networkservicemesh/${{ matrix.repository }}
uses: actions/checkout@v2
with:
path: networkservicemesh/${{ matrix.repository }}
repository: networkservicemesh/${{ matrix.repository }}
token: ${{ secrets.NSM_BOT_GITHUB_TOKEN }}
- uses: actions/setup-go@v1
with:
go-version: 1.13.4
- name: Push update to the ${{ matrix.repository }}
working-directory: networkservicemesh/${{ matrix.repository }}
run: |
echo Starting to update repositotry ${{ matrix.repository }}
git config --global user.email "[email protected]"
git config --global user.name "NSMBot"
git remote add cmd_template https://github.com/networkservicemesh/cmd-template.git
git fetch cmd_template
git diff cmd_template/master -R | git apply
git add $(git ls-tree --name-only -r cmd_template/master | grep ".*\.yml\|.*\.yaml\|.*\.md\|.*\.txt\|.*.\.conf")
git reset -- $(cat exclude.patch.conf)
git commit -s -F /tmp/commit-message
git checkout -b update/${{ github.repository }}
git push -f origin update/${{ github.repository }}
19 changes: 16 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
---
run:
# concurrency: 6
timeout: 1m
timeout: 2m
issues-exit-code: 1
tests: true
linters-settings:
goheader:
template-path: ".license/template.txt"
values:
const:
year: 2020
regexp:
year-range: ((\d\d\d\d-{{year}})|({{year}}))
company: .*
copyright-holder: Copyright \(c\) {{year-range}} {{company}}\n\n
copyright-holders: ({{copyright-holder}})+
errcheck:
check-type-assertions: false
check-blank: false
Expand All @@ -20,13 +30,16 @@ linters-settings:
golint:
min-confidence: 0.8
goimports:
local-prefixes: github.com/networkservicemesh/cmd-forwarder-vppagent
local-prefixes: github.com/networkservicemesh
gocyclo:
min-complexity: 15
maligned:
suggest-new: true
dupl:
threshold: 150
funlen:
Lines: 100
Statements: 50
goconst:
min-len: 2
min-occurrences: 2
Expand Down Expand Up @@ -93,7 +106,6 @@ linters-settings:
- octalLiteral
- offBy1
- paramTypeCombine
- ptrToRefParam
- rangeExprCopy
- rangeValCopy
- regexpMust
Expand All @@ -120,6 +132,7 @@ linters:
disable-all: true
enable:
# - rowserrcheck
- goheader
- bodyclose
- deadcode
- depguard
Expand Down
28 changes: 13 additions & 15 deletions .license/template.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
// {NSM COPYRIGHT HOLDERS}
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at:
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
{{copyright-holders}}SPDX-License-Identifier: Apache-2.0

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at:

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
2 changes: 2 additions & 0 deletions exclude.patch.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
## Put here paths to files which should be ignored on updating from depended repository
README.md