Skip to content

Commit

Permalink
added linting back
Browse files Browse the repository at this point in the history
  • Loading branch information
wilkermichael committed Feb 9, 2024
1 parent f80e31b commit 682fbdb
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 70 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Dispatch to the consul-k8s-workflows when a PR is created and on merges to main/release*
name: pr
on:
pull_request:
inputs:
golangci-lint-version:
description: "Golangci-lint version"
required: false
type: string
default: "v1.55.2"

get-go-version:
runs-on: ubuntu-latest
outputs:
go-version: ${{ steps.get-go-version.outputs.go-version }}
steps:
- name: Checkout code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3

- name: Determine Go version
id: get-go-version
# We use .go-version as our source of truth for current Go
# version, because "goenv" can react to it automatically.
run: |
echo "Building with Go $(cat .go-version)"
echo "go-version=$(cat .go-version)" >> "${GITHUB_OUTPUT}"
linting:
name: golangci-lint
needs:
- get-go-version
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3

- name: Setup go
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version: ${{ needs.get-go-version.outputs.go-version }}
cache: false

- name: Setup GOROOT # Need to set GOROOT because an older version of go-critic used GOROOT to find rules
run: echo "GOROOT=$(go env GOROOT)" >> "${GITHUB_ENV}"

- name: golangci-lint-helm-gen
uses: golangci/golangci-lint-action@639cd343e1d3b897ff35927a75193d57cfcba299 # v3.6.0
with:
version: ${{ inputs.golangci-lint-version }}
working-directory: hack/helm-reference-gen
skip-cache: true # We have seen sticky timeout bugs crop up with caching enabled, so disabling for now
args: "--no-config --disable-all --enable gofmt,govet"

- name: golangci-lint-control-plane
uses: golangci/golangci-lint-action@639cd343e1d3b897ff35927a75193d57cfcba299 # v3.6.0
with:
version: ${{ inputs.golangci-lint-version }}
working-directory: control-plane
skip-cache: true # We have seen sticky timeout bugs crop up with caching enabled, so disabling for now

- name: golangci-lint-acceptance
uses: golangci/golangci-lint-action@639cd343e1d3b897ff35927a75193d57cfcba299 # v3.6.0
with:
version: ${{ inputs.golangci-lint-version }}
working-directory: acceptance
skip-cache: true # We have seen sticky timeout bugs crop up with caching enabled, so disabling for now

- name: golangci-lint-cli
uses: golangci/golangci-lint-action@639cd343e1d3b897ff35927a75193d57cfcba299 # v3.6.0
with:
version: ${{ inputs.golangci-lint-version }}
working-directory: acceptance
skip-cache: true # We have seen sticky timeout bugs crop up with caching enabled, so disabling for now
71 changes: 1 addition & 70 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@
name: pr
on:
pull_request:
inputs:
golangci-lint-version:
description: "Golangci-lint version"
required: false
type: string
default: "v1.55.2"

# these should be the only settings that you will ever need to change
env:
Expand All @@ -27,67 +21,4 @@ jobs:
repo: hashicorp/consul-k8s-workflows
ref: main
token: ${{ secrets.ELEVATED_GITHUB_TOKEN }}
inputs: '{ "context":"${{ env.CONTEXT }}", "actor":"${{ github.actor }}", "repository":"${{ github.repository }}", "branch":"${{ env.BRANCH }}", "sha":"${{ env.SHA }}", "token":"${{ secrets.ELEVATED_GITHUB_TOKEN }}" }'

get-go-version:
runs-on: ubuntu-latest
outputs:
go-version: ${{ steps.get-go-version.outputs.go-version }}
steps:
- name: Checkout code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3

- name: Determine Go version
id: get-go-version
# We use .go-version as our source of truth for current Go
# version, because "goenv" can react to it automatically.
run: |
echo "Building with Go $(cat .go-version)"
echo "go-version=$(cat .go-version)" >> "${GITHUB_OUTPUT}"
linting:
name: golangci-lint
needs:
- get-go-version
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3

- name: Setup go
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version: ${{ needs.get-go-version.outputs.go-version }}
cache: false

- name: Setup GOROOT # Need to set GOROOT because an older version of go-critic used GOROOT to find rules
run: echo "GOROOT=$(go env GOROOT)" >> "${GITHUB_ENV}"

- name: golangci-lint-helm-gen
uses: golangci/golangci-lint-action@639cd343e1d3b897ff35927a75193d57cfcba299 # v3.6.0
with:
version: ${{ inputs.golangci-lint-version }}
working-directory: hack/helm-reference-gen
skip-cache: true # We have seen sticky timeout bugs crop up with caching enabled, so disabling for now
args: "--no-config --disable-all --enable gofmt,govet"

- name: golangci-lint-control-plane
uses: golangci/golangci-lint-action@639cd343e1d3b897ff35927a75193d57cfcba299 # v3.6.0
with:
version: ${{ inputs.golangci-lint-version }}
working-directory: control-plane
skip-cache: true # We have seen sticky timeout bugs crop up with caching enabled, so disabling for now

- name: golangci-lint-acceptance
uses: golangci/golangci-lint-action@639cd343e1d3b897ff35927a75193d57cfcba299 # v3.6.0
with:
version: ${{ inputs.golangci-lint-version }}
working-directory: acceptance
skip-cache: true # We have seen sticky timeout bugs crop up with caching enabled, so disabling for now

- name: golangci-lint-cli
uses: golangci/golangci-lint-action@639cd343e1d3b897ff35927a75193d57cfcba299 # v3.6.0
with:
version: ${{ inputs.golangci-lint-version }}
working-directory: acceptance
skip-cache: true # We have seen sticky timeout bugs crop up with caching enabled, so disabling for now
inputs: '{ "context":"${{ env.CONTEXT }}", "actor":"${{ github.actor }}", "repository":"${{ github.repository }}", "branch":"${{ env.BRANCH }}", "sha":"${{ env.SHA }}", "token":"${{ secrets.ELEVATED_GITHUB_TOKEN }}" }'

0 comments on commit 682fbdb

Please sign in to comment.