Skip to content

Commit

Permalink
Switch to golangci-lint GH action
Browse files Browse the repository at this point in the history
Start using the golangci-lint github action and stop using
the check as part of the build jobs.

This way the version of the actions can be maintained by
dependabot, the version of golangci-lint can be updated in
the YAML and code in PRs can be annotated with issues.

It also reduces the load in the prow job slighlty, saving
a little infra cost.

Signed-off-by: Andrea Frittoli <andrea.frittoli@gmail.com>
  • Loading branch information
afrittoli committed Jan 10, 2025
1 parent aea48e1 commit 796261d
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 9 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/golangci-lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: golangci-lint
on:
push:
branches:
- main
pull_request:

permissions:
contents: read
checks: write # Used to annotate code in the PR

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
with:
go-version: stable
- name: golangci-lint
uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # v6.1.1
with:
version: v1.60
args: --timeout=10m
10 changes: 5 additions & 5 deletions pkg/reconciler/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package common

import (
"context"
"fmt"
"errors"
"strings"

"github.com/tektoncd/operator/pkg/apis/operator/v1alpha1"
Expand All @@ -39,15 +39,15 @@ func PipelineReady(informer informer.TektonPipelineInformer) (*v1alpha1.TektonPi
ppln, err := getPipelineRes(informer)
if err != nil {
if apierrors.IsNotFound(err) {
return nil, fmt.Errorf(PipelineNotFound)
return nil, errors.New(PipelineNotFound)
}
return nil, err
}
if ppln.GetStatus() != nil && strings.Contains(ppln.GetStatus().GetCondition(apis.ConditionReady).Message, v1alpha1.UpgradePending) {
return nil, v1alpha1.DEPENDENCY_UPGRADE_PENDING_ERR
}
if !ppln.Status.IsReady() {
return nil, fmt.Errorf(PipelineNotReady)
return nil, errors.New(PipelineNotReady)
}
return ppln, nil
}
Expand All @@ -72,15 +72,15 @@ func TriggerReady(informer informer.TektonTriggerInformer) (*v1alpha1.TektonTrig
trigger, err := getTriggerRes(informer)
if err != nil {
if apierrors.IsNotFound(err) {
return nil, fmt.Errorf(TriggerNotFound)
return nil, errors.New(TriggerNotFound)
}
return nil, err
}
if trigger.GetStatus() != nil && strings.Contains(trigger.GetStatus().GetCondition(apis.ConditionReady).Message, v1alpha1.UpgradePending) {
return nil, v1alpha1.DEPENDENCY_UPGRADE_PENDING_ERR
}
if !trigger.Status.IsReady() {
return nil, fmt.Errorf(TriggerNotReady)
return nil, errors.New(TriggerNotReady)
}
return trigger, nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/common/deadlockbreaker.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func isWebhookEndpointsActive(m *manifestival.Manifest, kc kubernetes.Interface,
}
return false, err
}
if endPoint.Subsets == nil || len(endPoint.Subsets) == 0 {
if len(endPoint.Subsets) == 0 {
return false, nil
}
return true, nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package client

import (
"context"
"errors"
"fmt"

mf "github.com/manifestival/manifestival"
Expand Down Expand Up @@ -113,7 +114,7 @@ func (i *InstallerSetClient) statusCheck(logger *zap.SugaredLogger, setType stri
if !ready.IsTrue() {
msg := fmt.Sprintf("%v/%v: installer set not ready, will retry: %v", i.resourceKind, setType, ready.Message)
logger.Debugf(msg)
return fmt.Errorf(msg)
return errors.New(msg)
}
}
return nil
Expand Down
3 changes: 2 additions & 1 deletion pkg/reconciler/platform/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package platform

import (
"errors"
"flag"
"fmt"
"log"
Expand Down Expand Up @@ -132,7 +133,7 @@ func validateConfig(pc *PlatformConfig) error {
if len(violations) == 0 {
return nil
}
return fmt.Errorf(strings.Join(violations, ","))
return errors.New(strings.Join(violations, ","))
}

// stringToControllerNamesSlice returns a []ControllerName
Expand Down
3 changes: 2 additions & 1 deletion test/presubmit-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ function check_yaml_lint() {
}

function post_build_tests() {
check_go_lint
# golangci-lint is executed now via GitHub actions
# check_go_lint
check_yaml_lint
}

Expand Down

0 comments on commit 796261d

Please sign in to comment.