From 1892fcc9f7ef74a0726268870ce4fc679b5bd0d4 Mon Sep 17 00:00:00 2001 From: Christian Weichel Date: Fri, 24 May 2024 09:04:41 +0000 Subject: [PATCH] Make LEEWAY_WORKSPACE_ROOT available in build commands allows to reference a golangci-lint config in the linter command --- pkg/leeway/build.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/leeway/build.go b/pkg/leeway/build.go index 15b15a2..c0aa3c3 100644 --- a/pkg/leeway/build.go +++ b/pkg/leeway/build.go @@ -1265,7 +1265,7 @@ func (p *Package) buildGo(buildctx *buildContext, wd, result string) (res *packa testCommand = append(testCommand, fmt.Sprintf("-coverprofile=%v", codecovComponentName(p.FullName()))) } else { testCommand = append(testCommand, "-coverprofile=testcoverage.out") - reportCoverage = collectGoTestCoverage(filepath.Join(wd, "testcoverage.out"), p.FullName()) + reportCoverage = collectGoTestCoverage(filepath.Join(wd, "testcoverage.out")) } testCommand = append(testCommand, "./...") @@ -1300,7 +1300,7 @@ func (p *Package) buildGo(buildctx *buildContext, wd, result string) (res *packa }, nil } -func collectGoTestCoverage(covfile, fullName string) testCoverageFunc { +func collectGoTestCoverage(covfile string) testCoverageFunc { return func() (coverage, funcsWithoutTest, funcsWithTest int, err error) { // We need to collect the coverage for all packages in the module. // To that end we load the coverage file. @@ -1680,6 +1680,7 @@ func executeCommandsForPackage(buildctx *buildContext, p *Package, wd string, co } env := append(os.Environ(), p.Environment...) + env = append(env, fmt.Sprintf("LEEWAY_WORKSPACE_ROOT=%s", p.C.W.Origin)) for _, cmd := range commands { err := run(buildctx.Reporter, p, env, wd, cmd[0], cmd[1:]...) if err != nil {