From 72d50fee2fe61b4b928217cb421bf0fb4c82d953 Mon Sep 17 00:00:00 2001 From: Theofanis Petkos Date: Thu, 23 Jan 2025 14:27:56 +0000 Subject: [PATCH] Upgrade go version to 1.23 (#157) * Upgrade go to 1.23 Signed-off-by: thepetk * Fix linting tool Signed-off-by: thepetk * Update gosec Signed-off-by: thepetk * Update upload-artifact Signed-off-by: thepetk --------- Signed-off-by: thepetk --- .github/workflows/scorecard.yml | 2 +- Makefile | 5 ++--- go.mod | 2 +- test/apis/component_recognizer_test.go | 8 ++++---- test/apis/language_recognizer_test.go | 2 +- test/apis/utils.go | 8 ++++---- 6 files changed, 13 insertions(+), 14 deletions(-) diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml index b93f2950..9b850714 100644 --- a/.github/workflows/scorecard.yml +++ b/.github/workflows/scorecard.yml @@ -45,7 +45,7 @@ jobs: # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF # format to the repository Actions tab. - name: "Upload artifact" - uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0 + uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0 with: name: SARIF file path: results.sarif diff --git a/Makefile b/Makefile index 49faa147..fd3076ef 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ check_registry: ## Run registry checks .PHONY: gosec_install gosec_install: ## Install gosec utility - go install github.com/securego/gosec/v2/cmd/gosec@v2.14.0 + go install github.com/securego/gosec/v2/cmd/gosec@v2.22.0 .PHONY: gosec gosec: ## Run go security checks @@ -40,5 +40,4 @@ lint: ## Run golangci-lint linter tool .PHONY: lint_install lint_install: ## Install golangci-lint linter tool - @# TODO(rm3l): recent versions of golangci-lint require Go >= 1.20. Update when we start using Go 1.20+ - go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.53.3 + go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.63.4 diff --git a/go.mod b/go.mod index 87395d02..78a5f651 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/devfile/alizer -go 1.21 +go 1.23 require ( github.com/go-git/go-git/v5 v5.13.1 diff --git a/test/apis/component_recognizer_test.go b/test/apis/component_recognizer_test.go index f3d23ec0..bee75fc8 100644 --- a/test/apis/component_recognizer_test.go +++ b/test/apis/component_recognizer_test.go @@ -361,7 +361,7 @@ func TestPortDetectionFlaskStringValue(t *testing.T) { func TestComponentDetectionNoResult(t *testing.T) { components := getComponentsFromTestProject(t, "simple") if len(components) > 0 { - t.Errorf("Expected 0 components but found " + strconv.Itoa(len(components))) + t.Errorf("Expected 0 components but found %v", strconv.Itoa(len(components))) } } @@ -395,7 +395,7 @@ func TestComponentDetectionWithGitIgnoreRule(t *testing.T) { components := getComponentsFromFiles(t, files, settings) if len(components) != 1 { - t.Errorf("Expected 1 components but found " + strconv.Itoa(len(components))) + t.Errorf("Expected 1 components but found %v", strconv.Itoa(len(components))) } //now add a gitIgnore with a rule to exclude the only component found @@ -413,7 +413,7 @@ func TestComponentDetectionWithGitIgnoreRule(t *testing.T) { os.Remove(gitIgnorePath) if len(componentsWithUpdatedGitIgnore) != 0 { - t.Errorf("Expected 0 components but found " + strconv.Itoa(len(componentsWithUpdatedGitIgnore))) + t.Errorf("Expected 0 components but found %v", strconv.Itoa(len(componentsWithUpdatedGitIgnore))) } } @@ -421,7 +421,7 @@ func TestComponentDetectionMultiProjects(t *testing.T) { components := getComponentsFromTestProject(t, "") nComps := 70 if len(components) != nComps { - t.Errorf("Expected " + strconv.Itoa(nComps) + " components but found " + strconv.Itoa(len(components))) + t.Errorf("Expected %v components but found %v", strconv.Itoa(nComps), strconv.Itoa(len(components))) } } diff --git a/test/apis/language_recognizer_test.go b/test/apis/language_recognizer_test.go index ff33518d..ed8b1920 100644 --- a/test/apis/language_recognizer_test.go +++ b/test/apis/language_recognizer_test.go @@ -63,7 +63,7 @@ func isLanguageInProject(t *testing.T, project string, wantedLanguage string, wa } if !hasWantedLanguage(languages, wantedLanguage, wantedTools, wantedFrameworks) { - t.Errorf("Project does not use " + wantedLanguage + " language") + t.Errorf("Project does not use %v language", wantedLanguage) } } diff --git a/test/apis/utils.go b/test/apis/utils.go index 927633ce..120f4d00 100644 --- a/test/apis/utils.go +++ b/test/apis/utils.go @@ -61,16 +61,16 @@ func verifyComponents(t *testing.T, components []model.Component, expectedNumber if hasComponents { isExpectedComponent := strings.EqualFold(expectedLanguage, components[0].Languages[0].Name) if !isExpectedComponent { - t.Errorf("Project does not use " + expectedLanguage + " language") + t.Errorf("Project does not use %v language ", expectedLanguage) } if expectedProjectName != "" { isExpectedProjectName := strings.EqualFold(expectedProjectName, components[0].Name) if !isExpectedProjectName { - t.Errorf("Main component has a different project name. Expected " + expectedProjectName + " but it was " + components[0].Name) + t.Errorf("Main component has a different project name. Expected %v but it was %v", expectedProjectName, components[0].Name) } } } else { - t.Errorf("Expected " + strconv.Itoa(expectedNumber) + " of components but it was " + strconv.Itoa(len(components))) + t.Errorf("Expected %v of components but it was %v", strconv.Itoa(expectedNumber), strconv.Itoa(len(components))) } } @@ -94,7 +94,7 @@ func testPortDetectionInProject(t *testing.T, project string, ports []int) { } } if !found { - t.Errorf("Port " + strconv.Itoa(port) + " have not been detected") + t.Errorf("Port %v have not been detected", strconv.Itoa(port)) } found = false }