incu6us / goimports-reviser

Right imports sorting & code formatting tool (goimports alternative)
MIT License
599 stars 72 forks source link

upgrade golang.org/x/mod package #135

Closed ozkansen closed 1 year ago

ozkansen commented 1 year ago

"go.mod toolchain error #134"

Patch to fix the related bug

incu6us commented 1 year ago

revert your last commit and do go mod tidy. it will fix the pipeline

codecov[bot] commented 1 year ago

Codecov Report

Merging #135 (a256ff9) into master (98d303d) will not change coverage. The diff coverage is n/a.

@@           Coverage Diff           @@
##           master     #135   +/-   ##
=======================================
  Coverage   90.06%   90.06%           
=======================================
  Files           8        8           
  Lines         624      624           
=======================================
  Hits          562      562           
  Misses         43       43           
  Partials       19       19           
Flag Coverage Δ
unittests 90.06% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

:loudspeaker: Have feedback on the report? Share it here.

ozkansen commented 1 year ago

revert your last commit and do go mod tidy. it will fix the pipeline

I just saw your comment, I solved it in my last commit. I can try your suggested solution if you want.

incu6us commented 1 year ago

go-pg should be removed. it will be fetched automatically on test pipeline. in other way it will be a rubbish on which other users will be dependent

ozkansen commented 1 year ago

I get error output when I run the test as below, is this normal?

Step 1:

go mod tidy

Step 2:

make go-test 
?       github.com/incu6us/goimports-reviser/v3 [no test files]
=== RUN   TestDetermineProjectName
=== PAUSE TestDetermineProjectName
=== CONT  TestDetermineProjectName
=== RUN   TestDetermineProjectName/success_with_manual_filepath
=== PAUSE TestDetermineProjectName/success_with_manual_filepath
=== RUN   TestDetermineProjectName/success_with_stdin
=== PAUSE TestDetermineProjectName/success_with_stdin
=== RUN   TestDetermineProjectName/fail_with_manual_filepath
=== PAUSE TestDetermineProjectName/fail_with_manual_filepath
=== CONT  TestDetermineProjectName/success_with_manual_filepath
=== CONT  TestDetermineProjectName/fail_with_manual_filepath
=== CONT  TestDetermineProjectName/success_with_stdin
--- PASS: TestDetermineProjectName (0.00s)
    --- PASS: TestDetermineProjectName/fail_with_manual_filepath (0.00s)
    --- PASS: TestDetermineProjectName/success_with_manual_filepath (0.00s)
    --- PASS: TestDetermineProjectName/success_with_stdin (0.00s)
PASS
coverage: 100.0% of statements
ok      github.com/incu6us/goimports-reviser/v3/helper  (cached)        coverage: 100.0% of statements
=== RUN   TestUsesImport
=== PAUSE TestUsesImport
=== RUN   TestLoadPackageDeps
=== PAUSE TestLoadPackageDeps
=== CONT  TestUsesImport
=== CONT  TestLoadPackageDeps
=== RUN   TestUsesImport/success_with_github.com/go-pg/pg/v9
=== RUN   TestLoadPackageDeps/success
=== PAUSE TestUsesImport/success_with_github.com/go-pg/pg/v9
=== PAUSE TestLoadPackageDeps/success
=== RUN   TestUsesImport/success_with_"pg2_github.com/go-pg/pg/v9"
=== RUN   TestLoadPackageDeps/success_with_deprecated_build_tag
=== PAUSE TestUsesImport/success_with_"pg2_github.com/go-pg/pg/v9"
=== RUN   TestUsesImport/success_with_strconv
=== PAUSE TestLoadPackageDeps/success_with_deprecated_build_tag
=== CONT  TestLoadPackageDeps/success
=== PAUSE TestUsesImport/success_with_strconv
=== RUN   TestUsesImport/success_without_ast
=== PAUSE TestUsesImport/success_without_ast
=== CONT  TestLoadPackageDeps/success_with_deprecated_build_tag
=== RUN   TestUsesImport/success_with_github.com/incu6us/goimports-reviser/testdata/innderpkg
=== PAUSE TestUsesImport/success_with_github.com/incu6us/goimports-reviser/testdata/innderpkg
=== RUN   TestUsesImport/success_with_unused_strconv
=== PAUSE TestUsesImport/success_with_unused_strconv
=== CONT  TestUsesImport/success_with_github.com/go-pg/pg/v9
=== CONT  TestUsesImport/success_without_ast
=== CONT  TestUsesImport/success_with_unused_strconv
=== CONT  TestUsesImport/success_with_strconv
=== CONT  TestUsesImport/success_with_github.com/incu6us/goimports-reviser/testdata/innderpkg
=== CONT  TestUsesImport/success_with_"pg2_github.com/go-pg/pg/v9"
--- PASS: TestUsesImport (0.00s)
    --- PASS: TestUsesImport/success_with_unused_strconv (0.00s)
    --- PASS: TestUsesImport/success_with_github.com/go-pg/pg/v9 (0.00s)
    --- PASS: TestUsesImport/success_without_ast (0.00s)
    --- PASS: TestUsesImport/success_with_strconv (0.00s)
    --- PASS: TestUsesImport/success_with_github.com/incu6us/goimports-reviser/testdata/innderpkg (0.00s)
    --- PASS: TestUsesImport/success_with_"pg2_github.com/go-pg/pg/v9" (0.00s)
