Skip to content

Feat/action flag fix#45

Open
moshloop wants to merge 5 commits into
mainfrom
feat/action-flag-fix
Open

Feat/action flag fix#45
moshloop wants to merge 5 commits into
mainfrom
feat/action-flag-fix

Conversation

@moshloop
Copy link
Copy Markdown
Member

No description provided.

…--show-passed for non-test subcommands

The flanksource/gavel composite action appends --no-progress --no-color
--show-passed --format ... after the user-supplied $GAVEL_ARGS. Two
issues prevented this from working:

1. cmd/gavel/test.go and cmd/gavel/test_framework_subcmds.go set
   testCmd.Flags().SetInterspersed(false), so any --flag token after a
   positional package path was treated as another path. With the action
   appending flags after user paths, every workflow that passed paths
   (e.g. `gavel test ./tests/e2e`) failed parsing with "starting path
   ./--no-progress does not exist".

2. action.yml unconditionally appended --show-passed, which is only
   defined on `gavel test` / `gavel lint`. Wrapping `gavel fixtures` (or
   any other subcommand) failed at flag parsing with "unknown flag:
   --show-passed".

Fix both:

- Flip SetInterspersed to true on `gavel test` and its framework
  subcommands. Cobra's `--` separator still terminates parsing for the
  documented `gavel test ./pkg -- --focus X` pass-through idiom.
- Detect the first non-flag word in $GAVEL_ARGS in the action's run
  step and only append --show-passed when it is `test` or `lint`.
…-tag-aware discovery

Lets callers run `gavel test ./... --ignore ./bench --ignore ./hack` instead
of enumerating every package they want included. Bare directory patterns are
recursive (no `/...` suffix needed); `/...` and `/**` suffixes are also
accepted for Go-style compatibility.

`.gitignore` is honored by default during test discovery (was already the
case via WalkGitIgnoredBounded); pass `--no-gitignore` to opt out.

Discovery now also evaluates build constraints via go/build.MatchFile so
test files behind `//go:build never` (or any tag the current build context
does not satisfy) no longer cause their package to be surfaced as runnable.
The check is permissive on errors (missing files etc.) to preserve existing
behavior on edge cases.

Implementation notes:
- `Ignore []string` and `NoGitignore bool` added to RunOptions; clicky's
  reflective flag binding picks them up from struct tags, no manual cobra
  wiring needed.
- Filter is applied in TestOrchestrator.discoverPackagesInPaths after the
  per-runner discovery returns, so all frameworks benefit.
- `--no-gitignore` is threaded through utils via a process-global toggle
  (utils.SetGitignoreDisabled) because the Runner interface does not pass
  per-call options into discovery; acceptable for a single-shot CLI.
Two follow-ups so duty's `./... --ignore ./hack` actually works:

1. Recognise Go-style recursive wildcards as starting paths. `./...`, `...`,
   `.`, and `./` now resolve to "discover from WorkDir" (the same code path
   used when no positional args are given), and any `./<dir>/...` is
   rewritten to `./<dir>` (DiscoverPackages already walks recursively).
   Previously gavel rejected `./...` with "starting path does not exist".

2. Apply --ignore to nested-module testGroups. expandNestedModuleGroups()
   spawns a separate group per child go.mod (e.g. ./hack/migrate,
   ./hack/generate-schemas), each running with its own WorkDir, so
   per-package filtering inside discoverPackagesInPaths never saw them.
   Drop ignored groups before runMultiRoot fans out.

Also extends path_filtering_unit_test.go with TestExpandRecursiveWildcards
and TestFilterIgnoredGroups.
…-passing sources

Add discovery and merging of multiple gavel-* artifacts from different workflow runs or matrix shards. When a PR has multiple test jobs, each now appears as a separate entry in the results UI with per-job breakdowns, while aggregate counts roll up to the PR level.

Also optimize the summary table to hide sources with 100% passing tests, collapsing them into a single "N more passing source(s)" row. This keeps PR comments short for the common "all green" case while still showing failing/skipped sources prominently.

Key changes:
- Add GavelArtifact struct and ListRunArtifacts/FindGavelArtifacts to discover artifacts via Actions API
- Refactor DownloadArtifact to DownloadArtifactFiles for multi-file support
- Add mergeGavelResults to concatenate test/lint/bench data from multiple payloads
- Add GavelJobSummary for per-job breakdown in UI
- Update summary table generation to filter and collapse all-passing sources
- Add comprehensive tests for artifact discovery, merging, and table generation

BREAKING CHANGE: DownloadArtifact now returns the first .json file only; use DownloadArtifactFiles for multi-file artifacts.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 27, 2026

Gavel summary

