consul/.github/workflows/reusable-lint.yml

63 lines
2.1 KiB
YAML

name: reusable-lint
on:
workflow_call:
inputs:
go-arch:
required: false
type: string
default: ""
go-version:
required: true
type: string
runs-on:
description: An expression indicating which kind of runners to use.
required: true
type: string
repository-name:
required: true
type: string
secrets:
elevated-github-token:
required: true
env:
GOTAGS: "${{ github.event.repository.name == 'consul-enterprise' && 'consulent consuldev' || '' }}"
GOARCH: ${{inputs.go-arch}}
GOPRIVATE: github.com/hashicorp # Required for enterprise deps
jobs:
lint:
runs-on: ${{ fromJSON(inputs.runs-on) }}
strategy:
matrix:
directory:
- ""
- "api"
- "sdk"
- "envoyextensions"
- "troubleshoot"
- "test/integration/consul-container"
- "test-integ"
- "testing/deployer"
fail-fast: true
name: lint ${{ matrix.directory }}
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
# NOTE: This step is specifically needed for ENT. It allows us to access the required private HashiCorp repos.
- name: Setup Git
if: ${{ endsWith(inputs.repository-name, '-enterprise') }}
run: git config --global url."https://${{ secrets.elevated-github-token }}:@github.com".insteadOf "https://github.com"
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version: ${{ inputs.go-version }}
- run: go env
- name: Set golangci-lint version
run: echo "GOLANGCI_LINT_VERSION=$(make --no-print-directory print-GOLANGCI_LINT_VERSION)" >> $GITHUB_ENV
- name: lint-${{ matrix.directory }}
uses: golangci/golangci-lint-action@639cd343e1d3b897ff35927a75193d57cfcba299 # v3.6.0
with:
working-directory: ${{ matrix.directory }}
version: ${{ env.GOLANGCI_LINT_VERSION }}
args: --build-tags="${{ env.GOTAGS }}" -v
skip-cache: true