generated from networkservicemesh/cmd-template
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 1ab4315
Showing
17 changed files
with
922 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,203 @@ | ||
--- | ||
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: yaml-lint | ||
uses: ibiqlik/action-yamllint@v1 | ||
with: | ||
config_file: .yamllint.yml | ||
strict: true | ||
shellcheck: | ||
name: shellcheck | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: shellcheck | ||
uses: fkautz/[email protected] | ||
build: | ||
name: build and test | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, macos-latest, windows-latest] | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
- name: Setup Go | ||
uses: actions/setup-go@v1 | ||
with: | ||
go-version: 1.13.4 | ||
- name: Build | ||
run: go build -race ./... | ||
golangci-lint: | ||
name: golangci-lint | ||
runs-on: ubuntu-latest | ||
if: github.repository != 'networkservicemesh/cmd-template' | ||
steps: | ||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v2 | ||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v2 | ||
with: | ||
version: v1.31 | ||
|
||
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/* | ||
env: | ||
ALLOWED_REPOSITORIES: "sdk, api, sdk-k8s, sdk-vppagent, sdk-sriov" | ||
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 ! [ "$(echo ${ALLOWED_REPOSITORIES}| grep ${i#github.com/networkservicemesh/})" ]; 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 | ||
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: Build container | ||
run: docker build . | ||
- name: Run tests | ||
run: docker run --privileged --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 | ||
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: | ||
- name: Check out the code | ||
uses: actions/checkout@v2 | ||
- name: Fetch master | ||
run: | | ||
git remote -v | ||
git fetch --depth=1 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: | ||
GITHUB_LOGIN: nsmbot | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
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: | ||
- uses: actions/checkout@v2 | ||
- name: Construct PR message | ||
run: | | ||
PULL_REQUEST_BODY=$(git log -1) | ||
echo ${PULL_REQUEST_BODY} | ||
echo "::set-env name=PULL_REQUEST_BODY::${PULL_REQUEST_BODY}" | ||
- name: pull-request-action | ||
uses: vsoch/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.NSM_BOT_GITHUB_TOKEN }} | ||
BRANCH_PREFIX: "update/" | ||
PULL_REQUEST_BRANCH: "master" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
--- | ||
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, cmd-forwarder-vppagent, cmd-exclude-prefixes-k8s] | ||
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 restore --staged -- exclude.patch.conf | ||
git restore -- exclude.patch.conf | ||
git restore --staged -- $(cat exclude.patch.conf) | ||
git restore -- $(cat exclude.patch.conf) | ||
if ! [ -n "$(git diff --cached --exit-code)" ]; then | ||
exit 0; | ||
fi | ||
git commit -s -F /tmp/commit-message | ||
git checkout -b update/${{ github.repository }} | ||
git push -f origin update/${{ github.repository }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/ |
Oops, something went wrong.