Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-v0.74.x] Switch to golangci-lint GH action #2506

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/bump-payload-on-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
bump-payloads:
name: "Bump payloads"
runs-on: ubuntu-latest
if: github.repository_owner == 'tektoncd' # do not run this elsewhere
if: github.repository_owner == 'tektoncd' # do not run this elsewhere
steps:
- uses: actions/setup-go@v5
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/bump-payload-on-releases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on: # yamllint disable-line rule:truthy
jobs:
build-release-matrix:
runs-on: ubuntu-latest
if: github.repository_owner == 'tektoncd' # do not run this elsewhere
if: github.repository_owner == 'tektoncd' # do not run this elsewhere
steps:
- id: set-matrix
run: |
Expand Down
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: # yamllint disable-line rule:truthy
push:
branches:
- main
pull_request: # yamllint disable-line rule:empty-values

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
2 changes: 1 addition & 1 deletion .github/workflows/helm-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
permissions:
contents: write
runs-on: ubuntu-latest
if: github.repository_owner == 'tektoncd' # do not run this elsewhere
if: github.repository_owner == 'tektoncd' # do not run this elsewhere
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
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
5 changes: 3 additions & 2 deletions test/presubmit-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function check_go_lint() {
function check_yaml_lint() {
header "Testing if yamllint has been done"

local YAML_FILES=$(find . -path ./vendor -prune -o -type f -regex ".*y[a]ml" -print)
local YAML_FILES=$(find . \( -path ./vendor -prune \) -o \( -type d -name testdata -prune \) -o -type f -regex ".*y[a]ml" -print)
yamllint -c .yamllint ${YAML_FILES}

if [[ $? != 0 ]]; then
Expand All @@ -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
Loading