--- PASS: TestLoadPackageDeps (0.00s)
    --- PASS: TestLoadPackageDeps/success (0.04s)
    --- PASS: TestLoadPackageDeps/success_with_deprecated_build_tag (0.04s)
PASS
coverage: 88.6% of statements
ok      github.com/incu6us/goimports-reviser/v3/pkg/astutil     (cached)        coverage: 88.6% of statements
?       github.com/incu6us/goimports-reviser/v3/pkg/std [no test files]
=== RUN   TestPathIsNotSetError_Error
=== PAUSE TestPathIsNotSetError_Error
=== RUN   TestUndefinedModuleError_Error
=== PAUSE TestUndefinedModuleError_Error
=== RUN   TestGoModRootPathAndName
=== PAUSE TestGoModRootPathAndName
=== RUN   TestName
=== PAUSE TestName
=== RUN   TestDetermineProjectName
=== PAUSE TestDetermineProjectName
=== CONT  TestPathIsNotSetError_Error
=== CONT  TestName
=== RUN   TestName/read_empty_go.mod
=== RUN   TestPathIsNotSetError_Error/success
=== CONT  TestGoModRootPathAndName
=== RUN   TestGoModRootPathAndName/success
=== PAUSE TestGoModRootPathAndName/success
=== RUN   TestGoModRootPathAndName/path_is_not_set_error
=== CONT  TestUndefinedModuleError_Error
=== RUN   TestUndefinedModuleError_Error/success
--- PASS: TestPathIsNotSetError_Error (0.00s)
    --- PASS: TestPathIsNotSetError_Error/success (0.00s)
=== PAUSE TestGoModRootPathAndName/path_is_not_set_error
=== RUN   TestGoModRootPathAndName/path_is_empty
--- PASS: TestUndefinedModuleError_Error (0.00s)
    --- PASS: TestUndefinedModuleError_Error/success (0.00s)
=== CONT  TestDetermineProjectName
=== PAUSE TestName/read_empty_go.mod
=== PAUSE TestGoModRootPathAndName/path_is_empty
=== RUN   TestName/check_failed_parsing_of_go.mod
=== PAUSE TestName/check_failed_parsing_of_go.mod
=== CONT  TestName/check_failed_parsing_of_go.mod
=== RUN   TestDetermineProjectName/success_with_auto_determining
=== CONT  TestGoModRootPathAndName/path_is_not_set_error
=== PAUSE TestDetermineProjectName/success_with_auto_determining
=== RUN   TestDetermineProjectName/success_with_manual_set
=== PAUSE TestDetermineProjectName/success_with_manual_set
=== CONT  TestGoModRootPathAndName/success
=== CONT  TestName/read_empty_go.mod
=== CONT  TestDetermineProjectName/success_with_manual_set
=== CONT  TestGoModRootPathAndName/path_is_empty
=== CONT  TestDetermineProjectName/success_with_auto_determining
--- PASS: TestDetermineProjectName (0.00s)
    --- PASS: TestDetermineProjectName/success_with_manual_set (0.00s)
    --- PASS: TestDetermineProjectName/success_with_auto_determining (0.00s)
