Skip to content

Commit d8f9352

Browse files
authored
Revert the tmt lint schema failure (teemtee#4481)
The original intention was to implement what is said in this [comment](teemtee#4445 (comment)). The issue I ran into is that when I have `tmt lint` emit a schema (pass or warn) if the only error is the `detect_missing_required_properties`, then it still fails because almost always this check `detect_enum_violations` also fails when a required key is missing. `detect_enum_violations` is triggered when `how` is used and the required key is missing because it cycles through all of the values and tells you when the first 9/10 did not match. Cursor analysis of why this occurs (better explanation than mine): > Explaining why enum violations only appear when the required property is missing: > The schema uses `oneOf` for the report step, which requires exactly one schema to match. Here's what happens: > When the `project` key (required property) is present: > The `reportportal` schema matches (`how: reportportal` and `project` are present) > Since `oneOf` requires exactly one match and reportportal matches, validation succeeds > No enum violations occur because the validator doesn't try other schemas > When the `project` key (required property) is missing: > The `reportportal` schema fails (missing required `project`) > Since `oneOf` requires exactly one match and `reportportal` failed, the validator tries other schemas (display, html, junit, polarion) > Each alternative fails because `how: reportportal` doesn't match their enum values (they expect how: display, how: html, etc.) > These enum violations are reported as the validator tries each alternative So, it's not simple to turn _only_ the missing required key into a warning in `tmt lint` since even if that error is not counted, another error still occurs, still resulting in an overall `tmt lint` failure. After some discussion with @LecrisUT, @happz, and @thrix, reverting the FAIL to a WARN would unblock the CI failures for teemtee#4178, while we work on a better overall solution where teemtee#3618 can be reimplemented, and teemtee#4178 is still resolved. The ticket for the better solution is teemtee#4483 This PR reverts the tmt lint schema failure implemented to fix issue teemtee#3618. Fixes: teemtee#4178
1 parent 56751d4 commit d8f9352

File tree

6 files changed

+21
-14
lines changed

6 files changed

+21
-14
lines changed

docs/releases/pending/4178.fmf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
description: |
2+
The ``tmt lint`` command no longer fails with an
3+
exit code 1 when any schema validation warnings are emitted,
4+
it now emits a warn with an exit code 0. This reverts the
5+
behavior added in tmt-1.55.0, until a better solution can
6+
be implemented.

tests/lint/all/test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ rlJournalStart
6262
rlPhaseEnd
6363

6464
rlPhaseStartTest "Check --fix for tests"
65-
rlRun -s "tmt lint --fix fix" 1 "Fix the test"
65+
rlRun -s "tmt lint --fix fix" 0 "Fix the test"
6666
rlAssertGrep 'relevancy converted into adjust' $rlRun_LOG
6767
rlRun -s "tmt lint fix" 0 "Should pass after fix"
6868
rlPhaseEnd

tests/lint/plan/test.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ rlJournalStart
4343
rlAssertGrep "warn C000 value of \"how\" is not \"fmf\"" $rlRun_LOG
4444
rlAssertGrep "warn C000 value of \"how\" is not \"tmt\"" $rlRun_LOG
4545
rlAssertGrep "warn C000 value of \"how\" is not \"upgrade\"" $rlRun_LOG
46-
rlAssertGrep "fail C000 fmf node failed schema validation" $rlRun_LOG
46+
rlAssertGrep "warn C000 fmf node failed schema validation" $rlRun_LOG
4747
rlAssertGrep "fail P003 unknown execute method \"somehow\" in \"default-0\"" $rlRun_LOG
4848
rlAssertGrep "fail P004 unknown discover method \"somehow\" in \"default-0\"" $rlRun_LOG
4949

@@ -62,13 +62,13 @@ rlJournalStart
6262
rlAssertGrep "fail P005 remote fmf id in \"b\" is invalid, repo 'http://invalid-url' cannot be cloned" $rlRun_LOG
6363

6464
rlRun -s "$tmt plan lint invalid_attr" 1
65-
rlAssertGrep "fail C000 fmf node failed schema validation" $rlRun_LOG
65+
rlAssertGrep "warn C000 fmf node failed schema validation" $rlRun_LOG
6666
rlAssertGrep "warn C001 summary key is missing" $rlRun_LOG
6767
rlAssertGrep "fail P001 unknown key \"discove\" is used" $rlRun_LOG
6868
rlAssertGrep "fail P001 unknown key \"environmen\" is used" $rlRun_LOG
6969
rlAssertGrep "fail P001 unknown key \"summaryABCDEF\" is used" $rlRun_LOG
7070

71-
rlRun -s "$tmt plan lint invalid-plugin-key" 1
71+
rlRun -s "$tmt plan lint invalid-plugin-key" 0
7272
rlAssertGrep 'warn C000 key "wrong" not recognized by schema$' $rlRun_LOG
7373
rlAssertGrep 'warn C000 key "wrong" not recognized by schema /schemas/prepare/feature' $rlRun_LOG
7474

@@ -96,8 +96,9 @@ rlJournalStart
9696
rlPhaseEnd
9797

9898
rlPhaseStartTest "Lint of missing required property"
99-
rlRun -s "$tmt plan lint missing_required" 1
99+
rlRun -s "$tmt plan lint missing_required" 0
100100
rlAssertGrep "warn C000 \"project-id\" is a required property by schema /schemas/report/polarion" "$rlRun_LOG"
101+
rlAssertGrep "warn C000 fmf node failed schema validation" "$rlRun_LOG"
101102
rlPhaseEnd
102103

103104
rlPhaseStartTest "Lint of duplicate ids"

tests/lint/story/test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ rlJournalStart
2020
rlAssertGrep "warn C001 summary should not exceed 50 characters" $rlRun_LOG
2121

2222
rlRun -s "tmt stories lint typo_in_key" 1
23-
rlAssertGrep "fail C000 fmf node failed schema validation" $rlRun_LOG
23+
rlAssertGrep "warn C000 fmf node failed schema validation" $rlRun_LOG
2424
rlAssertGrep "warn C001 summary key is missing" $rlRun_LOG
2525
rlAssertGrep "fail S001 unknown key \"exampleGG\" is used" $rlRun_LOG
2626

2727
rlRun -s "tmt stories lint missing_story" 1
28-
rlAssertGrep "fail C000 fmf node failed schema validation" $rlRun_LOG
28+
rlAssertGrep "warn C000 fmf node failed schema validation" $rlRun_LOG
2929
rlAssertGrep "warn C001 summary key is missing" $rlRun_LOG
3030
rlAssertGrep "pass S001 correct keys are used" $rlRun_LOG
3131
rlAssertGrep "fail S002 story is required" $rlRun_LOG

tests/lint/test/test.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ rlJournalStart
2828
rlPhaseEnd
2929

3030
rlPhaseStartTest "Old yaml"
31-
rlRun -s "tmt test lint old-yaml" 1
31+
rlRun -s "tmt test lint old-yaml" 0
3232
rlAssertGrep "warn: /old-yaml:enabled - 'yes' is not of type 'boolean'" $rlRun_LOG
33-
rlAssertGrep 'fail C000 fmf node failed schema validation' $rlRun_LOG
33+
rlAssertGrep 'warn C000 fmf node failed schema validation' $rlRun_LOG
3434
rlPhaseEnd
3535

3636
rlPhaseStartTest "Bad"
@@ -53,15 +53,15 @@ rlJournalStart
5353
rlAssertGrep "fail T001 unknown key \"serial_number\" is used" $rlRun_LOG
5454
rlRun -s "tmt test lint coverage" 1
5555
rlAssertGrep "fail T006 the 'coverage' field has been obsoleted by 'link'" $rlRun_LOG
56-
rlRun -s "tmt test lint library-missing-url-path" 1
57-
rlAssertGrep 'fail C000 fmf node failed schema validation' $rlRun_LOG
56+
rlRun -s "tmt test lint library-missing-url-path" 0
57+
rlAssertGrep 'warn C000 fmf node failed schema validation' $rlRun_LOG
5858
rlAssertGrep 'is not valid under any of the given schemas' $rlRun_LOG
5959
rlPhaseEnd
6060

6161
rlPhaseStartTest "Fix"
6262
# With --fix relevancy should be converted
63-
rlRun -s "tmt test lint --fix relevancy" 1
64-
rlAssertGrep 'fail C000 fmf node failed schema validation' $rlRun_LOG
63+
rlRun -s "tmt test lint --fix relevancy" 0
64+
rlAssertGrep 'warn C000 fmf node failed schema validation' $rlRun_LOG
6565
rlAssertGrep 'fix T005 relevancy converted into adjust' $rlRun_LOG
6666
# Re-run after --fix fixed the plan
6767
rlRun -s "tmt test lint --fix relevancy" 0

tmt/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1185,7 +1185,7 @@ def detect_errors(error: jsonschema.ValidationError) -> LinterReturn:
11851185
for suberror in error.context:
11861186
yield from detect_errors(suberror)
11871187

1188-
yield LinterOutcome.FAIL, 'fmf node failed schema validation'
1188+
yield LinterOutcome.WARN, 'fmf node failed schema validation'
11891189

11901190
return
11911191

0 commit comments

Comments
 (0)