Skip to content

Commit

Permalink
Make LEEWAY_WORKSPACE_ROOT available in build commands
Browse files Browse the repository at this point in the history
allows to reference a golangci-lint config in the linter command
  • Loading branch information
csweichel committed May 24, 2024
1 parent 5d8c7c7 commit 1892fcc
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/leeway/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, "./...")

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 1892fcc

Please sign in to comment.