--- PASS: TestGoModRootPathAndName (0.00s)
    --- PASS: TestGoModRootPathAndName/path_is_not_set_error (0.00s)
    --- PASS: TestGoModRootPathAndName/path_is_empty (0.00s)
    --- PASS: TestGoModRootPathAndName/success (0.00s)
--- PASS: TestName (0.00s)
    --- PASS: TestName/read_empty_go.mod (0.00s)
    --- PASS: TestName/check_failed_parsing_of_go.mod (0.00s)
PASS
coverage: 93.8% of statements
ok      github.com/incu6us/goimports-reviser/v3/pkg/module      (cached)        coverage: 93.8% of statements
=== RUN   TestNewSourceDir
=== RUN   TestNewSourceDir/should_generate_source_dir_from_recursive_path
--- PASS: TestNewSourceDir (0.00s)
    --- PASS: TestNewSourceDir/should_generate_source_dir_from_recursive_path (0.00s)
=== RUN   TestSourceDir_Fix
=== RUN   TestSourceDir_Fix/exclude-file
=== RUN   TestSourceDir_Fix/exclude-dir
=== RUN   TestSourceDir_Fix/exclude-file-*
=== RUN   TestSourceDir_Fix/exclude-file-?
=== RUN   TestSourceDir_Fix/exclude-file-multi
=== RUN   TestSourceDir_Fix/not-exclude
--- PASS: TestSourceDir_Fix (0.00s)
    --- PASS: TestSourceDir_Fix/exclude-file (0.00s)
    --- PASS: TestSourceDir_Fix/exclude-dir (0.00s)
    --- PASS: TestSourceDir_Fix/exclude-file-* (0.00s)
    --- PASS: TestSourceDir_Fix/exclude-file-? (0.00s)
    --- PASS: TestSourceDir_Fix/exclude-file-multi (0.00s)
    --- PASS: TestSourceDir_Fix/not-exclude (0.00s)
=== RUN   TestSourceDir_IsExcluded
=== RUN   TestSourceDir_IsExcluded/normal
=== RUN   TestSourceDir_IsExcluded/dir
=== RUN   TestSourceDir_IsExcluded/wildcard-1
=== RUN   TestSourceDir_IsExcluded/wildcard-2
=== RUN   TestSourceDir_IsExcluded/not-excluded
=== RUN   TestSourceDir_IsExcluded/multi-excludes
--- PASS: TestSourceDir_IsExcluded (0.00s)
    --- PASS: TestSourceDir_IsExcluded/normal (0.00s)
    --- PASS: TestSourceDir_IsExcluded/dir (0.00s)
    --- PASS: TestSourceDir_IsExcluded/wildcard-1 (0.00s)
    --- PASS: TestSourceDir_IsExcluded/wildcard-2 (0.00s)
    --- PASS: TestSourceDir_IsExcluded/not-excluded (0.00s)
    --- PASS: TestSourceDir_IsExcluded/multi-excludes (0.00s)