Source Pass Fail Skip Duration
./site 0 1 0 -
./testrunner/ui 34 1 0 53ms
github.com/flanksource/gavel/cmd/gavel 92 6 0 23.9s
github.com/flanksource/gavel/github 94 2 1 -
github.com/flanksource/gavel/testrunner 139 1 0 3.5s
github.com/flanksource/gavel/verify 180 1 0 -
lint: tsc 1 2 0 25.1s
git 105 0 2 5.7s
github.com/flanksource/gavel/github/cache 40 0 5 20ms
github.com/flanksource/gavel/linters/jscpd/testdata/sample 0 0 1 -
lint: betterleaks 0 0 1 -
lint: eslint 0 0 1 -
lint: golangci-lint 0 0 1 -
lint: jscpd 0 0 1 -
lint: markdownlint 0 0 1 -
lint: pyright 0 0 1 -
lint: ruff 0 0 1 -
lint: vale 0 0 1 -
36 more passing source(s) 1094 0 0 9.0s

Totals: 1779 passed · 14 failed · 17 skipped · 1m7s

Failing tests

github.com/flanksource/gavel/cmd/gavel — TestExecuteLintersJSCPDOptIn

github.com/flanksource/gavel/cmd/gavel — TestExecuteLintersJSCPDOptIn/jscpd_disabled_by_default

lint_test.go:50: expected jscpd to be absent when not enabled, got &{Linter:jscpd WorkDir: Command: Args:[] Success:false Skipped:true TimedOut:false Duration:0s Violations:[] RawOutput: Error:not ...

github.com/flanksource/gavel/cmd/gavel — TestWriteSnapshotJSON_ReadByLoadResults

test_fork_unix_test.go:117: 
        	Error Trace:	/home/runner/work/gavel/gavel/cmd/gavel/test_fork_unix_test.go:117
        	Error:      	"[map[context:map[duration: status:pending type:group] framework:task name:Running linters pending:true] map[context:map[duration: status:pending type:group] framework:task na...
        	Test:       	TestWriteSnapshotJSON_ReadByLoadResults

github.com/flanksource/gavel/cmd/gavel — TestLoadResults_MergesMultipleSnapshots

ui_serve_test.go:115: 
        	Error Trace:	/home/runner/work/gavel/gavel/cmd/gavel/ui_serve_test.go:115
        	Error:      	"[{Running linters     []   0 task 0s false false false true false false false   [] <nil> map[duration: status:pending type:group] <nil>} {Running linters     []   0 task 0s f...
        	Test:       	TestLoadResults_MergesMultipleSnapshots

github.com/flanksource/gavel/cmd/gavel — TestRunUIServe_ReplaysSnapshotAndExits

UI at http://localhost:42759
    ui_serve_test.go:251: 
        	Error Trace:	/home/runner/work/gavel/gavel/cmd/gavel/ui_serve_test.go:251
        	Error:      	"[map[context:map[duration: status:pending type:group] framework:task name:Running linters pending:true] map[context:map[duration: status:pending type:group] framework:task na...
... (8 more lines truncated)

... and 7 more failing tests — see the full gavel-results artifact.

Failing linters

tsc — error

tsc wrapper failed: exit status 1
Stderr:
gavel-tsc: cannot load 'typescript' from /home/runner/work/gavel/gavel/site/node_modules. Install it with your package manager (e.g. `npm i -D typescript`).

tsc — 3 violation(s)

  • src/App.tsx:37 — Cannot find namespace 'React'. Did you mean 'preact'? (tsc)
  • src/App.tsx:38 — Cannot find namespace 'React'. Did you mean 'preact'? (tsc)
  • src/App.tsx:39 — Cannot find namespace 'React'. Did you mean 'preact'? (tsc)

View full results

Implement a new index view that lists previously-saved test snapshots from the .gavel/ directory, allowing users to browse and replay historical test runs without re-running tests.

Key changes:
- Add /api/runs endpoint to list snapshots with metadata (test counts, lint violations, duration, git SHA)
- Add /api/runs/{name} endpoint to load individual snapshots, with pointer resolution for aliased runs (last, main, master)
- Add resolveGavelRoot() to discover .gavel/ directory when gavel ui serve is run with no arguments
- Implement RunIndex frontend component with sortable snapshot table showing test results and lint counts
- Add route parsing for /run/{name} URLs to support deep-linking into specific snapshots
- Maintain backward compatibility with existing /tests, /lint, etc. routes

Users can now run `gavel ui serve` in a git repo to browse all saved snapshots, or continue using `gavel ui serve <file>` to view a specific snapshot. Pointer files (last.json, main.json) are automatically resolved to their target snapshots.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant