feat(test): add --output (text/json/yaml/github-actions) for machine-readable results#488
feat(test): add --output (text/json/yaml/github-actions) for machine-readable results#488Caesarsage wants to merge 6 commits into
Conversation
Signed-off-by: caesarsage <destinyerhabor6@gmail.com>
…ctions) Signed-off-by: caesarsage <destinyerhabor6@gmail.com>
…paths Signed-off-by: caesarsage <destinyerhabor6@gmail.com>
Signed-off-by: caesarsage <destinyerhabor6@gmail.com>
Signed-off-by: caesarsage <destinyerhabor6@gmail.com>
Signed-off-by: caesarsage <destinyerhabor6@gmail.com>
|
/hold Working on a structure logger and helper function from last mentorship call |
| "encoding/json" | ||
|
|
||
| "github.com/microcks/microcks-cli/pkg/connectors" | ||
| "gopkg.in/yaml.v2" |
There was a problem hiding this comment.
In openapi_linemap file, you used yaml.v3, so why v2 here?
| // within an OpenAPI spec file, or 0 if it can't be determined (non-YAML spec, | ||
| // parse error, or operation not found). yaml.v3 nodes carry line numbers, which | ||
| // yaml.v2 does not expose. | ||
| func operationLine(specPath, operationName string) int { |
There was a problem hiding this comment.
Nit: the function name operationLine and the paths key lookup hard-code an assumption that this is an OpenAPI spec. But microcks test --dry-run also works with AsyncAPI, Postman Collections, and GraphQL artifacts.
For AsyncAPI, the top-level key is channels (AsyncAPI 2.x) or channels/operations (AsyncAPI 3.x), not paths. Postman Collections are JSON, not YAML at all.
| if pathNode == nil { | ||
| return 0 | ||
| } | ||
| line, _ := mappingEntry(pathNode, method) |
There was a problem hiding this comment.
The blank identifier _ here silently discards whether the method lookup found anything. If mappingEntry returns (0, nil) for a missing key, that's already handled correctly since you return 0.
But would it be worth extracting a named variable for clarity?
line, methodNode := mappingEntry(pathNode, method)
if methodNode == nil {
return 0
}
return line| } | ||
|
|
||
| // splitOperation parses "GET /products" into ("get", "/products", true). | ||
| func splitOperation(operationName string) (method, path string, ok bool) { |
There was a problem hiding this comment.
This works great for the OpenAPI METHOD /path convention, but Microcks also supports AsyncAPI (e.g. SUBSCRIBE channel) and GraphQL (e.g. getPastries) where the split won't match, though the safe false fallback handles that correctly.
Worth adding a short doc comment to make this intentional scope explicit.
Adds
--outputtomicrocks test, with four formats:text(default)jsonTestResultas JSONyamlTestResultas YAMLgithub-actionsWorks for both the normal server path and
--dry-run, since it's wired into theshared test engine (
runTestAndWait).github-actions format
::group::/::endgroup::log-folding per operation::error::per failing step, with the validation message::error file=<spec>,line=<n>::when the local spec is known (--dry-run --artifact),mapping the failing operation to its line so the annotation lands on the diff
::notice::for passing operations, gated byMICROCKS_ACTIONS_VERBOSE$GITHUB_STEP_SUMMARYTests
summary, and the OpenAPI line-mapping (
pkg/output).Notes
--output, extended with github-actions + diffannotations) — that PR can be closed.
Refs Feat: Microcks-CLI v2 - IDE (Vs code) Integration and Local Dev Loop Enhancement #255