=== RUN   TestSourceFile_Fix
=== RUN   TestSourceFile_Fix/success_with_comments
=== RUN   TestSourceFile_Fix/success_with_auto-generated
=== RUN   TestSourceFile_Fix/success_with_auto-generated#01
=== RUN   TestSourceFile_Fix/success_with_directive
=== RUN   TestSourceFile_Fix/success_with_std_&_project_deps
=== RUN   TestSourceFile_Fix/success_with_std_&_third-party_deps
=== RUN   TestSourceFile_Fix/success_with_std_deps_only
=== RUN   TestSourceFile_Fix/success_with_third-party_deps_only
=== RUN   TestSourceFile_Fix/success_with_project_deps_only
=== RUN   TestSourceFile_Fix/success_with_clear_doc_for_import
=== RUN   TestSourceFile_Fix/success_with_comment_for_import
=== RUN   TestSourceFile_Fix/success_with_no_changes
=== RUN   TestSourceFile_Fix/success_no_changes_by_imports_and_comments
=== RUN   TestSourceFile_Fix/success_with_multiple_import_statements
=== RUN   TestSourceFile_Fix/preserves_cgo_import
=== RUN   TestSourceFile_Fix/preserves_cgo_import_even_when_reordering
=== RUN   TestSourceFile_Fix/try_to_read_from_stdin
=== RUN   TestSourceFile_Fix/error_with_non-existent_file
--- PASS: TestSourceFile_Fix (0.01s)
    --- PASS: TestSourceFile_Fix/success_with_comments (0.00s)
    --- PASS: TestSourceFile_Fix/success_with_auto-generated (0.00s)
    --- PASS: TestSourceFile_Fix/success_with_auto-generated#01 (0.00s)
    --- PASS: TestSourceFile_Fix/success_with_directive (0.00s)
    --- PASS: TestSourceFile_Fix/success_with_std_&_project_deps (0.00s)
    --- PASS: TestSourceFile_Fix/success_with_std_&_third-party_deps (0.00s)
    --- PASS: TestSourceFile_Fix/success_with_std_deps_only (0.00s)
    --- PASS: TestSourceFile_Fix/success_with_third-party_deps_only (0.00s)
    --- PASS: TestSourceFile_Fix/success_with_project_deps_only (0.00s)
    --- PASS: TestSourceFile_Fix/success_with_clear_doc_for_import (0.00s)
    --- PASS: TestSourceFile_Fix/success_with_comment_for_import (0.00s)
    --- PASS: TestSourceFile_Fix/success_with_no_changes (0.00s)
    --- PASS: TestSourceFile_Fix/success_no_changes_by_imports_and_comments (0.00s)
    --- PASS: TestSourceFile_Fix/success_with_multiple_import_statements (0.00s)
    --- PASS: TestSourceFile_Fix/preserves_cgo_import (0.00s)
    --- PASS: TestSourceFile_Fix/preserves_cgo_import_even_when_reordering (0.00s)
    --- PASS: TestSourceFile_Fix/try_to_read_from_stdin (0.00s)
    --- PASS: TestSourceFile_Fix/error_with_non-existent_file (0.00s)
=== RUN   TestSourceFile_Fix_WithImportsOrder
=== RUN   TestSourceFile_Fix_WithImportsOrder/success_with_default_order
=== RUN   TestSourceFile_Fix_WithImportsOrder/success_std,general,company,project
=== RUN   TestSourceFile_Fix_WithImportsOrder/success_project,company,general,std
--- PASS: TestSourceFile_Fix_WithImportsOrder (0.00s)
    --- PASS: TestSourceFile_Fix_WithImportsOrder/success_with_default_order (0.00s)
    --- PASS: TestSourceFile_Fix_WithImportsOrder/success_std,general,company,project (0.00s)
    --- PASS: TestSourceFile_Fix_WithImportsOrder/success_project,company,general,std (0.00s)
