From 028b724901ea8dc578cb47d86b9fe29d833aa6b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Garc=C3=ADa=20Crespo?= Date: Thu, 2 May 2024 04:18:25 +0000 Subject: [PATCH 1/3] Add golangci-lint job in CI --- .github/workflows/test.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 21d631ad3..f02f93bd1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,6 +5,35 @@ on: permissions: contents: read jobs: + golangci-lint: + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v4 + - name: Install Go + uses: actions/setup-go@v5 + with: + go-version-file: hack/ccp/go.mod + cache-dependency-path: hack/ccp/go.sum + - name: Get date + id: get-date + shell: bash + run: | + echo "::set-output name=date::$(date -u "+%Y-%m")" + - name: Restore golangci-lint cache + uses: actions/cache@v4 + timeout-minutes: 10 + continue-on-error: true + with: + path: ${{ runner.temp }}/golangci-lint-cache + key: ${{ runner.os }}-golangci-lint-cache-${{ steps.get-date.outputs.date }} + restore-keys: | + ${{ runner.os }}-golangci-lint-cache- + - name: Run golangci-lint + run: make lint + env: + GOLANGCI_LINT_CACHE: ${{ runner.temp }}/golangci-lint-cache + working-directory: hack/ccp test: name: Test strategy: From 88582413fc9c129bb3575c0ccc050b6870f7daea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Garc=C3=ADa=20Crespo?= Date: Thu, 2 May 2024 04:22:37 +0000 Subject: [PATCH 2/3] Disable unused linter temporarily --- hack/ccp/.golangci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hack/ccp/.golangci.yml b/hack/ccp/.golangci.yml index f312822a6..3163d1a64 100644 --- a/hack/ccp/.golangci.yml +++ b/hack/ccp/.golangci.yml @@ -8,6 +8,10 @@ linters: - gci - unparam - gosec + disable: + # There is too much WIP code at the moment. + # TODO: enable this ASAP. + - unused issues: exclude-dirs: From 6de92c0dd59ae694c6c489421611357685dd70b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Garc=C3=ADa=20Crespo?= Date: Thu, 2 May 2024 04:22:54 +0000 Subject: [PATCH 3/3] Fix some linting issues --- hack/ccp/internal/controller/jobs.go | 8 ++++---- hack/ccp/internal/controller/task.go | 4 +--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/hack/ccp/internal/controller/jobs.go b/hack/ccp/internal/controller/jobs.go index 756b17b22..8f167b27a 100644 --- a/hack/ccp/internal/controller/jobs.go +++ b/hack/ccp/internal/controller/jobs.go @@ -193,7 +193,7 @@ func (l *outputDecisionJob) exec(ctx context.Context) (uuid.UUID, error) { panic("not implemented") - return uuid.Nil, nil + return uuid.Nil, nil // nolint: govet } // nextChainDecisionJob. @@ -488,7 +488,7 @@ func (l *updateContextDecisionJob) await(ctx context.Context, opts []option) (_ return uuid.Nil, err } - decision, err := l.j.pkg.AwaitDecision(ctx, opts) + decision, err := l.j.pkg.AwaitDecision(ctx, opts) // nolint: staticcheck if err != nil { return uuid.Nil, err } @@ -498,7 +498,7 @@ func (l *updateContextDecisionJob) await(ctx context.Context, opts []option) (_ panic("not implemented") - return decision.uuid(), nil + return decision.uuid(), nil // nolint: govet } // directoryClientScriptJob. @@ -736,7 +736,7 @@ func (l *outputClientScriptJob) exec(ctx context.Context) (uuid.UUID, error) { panic("not implemented") - return uuid.Nil, nil + return uuid.Nil, nil // nolint: govet } // setUnitVarLinkJob is a local job that sets the unit variable configured in diff --git a/hack/ccp/internal/controller/task.go b/hack/ccp/internal/controller/task.go index 5a799a6b8..dfef8bcd3 100644 --- a/hack/ccp/internal/controller/task.go +++ b/hack/ccp/internal/controller/task.go @@ -32,7 +32,7 @@ func newTaskBackend(logger logr.Logger, job *job, config *workflow.LinkStandardT } } -func (b *taskBackend) submit(pCtx *packageContext, args string, wantsOutput bool, stdoutFilePath, stderrFilePath string) uuid.UUID { +func (b *taskBackend) submit(pCtx *packageContext, args string, wantsOutput bool, stdoutFilePath, stderrFilePath string) { t := &task{ ID: uuid.New(), CreatedAt: time.Now().UTC(), @@ -47,8 +47,6 @@ func (b *taskBackend) submit(pCtx *packageContext, args string, wantsOutput bool } b.tasks.Tasks[t.ID] = t - - return t.ID } func (b *taskBackend) wait(ctx context.Context) (*taskResults, error) {