Skip to content

Commit

Permalink
Add GHA linting
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-innis committed Oct 26, 2023
1 parent 6decc34 commit 48decff
Show file tree
Hide file tree
Showing 23 changed files with 72 additions and 47 deletions.
17 changes: 17 additions & 0 deletions .github/actionlint-matcher.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"problemMatcher": [
{
"owner": "actionlint",
"pattern": [
{
"regexp": "^(?:\\x1b\\[\\d+m)?(.+?)(?:\\x1b\\[\\d+m)*:(?:\\x1b\\[\\d+m)*(\\d+)(?:\\x1b\\[\\d+m)*:(?:\\x1b\\[\\d+m)*(\\d+)(?:\\x1b\\[\\d+m)*: (?:\\x1b\\[\\d+m)*(.+?)(?:\\x1b\\[\\d+m)* \\[(.+?)\\]$",
"file": 1,
"line": 2,
"column": 3,
"message": 4,
"code": 5
}
]
}
]
}
4 changes: 1 addition & 3 deletions .github/workflows/approval-comment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ jobs:
REVIEW_BODY: ${{ github.event.review.body }}
run: |
mkdir -p /tmp/artifacts
echo $REVIEW_BODY >> /tmp/artifacts/metadata.txt
echo ${{ github.event.pull_request.number }} >> /tmp/artifacts/metadata.txt
echo ${{ github.event.review.commit_id }} >> /tmp/artifacts/metadata.txt
{ echo "$REVIEW_BODY"; echo ${{ github.event.pull_request.number }}; echo ${{ github.event.review.commit_id }}; } >> /tmp/artifacts/metadata.txt
cat /tmp/artifacts/metadata.txt
- uses: actions/upload-artifact@v3
with:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/install-deps
- name: Enable the actionlint matcher
run: echo "::add-matcher::.github/actionlint-matcher.json"
- run: make ci-non-test
2 changes: 1 addition & 1 deletion .github/workflows/e2e-cleanup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
name: cleanup-${{ inputs.cluster_name }}
runs-on: ubuntu-latest
steps:
- name: cleanup karpenter and cluster '${{ inputs.cluster-name }}' resources
- name: cleanup karpenter and cluster '${{ inputs.cluster_name }}' resources
uses: ./.github/actions/e2e/cleanup
with:
account_id: ${{ vars.ACCOUNT_ID }}
Expand Down
23 changes: 12 additions & 11 deletions .github/workflows/e2e-conformance-trigger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@ on:
workflows: [ApprovalComment]
types: [completed]
workflow_dispatch:
region:
required: true
default: 'eu-west-1'
type: choice
options:
- "us-east-1"
- "eu-west-1"
cleanup:
required: true
default: true
type: boolean
inputs:
region:
required: true
default: 'eu-west-1'
type: choice
options:
- "us-east-1"
- "eu-west-1"
cleanup:
required: true
default: true
type: boolean
jobs:
resolve:
if: (github.repository == 'aws/karpenter' && (github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success')) || github.event_name == 'workflow_dispatch'
Expand Down
23 changes: 12 additions & 11 deletions .github/workflows/e2e-matrix-trigger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@ on:
workflows: [ApprovalComment]
types: [completed]
workflow_dispatch:
region:
required: true
default: 'us-east-2'
type: choice
options:
- "us-east-1"
- "us-east-2"
cleanup:
required: true
default: true
type: boolean
inputs:
region:
required: true
default: 'us-east-2'
type: choice
options:
- "us-east-1"
- "us-east-2"
cleanup:
required: true
default: true
type: boolean
jobs:
resolve:
if: (github.repository == 'aws/karpenter' && (github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success')) || github.event_name == 'workflow_dispatch'
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/e2e-matrix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ on:
cleanup:
type: boolean
required: true
default: true
git_ref:
type: string
workflow_trigger:
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/e2e-upgrade.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ on:
default: "1.28"
cleanup:
required: true
default: true
type: boolean
workflow_trigger:
type: string
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ on:
cleanup:
type: boolean
required: true
default: true
workflow_trigger:
type: string
secrets:
Expand Down Expand Up @@ -102,10 +101,10 @@ jobs:
- name: add jitter on cluster creation
run: |
# Creating jitter so that we can stagger cluster creation to avoid throttling
sleep $(( $RANDOM % 300 + 1 ))
sleep $(( RANDOM % 300 + 1 ))
- id: generate-cluster-name
run: |
CLUSTER_NAME=$(echo ${{ inputs.suite }}-$RANDOM$RANDOM | awk '{print tolower($0)}' | tr / -)
CLUSTER_NAME="$(echo ${{ inputs.suite }}-"$RANDOM$RANDOM" | awk '{print tolower($0)}' | tr / -)"
echo "Using cluster name \"$CLUSTER_NAME\""
echo CLUSTER_NAME=$CLUSTER_NAME >> $GITHUB_OUTPUT
- name: create eks cluster '${{ steps.generate-cluster-name.outputs.CLUSTER_NAME }}'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pr-snapshot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ jobs:
- uses: ./.github/actions/download-artifact
- id: metadata
run: |
pr_number=$(head -n 2 /tmp/artifacts/metadata.txt | tail -n 1)
pr_commit=$(tail -n 1 /tmp/artifacts/metadata.txt)
pr_number="$(head -n 2 /tmp/artifacts/metadata.txt | tail -n 1)"
pr_commit="$(tail -n 1 /tmp/artifacts/metadata.txt)"
echo "PR_COMMIT=$pr_commit" >> $GITHUB_OUTPUT
echo "PR_NUMBER=$pr_number" >> $GITHUB_OUTPUT
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
prerelease: false
- id: tag
run: |
TAG=$(git describe --tags --exact-match)
TAG="$(git describe --tags --exact-match)"
echo "TAG=${TAG}" >> $GITHUB_OUTPUT
- uses: ./.github/actions/install-deps
- uses: aws-actions/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/resolve-args.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- id: resolve-step
run: |
if [[ "${{ github.event_name }}" == "workflow_run" ]]; then
if [[ $(head -n 1 /tmp/artifacts/metadata.txt) == *"${{ inputs.allowed_comment }}"* ]]; then
if [[ "$(head -n 1 /tmp/artifacts/metadata.txt)" == *"${{ inputs.allowed_comment }}"* ]]; then
echo SHOULD_RUN=true >> $GITHUB_OUTPUT
else
echo SHOULD_RUN=false >> $GITHUB_OUTPUT
Expand Down
8 changes: 8 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ linters-settings:
min-complexity: 11
govet:
check-shadowing: true
revive:
rules:
- name: dot-imports
disabled: true
stylecheck:
dot-import-whitelist:
- "github.com/onsi/ginkgo/v2"
- "github.com/onsi/gomega"
misspell:
locale: US
ignore-words: []
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ verify: tidy download ## Verify code. Includes dependencies, linting, formatting
fi;}
@echo "Validating codegen/docgen build scripts..."
@find hack/code hack/docs -name "*.go" -type f -print0 | xargs -0 -I {} go build -o /dev/null {}
actionlint -oneline

vulncheck: ## Verify code vulnerabilities
@govulncheck ./pkg/...
Expand Down
1 change: 1 addition & 0 deletions hack/toolchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ tools() {
go install -tags extended github.com/gohugoio/[email protected]
go install golang.org/x/vuln/cmd/govulncheck@latest
go install github.com/onsi/ginkgo/v2/ginkgo@latest
go install github.com/rhysd/actionlint/cmd/actionlint@latest

if ! echo "$PATH" | grep -q "${GOPATH:-undefined}/bin\|$HOME/go/bin"; then
echo "Go workspace's \"bin\" directory is not in PATH. Run 'export PATH=\"\$PATH:\${GOPATH:-\$HOME/go}/bin\"'."
Expand Down
2 changes: 1 addition & 1 deletion pkg/test/expectations/expectations.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ limitations under the License.
package expectations

import (
. "github.com/onsi/gomega" //nolint:revive,stylecheck
. "github.com/onsi/gomega"
"github.com/samber/lo"
v1 "k8s.io/api/core/v1"

Expand Down
2 changes: 1 addition & 1 deletion test/pkg/debug/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"k8s.io/client-go/rest"
"sigs.k8s.io/controller-runtime/pkg/client"

. "github.com/onsi/gomega" //nolint:revive,stylecheck
. "github.com/onsi/gomega"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion test/pkg/environment/aws/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
"github.com/aws/aws-sdk-go/service/sts"
"github.com/aws/aws-sdk-go/service/timestreamwrite"
"github.com/aws/aws-sdk-go/service/timestreamwrite/timestreamwriteiface"
. "github.com/onsi/ginkgo/v2" //nolint:revive,stylecheck
. "github.com/onsi/ginkgo/v2"
"github.com/samber/lo"
"k8s.io/utils/env"

Expand Down
4 changes: 2 additions & 2 deletions test/pkg/environment/aws/expectations.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import (
"github.com/aws/aws-sdk-go/service/ssm"
"github.com/aws/aws-sdk-go/service/sts"
"github.com/mitchellh/hashstructure/v2"
. "github.com/onsi/ginkgo/v2" //nolint:revive,stylecheck
. "github.com/onsi/gomega" //nolint:revive,stylecheck
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/samber/lo"
"go.uber.org/multierr"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
4 changes: 2 additions & 2 deletions test/pkg/environment/aws/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
"github.com/aws/aws-sdk-go/aws/request"
"github.com/aws/aws-sdk-go/service/timestreamwrite"
"github.com/aws/aws-sdk-go/service/timestreamwrite/timestreamwriteiface"
. "github.com/onsi/ginkgo/v2" //nolint:revive,stylecheck
. "github.com/onsi/gomega" //nolint:revive,stylecheck
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/samber/lo"

"github.com/aws/karpenter/test/pkg/environment/common"
Expand Down
1 change: 0 additions & 1 deletion test/pkg/environment/aws/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ limitations under the License.
package aws

import (
//nolint:revive,stylecheck
v1 "k8s.io/api/core/v1"
"sigs.k8s.io/controller-runtime/pkg/client"

Expand Down
4 changes: 2 additions & 2 deletions test/pkg/environment/common/expectations.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"strings"
"time"

. "github.com/onsi/ginkgo/v2" //nolint:revive,stylecheck
. "github.com/onsi/gomega" //nolint:revive,stylecheck
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/samber/lo"
appsv1 "k8s.io/api/apps/v1"
coordinationv1 "k8s.io/api/coordination/v1"
Expand Down
4 changes: 2 additions & 2 deletions test/pkg/environment/common/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import (
"sync"
"time"

. "github.com/onsi/ginkgo/v2" //nolint:revive,stylecheck
. "github.com/onsi/gomega" //nolint:revive,stylecheck
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/samber/lo"
appsv1 "k8s.io/api/apps/v1"
v1 "k8s.io/api/core/v1"
Expand Down

0 comments on commit 48decff

Please sign in to comment.