Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
haiodo committed Aug 12, 2020
0 parents commit 2816da3
Show file tree
Hide file tree
Showing 13 changed files with 855 additions and 0 deletions.
198 changes: 198 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
---
name: ci
on:
push:
branches:
- master
pull_request:
jobs:
yamllint:
name: yamllint
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v1
- name: Install yamllint
run: pip install --user yamllint
- name: Run yamllint
run: ~/.local/bin/yamllint -c .yamllint.yml --strict .
shellcheck:
name: shellcheck
runs-on: ubuntu-latest
steps:
- 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.3
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Pull golangci-lint docker container
run: docker pull ${GOLANGCI_LINT_CONTAINER}
- name: Run golangci-lint
run: docker run --rm -v $(pwd):/app -w /app ${GOLANGCI_LINT_CONTAINER} golangci-lint run

excludeFmtErrorf:
name: exclude fmt.Errorf
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Exclude fmt.Errorf
run: |
if grep -r --include=*.go --exclude=*.pb.go fmt.Errorf . ; then
echo "Please use errors.Errorf (or errors.New or errors.Wrap or errors.Wrapf) as appropriate rather than fmt.Errorf"
exit 1
fi
restrictNSMDeps:
name: Restrict dependencies on github.com/networkservicemesh/*
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- 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" ] && [ "${i}" != "github.com/networkservicemesh/api" ]; then
echo Dependency on "${i}" is forbidden
exit 1
fi
done
checkgomod:
name: check go.mod and go.sum
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v1
with:
go-version: 1.13.4
- run: go mod tidy
- name: Check for changes in go.mod or go.sum
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 )
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
- 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: |
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
steps:
- name: Check out the code
uses: actions/checkout@v2
- name: Exclude replace in go.mod
run: |
grep ^replace go.mod || exit 0
exit 1
captureRunEnv:
name: Capture CI Run Env
runs-on: ubuntu-latest
steps:
- run: printenv
docker:
name: Docker Build & Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v1
with:
go-version: 1.13.4
- 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
id: findPr
with:
github-token: ${{ github.token }}

- name: Publish Image
if: github.event_name == 'push' && github.ref == 'refs/heads/master' && success() && steps.findPr.outputs.number
uses: matootie/[email protected]
with:
accessToken: ${{ github.token }}
tag: |
pr-${{ steps.findPr.outputs.pr }}
commit-${{ github.sha }}
latest
automerge:
name: automerge
runs-on: ubuntu-latest
needs:
- build
- docker
if: github.actor == 'nsmbot' && github.base_ref == 'master' && github.event_name == 'pull_request'
steps:
- name: Check out the code
uses: actions/checkout@v2
- name: Fetch master
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: Automerge nsmbot PR
uses: ridedott/merge-me-action@master
with:
GITHUB_LOGIN: nsmbot
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
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 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.repository }}
if: github.repository != 'networkservicemesh/cmd-template'
steps:
- uses: actions/checkout@v1
- 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}"
17 changes: 17 additions & 0 deletions .github/workflows/pr-for-updates.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: Pull Request on update/* Branch Push
on:
push:
branches:
- update/*
jobs:
auto-pull-request:
name: Pull Request on update/* Branch Push
runs-on: ubuntu-latest
steps:
- name: pull-request-action
uses: vsoch/pull-request-action@master
env:
GITHUB_TOKEN: ${{ secrets.NSM_BOT_GITHUB_TOKEN }}
BRANCH_PREFIX: "update/"
PULL_REQUEST_BRANCH: "master"
56 changes: 56 additions & 0 deletions .github/workflows/update-cmd-repositories.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
name: Update cmd repositories
on:
push:
branches:
- master

jobs:
update-cmd-repositories:
strategy:
matrix:
repository: [cmd-registry-proxy-dns]
name: Update ${{ matrix.repository }}
runs-on: ubuntu-latest
steps:
- 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
- uses: actions/checkout@v2
with:
path: networkservicemesh/${{ matrix.repository }}
repository: networkservicemesh/${{ matrix.repository }}
token: ${{ secrets.NSM_BOT_GITHUB_TOKEN }}
sha: ${{ GITHUB_SHA }}
- uses: actions/setup-go@v1
with:
go-version: 1.13.4
- name: Push update to ${{ matrix.repository }}
working-directory: networkservicemesh/${{ matrix.repository }}
run: |
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 cherry-pick --no-commit ${sha}
git commit -F /tmp/commit-message
git checkout -b update/sdk-gomod
git push -f origin update/sdk-gomod
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/

.idea/
junit/
Loading

0 comments on commit 2816da3

Please sign in to comment.