=== RUN   TestSourceFile_Fix_WithRemoveUnusedImports
=== RUN   TestSourceFile_Fix_WithRemoveUnusedImports/remove_unused_import
=== RUN   TestSourceFile_Fix_WithRemoveUnusedImports/remove_unused_import_with_alias
=== RUN   TestSourceFile_Fix_WithRemoveUnusedImports/use_loaded_import_but_not_used
=== RUN   TestSourceFile_Fix_WithRemoveUnusedImports/success_with_comments_before_imports
=== RUN   TestSourceFile_Fix_WithRemoveUnusedImports/success_without_imports
=== RUN   TestSourceFile_Fix_WithRemoveUnusedImports/cleanup_empty_import_block
=== RUN   TestSourceFile_Fix_WithRemoveUnusedImports/success_with_"C"
--- PASS: TestSourceFile_Fix_WithRemoveUnusedImports (0.21s)
    --- PASS: TestSourceFile_Fix_WithRemoveUnusedImports/remove_unused_import (0.04s)
    --- PASS: TestSourceFile_Fix_WithRemoveUnusedImports/remove_unused_import_with_alias (0.03s)
    --- PASS: TestSourceFile_Fix_WithRemoveUnusedImports/use_loaded_import_but_not_used (0.03s)
    --- PASS: TestSourceFile_Fix_WithRemoveUnusedImports/success_with_comments_before_imports (0.03s)
    --- PASS: TestSourceFile_Fix_WithRemoveUnusedImports/success_without_imports (0.03s)
    --- PASS: TestSourceFile_Fix_WithRemoveUnusedImports/cleanup_empty_import_block (0.03s)
    --- PASS: TestSourceFile_Fix_WithRemoveUnusedImports/success_with_"C" (0.03s)
=== RUN   TestSourceFile_Fix_WithAliasForVersionSuffix
=== RUN   TestSourceFile_Fix_WithAliasForVersionSuffix/success_with_set_alias
example.go:4:2: no required module provides package github.com/go-pg/pg/v9; to add it:
        go get github.com/go-pg/pg/v9
    file_test.go:1171: 
                Error Trace:    file_test.go:1171
                Error:          Received unexpected error:
                                package has an errors
                Test:           TestSourceFile_Fix_WithAliasForVersionSuffix/success_with_set_alias
    file_test.go:1172: 
                Error Trace:    file_test.go:1172
                Error:          Not equal: 
                                expected: true
                                actual  : false
                Test:           TestSourceFile_Fix_WithAliasForVersionSuffix/success_with_set_alias
    file_test.go:1173: 
                Error Trace:    file_test.go:1173
                Error:          Not equal: 
                                expected: "package testdata\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n\n\tpg \"github.com/go-pg/pg/v9\"\n)\n\nfunc main() {\n\t_ = strconv.Itoa(1)\n\tfmt.Println(pg.In([]string{\"test\"}))\n}\n"
                                actual  : ""

                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -1,14 +1 @@
                                -package testdata

                                -import (
                                -       "fmt"
                                -       "strconv"
                                -
                                -       pg "github.com/go-pg/pg/v9"
                                -)
                                -
                                -func main() {
                                -       _ = strconv.Itoa(1)
                                -       fmt.Println(pg.In([]string{"test"}))
                                -}
                                -
                Test:           TestSourceFile_Fix_WithAliasForVersionSuffix/success_with_set_alias
=== RUN   TestSourceFile_Fix_WithAliasForVersionSuffix/success_with_golang.org/x/exp/slices
=== RUN   TestSourceFile_Fix_WithAliasForVersionSuffix/success_with_"C"
--- FAIL: TestSourceFile_Fix_WithAliasForVersionSuffix (0.09s)
    --- FAIL: TestSourceFile_Fix_WithAliasForVersionSuffix/success_with_set_alias (0.03s)
    --- PASS: TestSourceFile_Fix_WithAliasForVersionSuffix/success_with_golang.org/x/exp/slices (0.03s)
    --- PASS: TestSourceFile_Fix_WithAliasForVersionSuffix/success_with_"C" (0.03s)
=== RUN   TestSourceFile_Fix_WithLocalPackagePrefixes
=== RUN   TestSourceFile_Fix_WithLocalPackagePrefixes/group_local_packages
=== RUN   TestSourceFile_Fix_WithLocalPackagePrefixes/group_local_packages#01
=== RUN   TestSourceFile_Fix_WithLocalPackagePrefixes/group_local_packages_separately_from_project_files
=== RUN   TestSourceFile_Fix_WithLocalPackagePrefixes/check_without_local_packages
--- PASS: TestSourceFile_Fix_WithLocalPackagePrefixes (0.00s)
    --- PASS: TestSourceFile_Fix_WithLocalPackagePrefixes/group_local_packages (0.00s)
    --- PASS: TestSourceFile_Fix_WithLocalPackagePrefixes/group_local_packages#01 (0.00s)
    --- PASS: TestSourceFile_Fix_WithLocalPackagePrefixes/group_local_packages_separately_from_project_files (0.00s)
    --- PASS: TestSourceFile_Fix_WithLocalPackagePrefixes/check_without_local_packages (0.00s)
