github.com/vmware/govmomi@v0.37.1/.github/workflows/govmomi-go-lint.yaml (about) 1 # Copyright (c) 2021 VMware, Inc. All Rights Reserved. 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: Code Style 16 17 on: 18 push: 19 branches: [ 'main' ] 20 21 pull_request: 22 branches: [ 'main' ] 23 24 jobs: 25 lint: 26 name: Lint Files 27 runs-on: ubuntu-20.04 28 timeout-minutes: 10 29 30 steps: 31 - name: Check out code 32 uses: actions/checkout@v4 33 34 - name: Set up Go 35 uses: actions/setup-go@v5 36 with: 37 go-version: 1.21 38 id: go 39 40 - name: Go Lint 41 run: make lint 42 43 boilerplate: 44 name: Boilerplate Check 45 runs-on: ubuntu-latest 46 strategy: 47 fail-fast: false # Keep running if one leg fails. 48 matrix: 49 extension: 50 - go 51 52 # Map between extension and human-readable name. 53 include: 54 - extension: go 55 language: Go 56 57 steps: 58 - name: Check out code 59 uses: actions/checkout@v4 60 61 - name: Set up Go 62 uses: actions/setup-go@v5 63 with: 64 go-version: 1.21 65 id: go 66 67 - name: Install Tools 68 run: | 69 TEMP_PATH="$(mktemp -d)" 70 cd "$TEMP_PATH" 71 72 echo '::group::🐶 Installing reviewdog ... https://github.com/reviewdog/reviewdog' 73 curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s -- -b "${TEMP_PATH}" 2>&1 74 echo '::endgroup::' 75 76 echo '::group:: Installing boilerplate-check ... https://github.com/mattmoor/boilerplate-check' 77 go install github.com/mattmoor/boilerplate-check/cmd/boilerplate-check@latest 78 echo '::endgroup::' 79 80 echo "${TEMP_PATH}" >> "$GITHUB_PATH" 81 82 - id: boilerplate_txt 83 uses: andstor/file-existence-action@v3 84 with: 85 files: ./hack/boilerplate/boilerplate.${{ matrix.extension }}.txt 86 87 - name: ${{ matrix.language }} license boilerplate 88 shell: bash 89 if: ${{ steps.boilerplate_txt.outputs.files_exists == 'true' }} 90 env: 91 REVIEWDOG_GITHUB_API_TOKEN: ${{ github.token }} 92 run: | 93 set -e 94 cd "${GITHUB_WORKSPACE}" || exit 1 95 96 echo '::group:: Running github.com/mattmoor/boilerplate-check for ${{ matrix.language }} with reviewdog 🐶 ...' 97 # Don't fail because of boilerplate-check 98 set +o pipefail 99 boilerplate-check check \ 100 --boilerplate ./hack/boilerplate/boilerplate.${{ matrix.extension }}.txt \ 101 --file-extension ${{ matrix.extension }} \ 102 --exclude "((vim25/json)|vendor|third_party|dist)/" | 103 reviewdog -efm="%A%f:%l: %m" \ 104 -efm="%C%.%#" \ 105 -name="${{ matrix.language }} headers" \ 106 -reporter="github-pr-check" \ 107 -filter-mode="diff_context" \ 108 -fail-on-error="true" \ 109 -level="error" 110 echo '::endgroup::'