Skip to content

Commit

Permalink
Merge pull request #19 from grafana/tweaks
Browse files Browse the repository at this point in the history
small tweaks on checkers
  • Loading branch information
szkiba authored Nov 14, 2024
2 parents 392b718 + 5248877 commit b058606
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
21 changes: 15 additions & 6 deletions checker_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,26 +66,33 @@ func (mc *moduleChecker) canBuild(ctx context.Context, dir string) *checkResult
return checkError(err)
}

mc.exe = exe
mc.js = mc.isJS(out)

return checkPassed("can be built with the latest k6 version")
}

func (mc *moduleChecker) isJS(out []byte) bool {
rex, err := regexp.Compile("(?i) " + mc.file.Module.Mod.String() + "[^,]+, [^ ]+ \\[(?P<type>[a-z]+)\\]")
if err != nil {
return checkError(err)
return false
}

subs := rex.FindAllSubmatch(out, -1)
if subs == nil {
return checkFailed(mc.file.Module.Mod.String() + " is not in the version command's output")
return false
}

js := false

for _, one := range subs {
if string(one[rex.SubexpIndex("type")]) == "js" {
mc.js = true
js = true
break
}
}

mc.exe = exe

return checkPassed("can be built with the latest k6 version")
return js
}

var reSmoke = regexp.MustCompile(`(?i)^smoke(\.test)?\.(?:js|ts)`)
Expand All @@ -105,6 +112,7 @@ func (mc *moduleChecker) smoke(ctx context.Context, dir string) *checkResult {
filepath.Join(dir, "test"),
filepath.Join(dir, "tests"),
filepath.Join(dir, "examples"),
filepath.Join(dir, "scripts"),
)
if err != nil {
return checkError(err)
Expand Down Expand Up @@ -140,6 +148,7 @@ func (mc *moduleChecker) types(_ context.Context, dir string) *checkResult {
_, shortname, err := findFile(reIndexDTS,
dir,
filepath.Join(dir, "docs"),
filepath.Join(dir, "api-docs"),
)
if err != nil {
return checkError(err)
Expand Down
15 changes: 15 additions & 0 deletions releases/v0.3.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
k6lint `v0.3.1` is here 🎉!

Tweaks in this release:

## types checker

Search for the `index.d.ts` file in the `api-docs` folder as well (not only in the `docs` and root folders).

## smoke checker

Search for the smoke test script in the `scripts` folder as well (not only in the `test`, `tests`, `examples` and root folder).

## build checker

The check should not fail if the module path of the extension is not included in the output of the version command.

0 comments on commit b058606

Please sign in to comment.