Skip to content

Commit

Permalink
[CI] Module parsing fix (#40053)
Browse files Browse the repository at this point in the history
Currently if CI detects changes in more than one module locations, e.g. `elasticsearch` and `system`, it defines a comma separated string like
`MODULE=elasticsearch,system`, which results in the error
`Error: no module elasticsearch,system` [link](https://github.com/elastic/beats/blob/main/dev-tools/mage/gotest.go#L209).

This commit fixes the above bug by running each module test sequentially.

Closes elastic/ingest-dev#3508

---------

Co-authored-by: Dimitrios Liappis <[email protected]>
  • Loading branch information
oakrizan and dliappis authored Aug 5, 2024
1 parent 81bc303 commit 313fdca
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion dev-tools/mage/gotest.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,22 @@ func DefaultTestBinaryArgs() TestBinaryArgs {
// Use RACE_DETECTOR=true to enable the race detector.
// Use MODULE=module to run only tests for `module`.
func GoTestIntegrationForModule(ctx context.Context) error {
module := EnvOr("MODULE", "")
modules := EnvOr("MODULE", "")
if modules == "" {
log.Printf("Warning: environment variable MODULE is empty: [%s]\n", modules)
}
moduleArr := strings.Split(modules, ",")

for _, module := range moduleArr {
err := goTestIntegrationForSingleModule(ctx, module)
if err != nil {
return err
}
}
return nil
}

func goTestIntegrationForSingleModule(ctx context.Context, module string) error {
modulesFileInfo, err := os.ReadDir("./module")
if err != nil {
return err
Expand Down

0 comments on commit 313fdca

Please sign in to comment.