=== RUN   TestSourceFile_Fix_WithFormat
=== RUN   TestSourceFile_Fix_WithFormat/success
=== RUN   TestSourceFile_Fix_WithFormat/success_with_comments
--- PASS: TestSourceFile_Fix_WithFormat (0.00s)
    --- PASS: TestSourceFile_Fix_WithFormat/success (0.00s)
    --- PASS: TestSourceFile_Fix_WithFormat/success_with_comments (0.00s)
=== RUN   TestSourceFile_Fix_WithSkipGeneratedFile
=== RUN   TestSourceFile_Fix_WithSkipGeneratedFile/success_with_generated_file
=== RUN   TestSourceFile_Fix_WithSkipGeneratedFile/success_with_generated_file#01
=== RUN   TestSourceFile_Fix_WithSkipGeneratedFile/success_with_generated_file#02
=== RUN   TestSourceFile_Fix_WithSkipGeneratedFile/success_with_generated_file#03
=== RUN   TestSourceFile_Fix_WithSkipGeneratedFile/success_with_generated_file#04
=== RUN   TestSourceFile_Fix_WithSkipGeneratedFile/success_with_generated_file#05
=== RUN   TestSourceFile_Fix_WithSkipGeneratedFile/success_with_generated_file#06
=== RUN   TestSourceFile_Fix_WithSkipGeneratedFile/success_with_generated_file#07
--- PASS: TestSourceFile_Fix_WithSkipGeneratedFile (0.00s)
    --- PASS: TestSourceFile_Fix_WithSkipGeneratedFile/success_with_generated_file (0.00s)
    --- PASS: TestSourceFile_Fix_WithSkipGeneratedFile/success_with_generated_file#01 (0.00s)
    --- PASS: TestSourceFile_Fix_WithSkipGeneratedFile/success_with_generated_file#02 (0.00s)
    --- PASS: TestSourceFile_Fix_WithSkipGeneratedFile/success_with_generated_file#03 (0.00s)
    --- PASS: TestSourceFile_Fix_WithSkipGeneratedFile/success_with_generated_file#04 (0.00s)
    --- PASS: TestSourceFile_Fix_WithSkipGeneratedFile/success_with_generated_file#05 (0.00s)
    --- PASS: TestSourceFile_Fix_WithSkipGeneratedFile/success_with_generated_file#06 (0.00s)
    --- PASS: TestSourceFile_Fix_WithSkipGeneratedFile/success_with_generated_file#07 (0.00s)
=== RUN   TestStringToImportsOrder
=== PAUSE TestStringToImportsOrder
=== CONT  TestStringToImportsOrder
=== RUN   TestStringToImportsOrder/invalid_groups_count
=== PAUSE TestStringToImportsOrder/invalid_groups_count
=== RUN   TestStringToImportsOrder/unknown_group
=== PAUSE TestStringToImportsOrder/unknown_group
=== CONT  TestStringToImportsOrder/invalid_groups_count
=== CONT  TestStringToImportsOrder/unknown_group
--- PASS: TestStringToImportsOrder (0.00s)
    --- PASS: TestStringToImportsOrder/invalid_groups_count (0.00s)
    --- PASS: TestStringToImportsOrder/unknown_group (0.00s)
FAIL
coverage: 95.0% of statements
FAIL    github.com/incu6us/goimports-reviser/v3/reviser 0.586s
FAIL
make: *** [go-test] Error 1
incu6us commented 1 year ago

it is fine for local testing

incu6us commented 1 year ago

np. merging the PR