Skip to content

Allow non-exact matching for ids in cli subcommands (New)#1964

Merged
Hook25 merged 8 commits intomainfrom
non_exact_ids
Jul 9, 2025
Merged

Allow non-exact matching for ids in cli subcommands (New)#1964
Hook25 merged 8 commits intomainfrom
non_exact_ids

Conversation

@Hook25
Copy link
Copy Markdown
Collaborator

@Hook25 Hook25 commented Jun 18, 2025

Description

It is often bothersome, and rarely useful, to include the namespace for all ids in the checkbox-cli subcommands.

This changes them all so that any id provided will be searched both as a namespace::id and a ?::id input. This doesn't affect the user that provides the namespace, but makes it way more accessible for all users to use these tools.

Whenever this behaviour is not desirable, for whatever reason, --exact can be provided to all changed subcommands to have the old behaviour back.

Resolved issues

Fixes: https://warthogs.atlassian.net/browse/CHECKBOX-1951

Documentation

Documents the new --exact option

Tests

Tested new functions added (most)
Launched manually the commands with the new and old behaviour, ie.

checkbox-cli show sru
checkbox-cli show com.canonical.certification::sru
checkbox-cli show com.canonical.certification::sru --exact

should all yield the same result

@Hook25 Hook25 changed the title New: Allow non-exact matching for ids in cli subcommands Allow non-exact matching for ids in cli subcommands (New) Jun 18, 2025
@codecov
Copy link
Copy Markdown

codecov bot commented Jun 18, 2025

Codecov Report

❌ Patch coverage is 72.41379% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.64%. Comparing base (ada9397) to head (0921738).
⚠️ Report is 127 commits behind head on main.

Files with missing lines Patch % Lines
checkbox-ng/checkbox_ng/launcher/subcommands.py 62.79% 14 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1964      +/-   ##
==========================================
+ Coverage   50.55%   50.64%   +0.09%     
==========================================
  Files         384      384              
  Lines       41116    41222     +106     
  Branches     7628     7658      +30     
==========================================
+ Hits        20786    20878      +92     
- Misses      19586    19597      +11     
- Partials      744      747       +3     
Flag Coverage Δ
checkbox-ng 70.37% <72.41%> (+0.11%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Hook25 added 2 commits June 18, 2025 15:32
Minor: fixed missing import
Minor: raise system exit when more than 1 is found
Copy link
Copy Markdown
Collaborator

@pieqq pieqq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally, works as advertised, it's really nice! I tried it with expand, list-bootstrapped and show.

One request with regard to help and docs:

Currently, commands that take a test plan as input have an help screen that looks like this:

checkbox-cli expand -h
usage: checkbox-cli [-h] [-f FORMAT] [--exact] TEST_PLAN

Expand a given test plan: display all the jobs, templates and manifest entries that are defined in this test plan and that  would be executed if ran. This is useful to visualize the full list of units called for complex test plans that consist of many nested parts with different 'include' and 'exclude' sections.

NOTE: the elements listed here are not sorted by execution order. To see the execution order, please use the 'list-bootstrapped' command instead.

positional arguments:
  TEST_PLAN             test-plan id to expand

options:
  -h, --help            show this help message and exit
  -f FORMAT, --format FORMAT
                        output format: 'text' or 'json' (default: text)
  --exact               only expand the test-plan that exactly matches

Can you:

  • improve the help text for TEST_PLAN (for example, for above, testplan id to expand (namespace can be omitted) or something like that)
  • reword the help for exact (e.g. only expand the testplan that exactly matches the given string (must include namespace))

Can you also update the tutorial page A few more Checkbox commands to explain that namespace is not necessary and to show it? (so, for instance in the list-bootstrapped example, replace list-bootstrapped com.canonical.certification::audio-cert-automated with list-bootstrapped audio-cert-automated). There is a Namespace ref in the glossary that you can point to if needed.

Copy link
Copy Markdown
Collaborator

@fernando79513 fernando79513 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just left two small comments. Can't wait to have this in place. I've just had to write twice the com.canonical.certification this morning.

pieqq
pieqq previously requested changes Jul 2, 2025
Minor: remove typo from the docs
fernando79513
fernando79513 previously approved these changes Jul 8, 2025
Copy link
Copy Markdown
Collaborator

@fernando79513 fernando79513 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM +1!

@fernando79513 fernando79513 self-requested a review July 8, 2025 14:57
@fernando79513 fernando79513 dismissed their stale review July 8, 2025 14:58

Lint check is still failing

Copy link
Copy Markdown
Collaborator

@fernando79513 fernando79513 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM +1!

@Hook25 Hook25 merged commit 19c2f9a into main Jul 9, 2025
58 of 64 checks passed
@Hook25 Hook25 deleted the non_exact_ids branch July 9, 2025 07:05
mreed8855 pushed a commit that referenced this pull request Jul 30, 2025
* Allow non-exact matching for ids in cli subcommands

* Roll back hackaround IQN being dumb

* Test find_children_by_name

Minor: fixed missing import

* Test get_testplan_ids_by_id

Minor: raise system exit when more than 1 is found

* Explain fuzzy matching in a note in the docs

* Better naming of variables

* Mention what has to fully match

* No more FQID -> fully qualified ID

Minor: remove typo from the docs
mreed8855 pushed a commit that referenced this pull request Jul 31, 2025
* Allow non-exact matching for ids in cli subcommands

* Roll back hackaround IQN being dumb

* Test find_children_by_name

Minor: fixed missing import

* Test get_testplan_ids_by_id

Minor: raise system exit when more than 1 is found

* Explain fuzzy matching in a note in the docs

* Better naming of variables

* Mention what has to fully match

* No more FQID -> fully qualified ID

Minor: remove typo from the docs
bladernr pushed a commit that referenced this pull request Aug 28, 2025
* Allow non-exact matching for ids in cli subcommands

* Roll back hackaround IQN being dumb

* Test find_children_by_name

Minor: fixed missing import

* Test get_testplan_ids_by_id

Minor: raise system exit when more than 1 is found

* Explain fuzzy matching in a note in the docs

* Better naming of variables

* Mention what has to fully match

* No more FQID -> fully qualified ID

Minor: remove typo from the docs
stanley31huang pushed a commit that referenced this pull request Oct 3, 2025
* Allow non-exact matching for ids in cli subcommands

* Roll back hackaround IQN being dumb

* Test find_children_by_name

Minor: fixed missing import

* Test get_testplan_ids_by_id

Minor: raise system exit when more than 1 is found

* Explain fuzzy matching in a note in the docs

* Better naming of variables

* Mention what has to fully match

* No more FQID -> fully qualified ID

Minor: remove typo from the docs
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.

3 participants