|
| 1 | +# Copyright 2020 The Serverless Workflow Specification Authors |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +name: Go SDK PR Checks |
| 16 | +on: |
| 17 | + pull_request: |
| 18 | + paths-ignore: |
| 19 | + - "**.md" |
| 20 | + - "hack/**" |
| 21 | + - "LICENSE" |
| 22 | + - "Makefile" |
| 23 | + branches: |
| 24 | + - master |
| 25 | + env: |
| 26 | + GO_VERSION: 1.14 |
| 27 | + jobs: |
| 28 | + basic_checks: |
| 29 | + name: Basic Checks |
| 30 | + runs-on: ubuntu-latest |
| 31 | + env: |
| 32 | + GOLANG_LINT_VERSION: v1.27.0 |
| 33 | + steps: |
| 34 | + - name: Checkout Code |
| 35 | + uses: actions/checkout@v2 |
| 36 | + - name: Setup Go ${{ env.GO_VERSION }} |
| 37 | + uses: actions/setup-go@v2 |
| 38 | + with: |
| 39 | + go-version: ${{ env.GO_VERSION }} |
| 40 | + id: go |
| 41 | + - name: Cache dependencies |
| 42 | + uses: actions/cache@v2 |
| 43 | + with: |
| 44 | + path: ~/go/pkg/mod/cache |
| 45 | + key: ${{ runner.os }}-go-cache-${{ hashFiles('**/go.sum') }} |
| 46 | + restore-keys: | |
| 47 | + ${{ runner.os }}-go-cache- |
| 48 | + - name: Check Headers |
| 49 | + run: | |
| 50 | + make addheaders |
| 51 | + changed_files=$(git status -s | grep -v 'go.mod\|go.sum' || :) |
| 52 | + [[ -z "$changed_files" ]] || (printf "Some files are missing the headers: \n$changed_files\n Did you run 'make lint' before sending the PR" && exit 1) |
| 53 | + - name: Check Formatting |
| 54 | + run: | |
| 55 | + make fmt |
| 56 | + changed_files=$(git status -s | grep -v 'go.mod\|go.sum' || :) |
| 57 | + [[ -z "$changed_files" ]] || (printf "Some files are not formatted properly: \n$changed_files\n Did you run 'make test' before sending the PR?" && exit 1) |
| 58 | + - name: Install golinters |
| 59 | + run: | |
| 60 | + go get -u golang.org/x/lint/golint |
| 61 | + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin $GOLANG_LINT_VERSION |
| 62 | + - name: Check lint |
| 63 | + run: | |
| 64 | + make lint |
| 65 | + - name: Install cover |
| 66 | + run: go get golang.org/x/tools/cmd/cover |
| 67 | + - run: go mod tidy |
| 68 | + - name: Validate codcov yaml file |
| 69 | + run: curl -vvv --data-binary @codecov.yml https://codecov.io/validate |
| 70 | + - name: Run Unit Tests |
| 71 | + run: | |
| 72 | + ./hack/go-test.sh "true" |
| 73 | + - name: Upload results to codecov |
| 74 | + uses: codecov/codecov-action@v1 |
| 75 | + with: |
| 76 | + file: ./test_coverage.txt |
| 77 | + flags: sdk-go |
| 78 | + name: sdk-go |
| 79 | + fail_ci_if_error: true |
0 commit comments