Skip to content
This repository has been archived by the owner on May 2, 2021. It is now read-only.

Commit

Permalink
Update common CI files to latest version from networkservicemesh/cmd-…
Browse files Browse the repository at this point in the history
…template@master networkservicemesh/cmd-template#13

networkservicemesh/cmd-template PR link: networkservicemesh/cmd-template#13

networkservicemesh/cmd-template commit message:
commit e7476b50d1a8dd0adc7b844e8e872038be149be7
Author: Ed Warnicke <[email protected]>
Date:   Sat Aug 22 12:25:51 2020 -0500

    Merge pull request #13 from denis-tingajkin/subscribe_cmd-forwarder-vppagent

    Subscribe cmd-forwarder-vppagent on cmd-template updates

Signed-off-by: NSMBot <[email protected]>
  • Loading branch information
NSMBot committed Aug 22, 2020
1 parent 042e456 commit f48a0b6
Show file tree
Hide file tree
Showing 7 changed files with 224 additions and 65 deletions.
130 changes: 94 additions & 36 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,45 @@ 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.23.2
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@v1
uses: actions/checkout@v2
- name: Pull golangci-lint docker container
run: docker pull ${GOLANGCI_LINT_CONTAINER}
- name: Run golangci-lint
Expand All @@ -42,10 +73,10 @@ jobs:
name: exclude fmt.Errorf
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: Exclude fmt.Errorf
run: |
if grep -r --include=*.go fmt.Errorf . ; then
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
Expand All @@ -54,11 +85,11 @@ jobs:
name: Restrict dependencies on github.com/networkservicemesh/*
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- 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-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 @@ -68,7 +99,7 @@ jobs:
name: check go.mod and go.sum
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- uses: actions/setup-go@v1
with:
go-version: 1.13.4
Expand All @@ -77,55 +108,57 @@ 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@v1
- 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
name: Exclude Replace in go.mod
runs-on: ubuntu-latest
steps:
- name: Check out the code
uses: actions/checkout@v1
uses: actions/checkout@v2
- name: Exclude replace in go.mod
run: |
grep ^replace || exit 0
grep ^replace go.mod || exit 0
exit 1
captureRunEnv:
name: Capture CI Run Env
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 --privileged --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}"
10 changes: 8 additions & 2 deletions .github/workflows/pr-for-updates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@ name: Pull Request on update/* Branch Push
on:
push:
branches:
- update/*
- 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/pull-request-action@master
uses: vsoch/pull-request-action@1.0.6
env:
GITHUB_TOKEN: ${{ secrets.NSM_BOT_GITHUB_TOKEN }}
BRANCH_PREFIX: "update/"
Expand Down
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, cmd-forwarder-vppagent]
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 }}
Loading

0 comments on commit f48a0b6

Please sign in to comment.