From 8223ca40e8fa7267953bf1002f6e044257c99bb1 Mon Sep 17 00:00:00 2001 From: Ichinose Shogo Date: Tue, 25 May 2021 09:14:01 +0900 Subject: [PATCH 1/6] bump x/mod and x/tools --- go.mod | 4 ++-- go.sum | 25 ++++++++++++++++--------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/go.mod b/go.mod index 5df3897..661fe67 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,6 @@ module github.com/mattn/goveralls go 1.11 require ( - golang.org/x/mod v0.2.0 - golang.org/x/tools v0.0.0-20200522201501-cb1345f3a375 + golang.org/x/mod v0.4.2 + golang.org/x/tools v0.1.1 ) diff --git a/go.sum b/go.sum index 948410c..9ba29a2 100644 --- a/go.sum +++ b/go.sum @@ -1,20 +1,27 @@ -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/mod v0.2.0 h1:KU7oHjnv3XNWfa5COkzUifxZmxp1TyI7ImMXqFxLwvQ= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo= +golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007 h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200522201501-cb1345f3a375 h1:SjQ2+AKWgZLc1xej6WSzL+Dfs5Uyd5xcZH1mGC411IA= -golang.org/x/tools v0.0.0-20200522201501-cb1345f3a375/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.1.1 h1:wGiQel/hW0NnEkJUk8lbzkX2gFJU6PFxf1v5OlCfuOs= +golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= From e0fd5381384463de22b7e4e619d623c6cb210953 Mon Sep 17 00:00:00 2001 From: Ichinose Shogo Date: Tue, 25 May 2021 09:15:43 +0900 Subject: [PATCH 2/6] `%w` verb is introduced from Go 1.13 --- gocover.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gocover.go b/gocover.go index c51bfb0..912a6c3 100644 --- a/gocover.go +++ b/gocover.go @@ -115,7 +115,7 @@ func mergeTwoProfBlock(left, right []cover.ProfileBlock) []cover.ProfileBlock { func toSF(profs []*cover.Profile) ([]*SourceFile, error) { rootDirectory, err := os.Getwd() if err != nil { - return nil, fmt.Errorf("get working dir: %w", err) + return nil, fmt.Errorf("get working dir: %v", err) } modPath := filepath.Join(rootDirectory, "go.mod") rootPackage := "" @@ -167,7 +167,7 @@ func parseCover(fn string) ([]*SourceFile, error) { for _, p := range strings.Split(fn, ",") { profs, err := cover.ParseProfiles(p) if err != nil { - return nil, fmt.Errorf("Error parsing coverage: %v", err) + return nil, fmt.Errorf("error parsing coverage: %v", err) } pfss = append(pfss, profs) } From b20196ba41f32ea7e33c0fb1889da556cbec2c60 Mon Sep 17 00:00:00 2001 From: Ichinose Shogo Date: Tue, 25 May 2021 09:26:55 +0900 Subject: [PATCH 3/6] add fallback for Go 1.7 x/mod/modfile is available from Go 1.8 --- gocover.go | 9 +++------ gocover_ge1.8.go | 19 +++++++++++++++++++ gocover_lt1.8.go | 14 ++++++++++++++ 3 files changed, 36 insertions(+), 6 deletions(-) create mode 100644 gocover_ge1.8.go create mode 100644 gocover_lt1.8.go diff --git a/gocover.go b/gocover.go index 912a6c3..ecd1b5d 100644 --- a/gocover.go +++ b/gocover.go @@ -16,7 +16,6 @@ import ( "path/filepath" "strings" - "golang.org/x/mod/modfile" "golang.org/x/tools/cover" ) @@ -113,15 +112,13 @@ func mergeTwoProfBlock(left, right []cover.ProfileBlock) []cover.ProfileBlock { // toSF converts profiles to sourcefiles for coveralls. func toSF(profs []*cover.Profile) ([]*SourceFile, error) { + // find root package to reduce build.Import calls when importing files from relative root + // https://github.com/mattn/goveralls/pull/195 rootDirectory, err := os.Getwd() if err != nil { return nil, fmt.Errorf("get working dir: %v", err) } - modPath := filepath.Join(rootDirectory, "go.mod") - rootPackage := "" - if content, err := ioutil.ReadFile(modPath); err == nil { - rootPackage = modfile.ModulePath(content) - } + rootPackage := findRootPackage(rootDirectory) var rv []*SourceFile for _, prof := range profs { diff --git a/gocover_ge1.8.go b/gocover_ge1.8.go new file mode 100644 index 0000000..4b880a5 --- /dev/null +++ b/gocover_ge1.8.go @@ -0,0 +1,19 @@ +// +build go1.8 + +package main + +import ( + "io/ioutil" + "path/filepath" + + "golang.org/x/mod/modfile" +) + +func findRootPackage(rootDirectory string) string { + modPath := filepath.Join(rootDirectory, "go.mod") + content, err := ioutil.ReadFile(modPath) + if err != nil { + return "" + } + return modfile.ModulePath(content) +} diff --git a/gocover_lt1.8.go b/gocover_lt1.8.go new file mode 100644 index 0000000..4327c16 --- /dev/null +++ b/gocover_lt1.8.go @@ -0,0 +1,14 @@ +// +build !go1.8 + +package main + +import ( + "io/ioutil" + "path/filepath" + + "golang.org/x/mod/modfile" +) + +func findRootPackage(rootDirectory string) string { + return "" +} From e0d4527b3b7fcf9e1d994551409e1149c2e3049c Mon Sep 17 00:00:00 2001 From: Ichinose Shogo Date: Tue, 25 May 2021 09:30:09 +0900 Subject: [PATCH 4/6] skip go get --- .github/workflows/main.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 60a332c..bd8df91 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -36,7 +36,6 @@ jobs: ref: ${{ github.event.pull_request.head.sha }} - name: build run: | - go get ./... go install . working-directory: src/github.com/mattn/goveralls - name: test From 5935d57ecb097fdc0c24c04d38aec0baf21f2625 Mon Sep 17 00:00:00 2001 From: Ichinose Shogo Date: Tue, 25 May 2021 09:30:43 +0900 Subject: [PATCH 5/6] remove unused imports --- gocover_lt1.8.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/gocover_lt1.8.go b/gocover_lt1.8.go index 4327c16..263306e 100644 --- a/gocover_lt1.8.go +++ b/gocover_lt1.8.go @@ -2,13 +2,6 @@ package main -import ( - "io/ioutil" - "path/filepath" - - "golang.org/x/mod/modfile" -) - func findRootPackage(rootDirectory string) string { return "" } From eab9c9172c1f27b3f523e3f0315be3418b6c38b3 Mon Sep 17 00:00:00 2001 From: Ichinose Shogo Date: Tue, 25 May 2021 09:31:58 +0900 Subject: [PATCH 6/6] Revert "skip go get" This reverts commit e0d4527b3b7fcf9e1d994551409e1149c2e3049c. --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bd8df91..60a332c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -36,6 +36,7 @@ jobs: ref: ${{ github.event.pull_request.head.sha }} - name: build run: | + go get ./... go install . working-directory: src/github.com/mattn/goveralls - name: test