featureparity 0.0.28 → 0.0.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/fp/cli.rb +11 -2
- data/lib/fp/client.rb +31 -1
- data/lib/fp/commands/base.rb +14 -0
- data/lib/fp/commands/check.rb +38 -4
- data/lib/fp/commands/ci_report.rb +35 -5
- data/lib/fp/commands/comment.rb +1 -1
- data/lib/fp/commands/coverage.rb +149 -0
- data/lib/fp/commands/doctor.rb +228 -0
- data/lib/fp/commands/help.rb +13 -1
- data/lib/fp/commands/history.rb +4 -0
- data/lib/fp/commands/init.rb +172 -117
- data/lib/fp/commands/list.rb +58 -4
- data/lib/fp/commands/mark.rb +167 -0
- data/lib/fp/commands/projects.rb +1 -0
- data/lib/fp/commands/propose.rb +401 -52
- data/lib/fp/commands/propose_change.rb +7 -1
- data/lib/fp/commands/question.rb +137 -0
- data/lib/fp/commands/report.rb +23 -3
- data/lib/fp/commands/run.rb +147 -0
- data/lib/fp/commands/show.rb +27 -0
- data/lib/fp/commands.rb +5 -0
- data/lib/fp/junit.rb +60 -7
- data/lib/fp/repo_detector.rb +488 -0
- data/lib/fp/requirement_lint.rb +105 -0
- data/lib/fp/rspec_json.rb +54 -0
- data/lib/fp/version.rb +1 -1
- data/lib/fp.rb +1 -0
- data/skills/fp/SKILL.md +244 -105
- data/skills/fp/references/cli.md +231 -3
- metadata +10 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7b3bad4ccc28e0695bdb790ecc37d6836d5477a84de09442c5255df871d98444
|
|
4
|
+
data.tar.gz: 67fcd3d1ac1a1a7bd41197ae674942fea80d20bbea22d856075face50ad87007
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b276bc10363baf2fe27e843e0824ed205ed62f7836f4671cf53db15fc92ddc6a579a2fb1f5da34c4f34e672ffe2c14c418d10239e55066aa1a4b5806f078b930
|
|
7
|
+
data.tar.gz: 2769c008ecac2bdd2f02c13ef34cdc91619085709965138dc8750ab4127ebd22d119eae646a89202217db47235ddc4e75e1efae24528feeed1b1a7d53ec20f80
|
data/lib/fp/cli.rb
CHANGED
|
@@ -8,6 +8,8 @@ module Fp
|
|
|
8
8
|
COMMANDS = {
|
|
9
9
|
'init' => Commands::Init,
|
|
10
10
|
'tutorial' => Commands::Tutorial,
|
|
11
|
+
'doctor' => Commands::Doctor,
|
|
12
|
+
'run' => Commands::Run,
|
|
11
13
|
'projects' => Commands::Projects,
|
|
12
14
|
'surfaces' => Commands::Surfaces,
|
|
13
15
|
'showroom' => Commands::Showroom,
|
|
@@ -15,7 +17,10 @@ module Fp
|
|
|
15
17
|
'show' => Commands::Show,
|
|
16
18
|
'propose' => Commands::Propose,
|
|
17
19
|
'propose-change' => Commands::ProposeChange,
|
|
20
|
+
'mark' => Commands::Mark,
|
|
18
21
|
'comment' => Commands::Comment,
|
|
22
|
+
'question' => Commands::Question,
|
|
23
|
+
'questions' => Commands::Questions,
|
|
19
24
|
'comments' => Commands::Comments,
|
|
20
25
|
'history' => Commands::History,
|
|
21
26
|
'analyze' => Commands::Analyze,
|
|
@@ -25,6 +30,7 @@ module Fp
|
|
|
25
30
|
'changed-tests' => Commands::ChangedTests,
|
|
26
31
|
'spot-check' => Commands::SpotCheck,
|
|
27
32
|
'check' => Commands::Check,
|
|
33
|
+
'coverage' => Commands::Coverage,
|
|
28
34
|
'matrix' => Commands::Matrix,
|
|
29
35
|
'export' => Commands::Export,
|
|
30
36
|
'profile' => Commands::Profile,
|
|
@@ -42,6 +48,9 @@ module Fp
|
|
|
42
48
|
class << self
|
|
43
49
|
def run(argv)
|
|
44
50
|
args = argv.dup
|
|
51
|
+
# Everything after `--` belongs to another program (`fp run -- pytest -p no:cov`),
|
|
52
|
+
# so global flags and --help are only looked for before it.
|
|
53
|
+
passthrough = (split = args.index('--')) ? args.slice!(split..) : []
|
|
45
54
|
global_opts = extract_global_options(args)
|
|
46
55
|
|
|
47
56
|
command_name = args.shift || 'help'
|
|
@@ -71,7 +80,7 @@ module Fp
|
|
|
71
80
|
|
|
72
81
|
# Profile/config commands don't need auth. `init` is here too: it only writes
|
|
73
82
|
# files into the repo, and onboarding a repo must work before anyone has a key.
|
|
74
|
-
needs_auth = !%w[init profile config repos setup whoami version help].include?(command_name)
|
|
83
|
+
needs_auth = !%w[init doctor profile config repos setup whoami version help mark].include?(command_name)
|
|
75
84
|
|
|
76
85
|
if needs_auth
|
|
77
86
|
config = Config.new(profile: global_opts[:profile], api_url: global_opts[:api_url])
|
|
@@ -87,7 +96,7 @@ module Fp
|
|
|
87
96
|
|
|
88
97
|
output = Output.new(json: global_opts[:json])
|
|
89
98
|
command = command_class.new(client: client, output: output, config: config)
|
|
90
|
-
command.run(args)
|
|
99
|
+
command.run(args + passthrough)
|
|
91
100
|
rescue Interrupt
|
|
92
101
|
warn "\nAborted."
|
|
93
102
|
exit 130
|
data/lib/fp/client.rb
CHANGED
|
@@ -247,6 +247,21 @@ module Fp
|
|
|
247
247
|
post("/api/requirements/#{requirement_id}/changes/#{change_id}/comment", params)
|
|
248
248
|
end
|
|
249
249
|
|
|
250
|
+
# GET /requirements/:id/questions
|
|
251
|
+
#
|
|
252
|
+
# The questions left for a human on a requirement (Fizzy #1786), open and resolved.
|
|
253
|
+
def list_requirement_questions(requirement_id)
|
|
254
|
+
get("/api/requirements/#{requirement_id}/questions")
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
# POST /requirements/:id/questions
|
|
258
|
+
#
|
|
259
|
+
# Attach an open question for a human to a draft (or active) requirement. There is
|
|
260
|
+
# no resolve method: only a human answers or dismisses, from the web app.
|
|
261
|
+
def ask_requirement_question(requirement_id, text)
|
|
262
|
+
post("/api/requirements/#{requirement_id}/questions", { text: text })
|
|
263
|
+
end
|
|
264
|
+
|
|
250
265
|
# GET /requirements/:id/comments
|
|
251
266
|
#
|
|
252
267
|
# The team's comments on a requirement, oldest first, plus who can be tagged:
|
|
@@ -303,12 +318,16 @@ module Fp
|
|
|
303
318
|
# only do that by fetching the test files from GitHub, which fails silently on a
|
|
304
319
|
# private repo, so resolved results are always sent when we have them.
|
|
305
320
|
def ingest_ci_results(project_id, ci_url:, surface:, junit_xml:, pr_url: nil, results: nil,
|
|
306
|
-
test_revisions: nil, unmarked_failures: nil, orphan_markers: nil, sha: nil
|
|
321
|
+
test_revisions: nil, unmarked_failures: nil, orphan_markers: nil, sha: nil,
|
|
322
|
+
local: false)
|
|
307
323
|
body = {
|
|
308
324
|
ci_url: ci_url,
|
|
309
325
|
surface: surface,
|
|
310
326
|
junit_xml: junit_xml
|
|
311
327
|
}
|
|
328
|
+
# A run on someone's machine rather than in CI (`fp ci-report --local`): there may be
|
|
329
|
+
# no run URL to record, and the server only accepts that when told so.
|
|
330
|
+
body[:local] = true if local
|
|
312
331
|
# Only send pr_url when set, so a merged-branch run stays a plain ingest.
|
|
313
332
|
body[:pr_url] = pr_url if pr_url && !pr_url.empty?
|
|
314
333
|
# The checkout commit, so the receipt (or a PR run's branch verdict) links the
|
|
@@ -367,6 +386,17 @@ module Fp
|
|
|
367
386
|
get("/api/projects/#{project_id}/parity", params)
|
|
368
387
|
end
|
|
369
388
|
|
|
389
|
+
# GET /projects/:project_id/parity?include_drafts=true — the same report plus a
|
|
390
|
+
# top-level `drafts` array: never-approved drafts with their cells resolved from
|
|
391
|
+
# evidence. Informational only; the server never gates on it (Fizzy #1786). Read by
|
|
392
|
+
# `fp coverage`, `fp list --status draft --gaps` and `fp check --include-drafts`.
|
|
393
|
+
def get_parity_with_drafts(project_id, level: nil, surface: nil)
|
|
394
|
+
params = { include_drafts: 'true' }
|
|
395
|
+
params[:level] = level if level
|
|
396
|
+
params[:surface] = surface if surface
|
|
397
|
+
get("/api/projects/#{project_id}/parity", params)
|
|
398
|
+
end
|
|
399
|
+
|
|
370
400
|
# POST /projects/:project_id/parity/preview — the pull-request gate.
|
|
371
401
|
#
|
|
372
402
|
# Evaluates JUnit results as an overlay on the stored grid *without persisting them*,
|
data/lib/fp/commands/base.rb
CHANGED
|
@@ -210,6 +210,20 @@ module Fp
|
|
|
210
210
|
project['id']
|
|
211
211
|
end
|
|
212
212
|
|
|
213
|
+
# One line on stderr before a command writes to a project, when the API it's about
|
|
214
|
+
# to write to isn't production. FP_PROFILE / FP_API_URL left over in a shell put an
|
|
215
|
+
# agent's new project on a dev environment with nothing to say so (Fizzy #1786).
|
|
216
|
+
# Stderr keeps --json output parseable; it never stops the command.
|
|
217
|
+
def warn_if_not_production!
|
|
218
|
+
env = config&.environment
|
|
219
|
+
return if env.nil? || env == 'production'
|
|
220
|
+
|
|
221
|
+
profile = config.profile_name
|
|
222
|
+
via = profile ? " (profile '#{profile}')" : ''
|
|
223
|
+
$stderr.puts "⚠ Writing to the '#{env}' environment at #{config.api_url}#{via}, not production. " \
|
|
224
|
+
'Run `fp whoami` to see where that comes from.'
|
|
225
|
+
end
|
|
226
|
+
|
|
213
227
|
def require_flag(opts, flag, message = nil)
|
|
214
228
|
unless opts[flag]
|
|
215
229
|
message ||= "--#{flag.to_s.tr('_', '-')} is required"
|
data/lib/fp/commands/check.rb
CHANGED
|
@@ -51,15 +51,17 @@ module Fp
|
|
|
51
51
|
help_flag :surface, 'Gate a single surface'
|
|
52
52
|
help_flag :test_type, 'Gate a single test type'
|
|
53
53
|
help_flag :level, 'Override the enforcement level for this run (off/regression/covered/strict)'
|
|
54
|
-
help_flag :junit, "Gate the branch on this run's results, overlaid on the grid (repeatable, one per surface)"
|
|
54
|
+
help_flag :junit, "Gate the branch on this run's results (JUnit XML or RSpec JSON), overlaid on the grid (repeatable, one per surface)"
|
|
55
55
|
help_flag :base_dir, "Where the report's relative test-file paths resolve from"
|
|
56
56
|
help_flag :pr, 'With --junit: this run is a pull request — fail only on parity it makes worse, ' \
|
|
57
57
|
'not on what the default branch already owes (optionally the PR URL)'
|
|
58
58
|
help_flag :warn_only, 'Report violations but still exit 0'
|
|
59
|
+
help_flag :include_drafts, 'Also show draft coverage after the verdict (never changes the exit code)'
|
|
59
60
|
help_example 'fp check', 'Gate on recorded state (project from .featureparity.yml)'
|
|
60
61
|
help_example 'fp check --surface api --junit junit.xml', 'Gate a default-branch run on its own results'
|
|
61
62
|
help_example 'fp check --surface api --junit junit.xml --pr', 'Gate a pull request on what it changes'
|
|
62
63
|
help_example 'fp check --warn-only --json'
|
|
64
|
+
help_example 'fp check --include-drafts', 'Onboarding: which drafts have evidence, which have none'
|
|
63
65
|
help_note "Exit 0 = passed, 1 = violations (or request failed). The level lives on the project\n" \
|
|
64
66
|
'server-side; --level only overrides this one run.'
|
|
65
67
|
|
|
@@ -73,7 +75,8 @@ module Fp
|
|
|
73
75
|
# `--pr` alone is true; `--pr <url>` carries the URL. Not :boolean on purpose, so
|
|
74
76
|
# the parser takes a following value when one is given.
|
|
75
77
|
pr: :string,
|
|
76
|
-
warn_only: :boolean
|
|
78
|
+
warn_only: :boolean,
|
|
79
|
+
include_drafts: :boolean
|
|
77
80
|
}.freeze
|
|
78
81
|
|
|
79
82
|
# How many inherited violations to list before summarising the rest. They are
|
|
@@ -103,7 +106,9 @@ module Fp
|
|
|
103
106
|
project_id = resolve_project_id(project_slug)
|
|
104
107
|
|
|
105
108
|
result =
|
|
106
|
-
if junit_paths.empty?
|
|
109
|
+
if junit_paths.empty? && opts[:include_drafts]
|
|
110
|
+
client.get_parity_with_drafts(project_id, level: level, surface: surface)
|
|
111
|
+
elsif junit_paths.empty?
|
|
107
112
|
client.get_parity(project_id, level: level, surface: surface)
|
|
108
113
|
else
|
|
109
114
|
preview(project_id, junit_paths, surface, level, opts)
|
|
@@ -125,7 +130,12 @@ module Fp
|
|
|
125
130
|
'this verdict counts every violation, including those the default branch already has.'
|
|
126
131
|
end
|
|
127
132
|
|
|
133
|
+
# Draft coverage rides along when asked for. Informational only: it is added after
|
|
134
|
+
# the verdict was decided and never feeds `passed` (Fizzy #1786).
|
|
135
|
+
report = report.merge('drafts' => draft_rows(project_id, level, surface, report)) if opts[:include_drafts]
|
|
136
|
+
|
|
128
137
|
render(report, violations, passed, project_slug, opts)
|
|
138
|
+
print_drafts(report) if opts[:include_drafts] && !output.json?
|
|
129
139
|
|
|
130
140
|
# A failing gate is the whole point of the command, so it must be the exit code
|
|
131
141
|
# and not just something printed. --warn-only downgrades it to advisory.
|
|
@@ -134,6 +144,30 @@ module Fp
|
|
|
134
144
|
|
|
135
145
|
private
|
|
136
146
|
|
|
147
|
+
# The standing read already carries `drafts` when asked for. The preview endpoint
|
|
148
|
+
# doesn't, so a --junit run reads them from the standing report instead; drafts are
|
|
149
|
+
# recorded state either way. A failed or too-old read is a warning, never a failed
|
|
150
|
+
# gate, because drafts can't change the verdict.
|
|
151
|
+
def draft_rows(project_id, level, surface, report)
|
|
152
|
+
return report['drafts'] if report.key?('drafts')
|
|
153
|
+
|
|
154
|
+
result = client.get_parity_with_drafts(project_id, level: level, surface: surface)
|
|
155
|
+
drafts = result[:ok] ? (result[:data]['parity'] || {})['drafts'] : nil
|
|
156
|
+
if drafts.nil?
|
|
157
|
+
warn 'Warning: draft coverage is unavailable from this API; the verdict is unaffected.'
|
|
158
|
+
return []
|
|
159
|
+
end
|
|
160
|
+
drafts
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
def print_drafts(report)
|
|
164
|
+
drafts = report['drafts'] || []
|
|
165
|
+
puts
|
|
166
|
+
puts "Draft coverage (#{drafts.size} draft(s), not gated):"
|
|
167
|
+
Coverage.print_drafts(output, drafts, report['surfaces'] || [])
|
|
168
|
+
Coverage.print_untested(Coverage.untested(drafts)) unless drafts.empty?
|
|
169
|
+
end
|
|
170
|
+
|
|
137
171
|
# Preview mode needs to know which surface the results belong to, because the
|
|
138
172
|
# server uses it to decide which cells the run had a chance to cover — and
|
|
139
173
|
# therefore which vanished tests it may legitimately flag.
|
|
@@ -162,7 +196,7 @@ module Fp
|
|
|
162
196
|
client.preview_parity(
|
|
163
197
|
project_id,
|
|
164
198
|
surface: surface,
|
|
165
|
-
junit_xmls: junit_paths.map { |p|
|
|
199
|
+
junit_xmls: junit_paths.map { |p| Fp::JUnit.read_xml(p) },
|
|
166
200
|
level: level,
|
|
167
201
|
results: resolve_results(junit_paths, surface, opts),
|
|
168
202
|
pull_request: !!opts[:pr],
|
|
@@ -49,6 +49,12 @@ module Fp
|
|
|
49
49
|
# of `passing`, and no merged evidence is demoted. Run it without --pr on pushes to
|
|
50
50
|
# the default branch to record the real `passing`, superseding any pr_passing a prior
|
|
51
51
|
# PR run left behind.
|
|
52
|
+
#
|
|
53
|
+
# --local is for when there is no CI to run the suite — a team out of CI minutes, or
|
|
54
|
+
# one without a pipeline yet (Fizzy #1837). A person runs the suite on their own
|
|
55
|
+
# machine and reports it the same way CI would; --ci-url becomes optional. The verdict
|
|
56
|
+
# is stamped on HEAD, so the working tree has to be clean: a result from edits nobody
|
|
57
|
+
# committed would be recorded against a commit that never ran them.
|
|
52
58
|
class CiReport < Base
|
|
53
59
|
help_summary 'CI only: ingest real pass/fail results (writes passing/failing evidence)'
|
|
54
60
|
help_usage 'fp ci-report --junit <file>... --project <slug> --surface <surface> --ci-url URL [--pr URL]'
|
|
@@ -57,15 +63,18 @@ module Fp
|
|
|
57
63
|
help_flag :test_type, 'Default test kind for markers that pin none'
|
|
58
64
|
help_flag :ci_url, 'CI run URL to record on the evidence'
|
|
59
65
|
help_flag :pr, "Mark this as a PR's CI: passing tests recorded as pr_passing, no merged evidence demoted"
|
|
60
|
-
help_flag :junit, 'JUnit XML report (repeatable to combine a surface split across shards)'
|
|
66
|
+
help_flag :junit, 'JUnit XML report, or RSpec `--format json` output (repeatable to combine a surface split across shards)'
|
|
61
67
|
help_flag :base_dir, "Where the report's relative test-file paths resolve from (e.g. frontend)"
|
|
62
68
|
help_flag :repo, 'Repository the tests live in (org/repo)'
|
|
63
69
|
help_flag :sha, 'Checkout commit SHA'
|
|
64
70
|
help_flag :allow_empty, 'Do not error when a report resolves no fp:<slug> markers'
|
|
71
|
+
help_flag :local, 'No CI available: report a suite a person ran locally at a clean, committed HEAD (--ci-url optional)'
|
|
65
72
|
help_example 'fp ci-report --junit junit.xml --project stowzilla --surface api --ci-url "$CI_RUN_URL"'
|
|
66
73
|
help_example 'fp ci-report --junit web.xml --surface web --base-dir frontend --pr "$PR_URL"'
|
|
74
|
+
help_example 'fp ci-report --local --junit junit.xml --surface api'
|
|
67
75
|
help_note "This is CI's command, not an agent's: only it writes passing/failing. Run it on both\n" \
|
|
68
|
-
|
|
76
|
+
"green and red builds (if: always()) so failures show on the matrix.\n" \
|
|
77
|
+
'Out of CI minutes? A person can run the suite and report it with --local; agents report with fp report.'
|
|
69
78
|
|
|
70
79
|
KNOWN_FLAGS = {
|
|
71
80
|
project: :string,
|
|
@@ -77,7 +86,8 @@ module Fp
|
|
|
77
86
|
base_dir: :string,
|
|
78
87
|
repo: :string,
|
|
79
88
|
sha: :string,
|
|
80
|
-
allow_empty: :boolean
|
|
89
|
+
allow_empty: :boolean,
|
|
90
|
+
local: :boolean
|
|
81
91
|
}.freeze
|
|
82
92
|
|
|
83
93
|
def run(args)
|
|
@@ -88,7 +98,7 @@ module Fp
|
|
|
88
98
|
|
|
89
99
|
require_project!(opts)
|
|
90
100
|
require_flag(opts, :surface)
|
|
91
|
-
require_flag(opts, :ci_url)
|
|
101
|
+
require_flag(opts, :ci_url) unless opts[:local]
|
|
92
102
|
|
|
93
103
|
if junit_paths.empty?
|
|
94
104
|
output.error('--junit <path> is required (may be given more than once).')
|
|
@@ -103,6 +113,7 @@ module Fp
|
|
|
103
113
|
|
|
104
114
|
project_id = resolve_project_id(opts[:project])
|
|
105
115
|
known = known_slugs(project_id)
|
|
116
|
+
require_clean_tree!(opts) if opts[:local]
|
|
106
117
|
commit_sha = resolve_commit_sha(opts)
|
|
107
118
|
repo = opts[:repo] || presence(ENV['GITHUB_REPOSITORY'])
|
|
108
119
|
|
|
@@ -127,7 +138,7 @@ module Fp
|
|
|
127
138
|
totals[:unmarked_failures].concat(resolved[:unmarked_failures])
|
|
128
139
|
totals[:test_revisions] += test_revisions.length
|
|
129
140
|
|
|
130
|
-
{ path: path, xml:
|
|
141
|
+
{ path: path, xml: Fp::JUnit.read_xml(path), results: results, test_revisions: test_revisions }
|
|
131
142
|
end
|
|
132
143
|
|
|
133
144
|
# One surface run may be split across several reports (unit + e2e, shards, etc.).
|
|
@@ -147,6 +158,7 @@ module Fp
|
|
|
147
158
|
junit_xml: resolved_reports.first[:xml],
|
|
148
159
|
pr_url: opts[:pr],
|
|
149
160
|
sha: commit_sha,
|
|
161
|
+
local: opts[:local],
|
|
150
162
|
results: combined_results,
|
|
151
163
|
test_revisions: combined_revisions,
|
|
152
164
|
unmarked_failures: totals[:unmarked_failures],
|
|
@@ -359,6 +371,23 @@ module Fp
|
|
|
359
371
|
exit 1
|
|
360
372
|
end
|
|
361
373
|
|
|
374
|
+
# A local run is recorded against HEAD, so HEAD has to be what ran. Untracked files
|
|
375
|
+
# are ignored: the report itself is usually one.
|
|
376
|
+
def require_clean_tree!(opts)
|
|
377
|
+
root = Fp::JUnit.repo_root_for(opts[:base_dir] || Dir.pwd)
|
|
378
|
+
stdout, _stderr, status = Open3.capture3('git', 'status', '--porcelain', '--untracked-files=no',
|
|
379
|
+
chdir: root || Dir.pwd)
|
|
380
|
+
unless status.success?
|
|
381
|
+
output.error('--local needs a git checkout: the results are recorded against the commit that ran them.')
|
|
382
|
+
exit 1
|
|
383
|
+
end
|
|
384
|
+
return if stdout.strip.empty?
|
|
385
|
+
|
|
386
|
+
output.error('--local refuses a working tree with uncommitted changes: the results would be ' \
|
|
387
|
+
'recorded against a commit that never ran them. Commit (and push) first, then re-run the suite.')
|
|
388
|
+
exit 1
|
|
389
|
+
end
|
|
390
|
+
|
|
362
391
|
def resolve_commit_sha(opts)
|
|
363
392
|
explicit = presence(opts[:sha])
|
|
364
393
|
return explicit if explicit
|
|
@@ -403,6 +432,7 @@ module Fp
|
|
|
403
432
|
|
|
404
433
|
output.success(data) do
|
|
405
434
|
mode = opts[:pr] ? " (PR mode — passing tests recorded as pr_passing)" : ''
|
|
435
|
+
mode += ' (local run, no CI)' if opts[:local]
|
|
406
436
|
puts "Ingested CI results for surface '#{opts[:surface]}'#{mode}:"
|
|
407
437
|
totals[:reports].each do |report|
|
|
408
438
|
report[:results].each do |r|
|
data/lib/fp/commands/comment.rb
CHANGED
|
@@ -17,7 +17,7 @@ module Fp
|
|
|
17
17
|
source_type: :string, source_url: :string, source_context: :string
|
|
18
18
|
}.freeze
|
|
19
19
|
|
|
20
|
-
VALID_SOURCE_TYPES = %w[fizzy discord github_issue jira notion manual ai_chat].freeze
|
|
20
|
+
VALID_SOURCE_TYPES = %w[fizzy discord github_issue jira notion manual ai_chat repo_scan].freeze
|
|
21
21
|
|
|
22
22
|
help_summary "Comment on a requirement's open change proposal"
|
|
23
23
|
help_usage 'fp comment <slug> --body "..." --project <slug>'
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Fp
|
|
4
|
+
module Commands
|
|
5
|
+
# fp coverage [--project X] [--surface api] [--all] [--json]
|
|
6
|
+
#
|
|
7
|
+
# Draft coverage: which draft requirements have marked tests or evidence on which
|
|
8
|
+
# surfaces, and which have none.
|
|
9
|
+
#
|
|
10
|
+
# The gate measures active requirements only (plus ones an open proposal demoted), so
|
|
11
|
+
# on a freshly onboarded project — where every requirement is still a draft — `fp
|
|
12
|
+
# check` says "Nothing to enforce yet" and `fp list --gaps` says "No gaps found". The
|
|
13
|
+
# agent that just proposed the catalog and marked the tests had no way to confirm its
|
|
14
|
+
# work, and nothing to hand the human but "trust me" (Fizzy #1786). This reads the
|
|
15
|
+
# parity report's `drafts` section, where the server resolves each draft's cells from
|
|
16
|
+
# evidence exactly as it would once the draft is active.
|
|
17
|
+
#
|
|
18
|
+
# It ends with a plain list of drafts that have no evidence on a required surface —
|
|
19
|
+
# the "requirements with no test" section an onboarding agent hands the human.
|
|
20
|
+
#
|
|
21
|
+
# Informational only. Drafts are reported, never gated; this command always exits 0
|
|
22
|
+
# on a successful read.
|
|
23
|
+
class Coverage < Base
|
|
24
|
+
help_summary 'Show which draft requirements have evidence on which surfaces (never gated)'
|
|
25
|
+
help_usage 'fp coverage [--project <slug>] [--surface X] [--all]'
|
|
26
|
+
help_flag :project, 'Project slug (falls back to .featureparity.yml)'
|
|
27
|
+
help_flag :surface, 'Limit to one surface'
|
|
28
|
+
help_flag :all, 'Also list the measured requirements (active, or under review) the gate checks'
|
|
29
|
+
help_example 'fp coverage', 'Drafts × surfaces, then the drafts with no evidence'
|
|
30
|
+
help_example 'fp coverage --all --json'
|
|
31
|
+
help_note "Drafts are not enforced: a human activates a draft before fp check gates on it.\n" \
|
|
32
|
+
'A cell reads the same here as it will in the matrix once the draft is active.'
|
|
33
|
+
|
|
34
|
+
KNOWN_FLAGS = {
|
|
35
|
+
project: :string,
|
|
36
|
+
surface: :string,
|
|
37
|
+
all: :boolean
|
|
38
|
+
}.freeze
|
|
39
|
+
|
|
40
|
+
def run(args)
|
|
41
|
+
opts, = parse_flags(args, KNOWN_FLAGS)
|
|
42
|
+
project_config = ProjectConfig.discover
|
|
43
|
+
project_slug = require_project!(opts, project_config)
|
|
44
|
+
project_id = resolve_project_id(project_slug)
|
|
45
|
+
surface = opts[:surface] || project_config.surface
|
|
46
|
+
|
|
47
|
+
result = client.get_parity_with_drafts(project_id, surface: surface)
|
|
48
|
+
unless result[:ok]
|
|
49
|
+
output.error(result[:error], status: result[:status])
|
|
50
|
+
exit 1
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
report = result[:data]['parity'] || {}
|
|
54
|
+
unless report.key?('drafts')
|
|
55
|
+
output.error('This FeatureParity API does not report draft coverage yet (it predates ' \
|
|
56
|
+
'`include_drafts`). Nothing was checked.')
|
|
57
|
+
exit 1
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
render(report, project_slug, surface, all: opts[:all])
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Drafts with no evidence on at least one required surface, as
|
|
64
|
+
# [{ 'slug', 'title', 'surfaces' => [...] }]. "No evidence" is the `missing` state:
|
|
65
|
+
# nothing — not even a stub or a red test — is filed for that surface.
|
|
66
|
+
def self.untested(drafts)
|
|
67
|
+
Array(drafts).filter_map do |row|
|
|
68
|
+
bare = Array(row['cells']).select { |c| c['state'] == 'missing' }.map { |c| c['surface'] }
|
|
69
|
+
next if bare.empty?
|
|
70
|
+
|
|
71
|
+
{ 'slug' => row['slug'], 'title' => row['title'], 'surfaces' => bare }
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# The drafts × surfaces table plus the "no evidence" list, for text output. Shared
|
|
76
|
+
# with `fp check --include-drafts`, so the two can't describe drafts differently.
|
|
77
|
+
def self.print_drafts(output, rows, surfaces, show_status: false)
|
|
78
|
+
if rows.empty?
|
|
79
|
+
puts 'No draft requirements.'
|
|
80
|
+
return
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
headers = %w[SLUG]
|
|
84
|
+
headers << 'STATUS' if show_status
|
|
85
|
+
headers += surfaces
|
|
86
|
+
table = rows.map do |row|
|
|
87
|
+
by_surface = Array(row['cells']).to_h { |c| [c['surface'], c['state']] }
|
|
88
|
+
cells = surfaces.map { |key| by_surface.key?(key) ? Parity.glyph(by_surface[key]) : Parity::NOT_REQUIRED }
|
|
89
|
+
line = [row['slug']]
|
|
90
|
+
line << row['status'] if show_status
|
|
91
|
+
line + cells
|
|
92
|
+
end
|
|
93
|
+
output.table(headers, table)
|
|
94
|
+
puts Parity::LEGEND
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def self.print_untested(untested)
|
|
98
|
+
puts
|
|
99
|
+
if untested.empty?
|
|
100
|
+
puts 'Every draft has evidence on each of its required surfaces.'
|
|
101
|
+
return
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
puts "#{untested.size} draft(s) with no evidence on a required surface:"
|
|
105
|
+
untested.each { |u| puts " #{u['slug']} — no evidence on: #{u['surfaces'].join(', ')}" }
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
private
|
|
109
|
+
|
|
110
|
+
def render(report, project_slug, surface, all:)
|
|
111
|
+
drafts = report['drafts'] || []
|
|
112
|
+
surfaces = report['surfaces'] || []
|
|
113
|
+
untested = self.class.untested(drafts)
|
|
114
|
+
|
|
115
|
+
payload = {
|
|
116
|
+
'project' => project_slug,
|
|
117
|
+
'surface' => surface,
|
|
118
|
+
'surfaces' => surfaces,
|
|
119
|
+
'drafts' => drafts,
|
|
120
|
+
'untested' => untested
|
|
121
|
+
}
|
|
122
|
+
payload['measured'] = report['requirements'] || [] if all
|
|
123
|
+
|
|
124
|
+
output.success(payload) do
|
|
125
|
+
scope = surface ? " (surface: #{surface})" : ''
|
|
126
|
+
puts "Draft coverage: #{project_slug}#{scope}"
|
|
127
|
+
puts
|
|
128
|
+
|
|
129
|
+
if all
|
|
130
|
+
measured = report['requirements'] || []
|
|
131
|
+
puts "Measured by the gate (#{measured.size}):"
|
|
132
|
+
if measured.empty?
|
|
133
|
+
puts 'None — no requirement is active yet.'
|
|
134
|
+
else
|
|
135
|
+
self.class.print_drafts(output, measured, surfaces, show_status: true)
|
|
136
|
+
end
|
|
137
|
+
puts
|
|
138
|
+
puts "Drafts (#{drafts.size}):"
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
self.class.print_drafts(output, drafts, surfaces)
|
|
142
|
+
self.class.print_untested(untested) unless drafts.empty?
|
|
143
|
+
puts
|
|
144
|
+
puts 'Drafts are reported, never gated. A human activates a draft before fp check enforces it.'
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
end
|