2023-03-28 21:29:27 +00:00
|
|
|
name: reusable-lint
|
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_call:
|
|
|
|
inputs:
|
|
|
|
go-arch:
|
|
|
|
required: false
|
|
|
|
type: string
|
|
|
|
default: ""
|
2024-01-08 22:18:41 +00:00
|
|
|
go-version:
|
|
|
|
required: true
|
|
|
|
type: string
|
2023-03-28 21:29:27 +00:00
|
|
|
runs-on:
|
|
|
|
description: An expression indicating which kind of runners to use.
|
|
|
|
required: true
|
|
|
|
type: string
|
2023-03-30 16:57:11 +00:00
|
|
|
repository-name:
|
|
|
|
required: true
|
|
|
|
type: string
|
|
|
|
secrets:
|
|
|
|
elevated-github-token:
|
|
|
|
required: true
|
2023-03-28 21:29:27 +00:00
|
|
|
env:
|
2023-11-14 20:02:18 +00:00
|
|
|
GOTAGS: "${{ github.event.repository.name == 'consul-enterprise' && 'consulent consuldev' || '' }}"
|
2023-03-28 21:29:27 +00:00
|
|
|
GOARCH: ${{inputs.go-arch}}
|
2023-06-21 15:26:27 +00:00
|
|
|
GOPRIVATE: github.com/hashicorp # Required for enterprise deps
|
2023-03-28 21:29:27 +00:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
lint:
|
|
|
|
runs-on: ${{ fromJSON(inputs.runs-on) }}
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
directory:
|
|
|
|
- ""
|
|
|
|
- "api"
|
|
|
|
- "sdk"
|
|
|
|
- "envoyextensions"
|
|
|
|
- "troubleshoot"
|
|
|
|
- "test/integration/consul-container"
|
2023-09-19 14:05:51 +00:00
|
|
|
- "test-integ"
|
2023-07-17 22:15:22 +00:00
|
|
|
- "testing/deployer"
|
2023-03-28 21:29:27 +00:00
|
|
|
fail-fast: true
|
|
|
|
name: lint ${{ matrix.directory }}
|
|
|
|
steps:
|
2024-05-14 19:49:03 +00:00
|
|
|
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
|
2023-03-30 16:57:11 +00:00
|
|
|
# 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"
|
2024-05-14 19:49:03 +00:00
|
|
|
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
|
2023-03-28 21:29:27 +00:00
|
|
|
with:
|
2024-01-08 22:18:41 +00:00
|
|
|
go-version: ${{ inputs.go-version }}
|
2023-03-28 21:29:27 +00:00
|
|
|
- run: go env
|
2024-01-12 14:57:38 +00:00
|
|
|
- name: Set golangci-lint version
|
|
|
|
run: echo "GOLANGCI_LINT_VERSION=$(make --no-print-directory print-GOLANGCI_LINT_VERSION)" >> $GITHUB_ENV
|
2023-03-28 21:29:27 +00:00
|
|
|
- name: lint-${{ matrix.directory }}
|
2024-05-14 19:49:03 +00:00
|
|
|
uses: golangci/golangci-lint-action@82d40c283aeb1f2b6595839195e95c2d6a49081b # v5.0.0
|
2023-03-28 21:29:27 +00:00
|
|
|
with:
|
|
|
|
working-directory: ${{ matrix.directory }}
|
2024-01-12 14:57:38 +00:00
|
|
|
version: ${{ env.GOLANGCI_LINT_VERSION }}
|
2023-03-28 21:29:27 +00:00
|
|
|
args: --build-tags="${{ env.GOTAGS }}" -v
|
2023-05-25 14:24:07 +00:00
|
|
|
skip-cache: true
|