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

58 lines
1.8 KiB
YAML

name: reusable-lint
on:
workflow_call:
inputs:
go-arch:
required: false
type: string
default: ""
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 consulprem consuldev' || '' }}"
GOARCH: ${{inputs.go-arch}}
jobs:
lint:
runs-on: ${{ fromJSON(inputs.runs-on) }}
strategy:
matrix:
directory:
- ""
- "api"
- "sdk"
- "envoyextensions"
- "troubleshoot"
- "test/integration/consul-container"
fail-fast: true
name: lint ${{ matrix.directory }}
steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # pin@v3.3.0
# 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@6edd4406fa81c3da01a34fa6f6343087c207a568 # pin@v3.5.0
with:
go-version-file: 'go.mod'
- run: go env
- name: lint-${{ matrix.directory }}
uses: golangci/golangci-lint-action@08e2f20817b15149a52b5b3ebe7de50aff2ba8c5 # pin@v3.4.0
with:
working-directory: ${{ matrix.directory }}
version: v1.51.1
args: --build-tags="${{ env.GOTAGS }}" -v
skip-cache: true
- name: Notify Slack
if: ${{ failure() }}
run: .github/scripts/notify_slack.sh