-
Notifications
You must be signed in to change notification settings - Fork 110
feat: implement mindev test cli command and rule loading by name #6551
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
evankanderson
merged 10 commits into
mindersec:main
from
krrish175-byte:feat/cli-scaffolding
Jul 3, 2026
Merged
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8f49124
feat: implement mindev test cli command and rule loading by name
krrish175-byte 2c9d69f
Merge branch 'main' into feat/cli-scaffolding
krrish175-byte 0b195db
fix: address reviewer feedback on mindev test command and ruletest
krrish175-byte 96953ef
fix: address second round of reviewer feedback on ruletest
krrish175-byte 1671dbe
Merge branch 'main' into feat/cli-scaffolding
krrish175-byte faee005
fix: address PR #6551 review comments
krrish175-byte 873de46
Address remaining PR comments from Evan
krrish175-byte ff1ceff
feat: integrate filesystem mocking in ruletest eval
krrish175-byte 1991991
chore: fix PR comments from latest review
krrish175-byte f7beb5a
chore: fix golangci-lint errors (gci and revive)
krrish175-byte File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| // SPDX-FileCopyrightText: Copyright 2026 The Minder Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| // Package test provides the test command for mindev | ||
| package test | ||
|
|
||
| import ( | ||
| "errors" | ||
|
|
||
| "github.com/spf13/cobra" | ||
|
|
||
| "github.com/mindersec/minder/pkg/ruletest" | ||
| ) | ||
|
|
||
| // CmdTest returns the test cobra command | ||
| func CmdTest() *cobra.Command { | ||
| cmd := &cobra.Command{ | ||
| Use: "test [paths...]", | ||
| Short: "Run Minder rule tests", | ||
| Long: "Run Starlark-based tests for Minder rules. Each path may be a file or directory. " + | ||
| "If no paths are provided, tests the current directory.", | ||
| RunE: func(cmd *cobra.Command, args []string) error { | ||
| if len(args) == 0 { | ||
| args = []string{"."} | ||
| } | ||
|
|
||
| runner := ruletest.NewRunner() | ||
| results, err := runner.RunPaths(args) | ||
| if err != nil { | ||
| cmd.PrintErrf("Error(s) running tests:\n%v\n", err) | ||
| } | ||
|
|
||
| if len(results) == 0 { | ||
| cmd.Printf("No tests found\n") | ||
| return nil | ||
| } | ||
|
|
||
| hasFailures := false | ||
| for _, res := range results { | ||
| if len(res.Failures) > 0 { | ||
| hasFailures = true | ||
| cmd.Printf("FAIL: %s/%s\n", res.Filename, res.Name) | ||
| for _, f := range res.Failures { | ||
| cmd.Printf(" - %s\n", f) | ||
| } | ||
| } else { | ||
| cmd.Printf("PASS: %s/%s\n", res.Filename, res.Name) | ||
| } | ||
| } | ||
|
|
||
| if hasFailures { | ||
| return errors.New("one or more tests failed") | ||
| } | ||
|
|
||
| return nil | ||
| }, | ||
| } | ||
|
|
||
| return cmd | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.