|
| 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 | + |
0 commit comments