polylith icon indicating copy to clipboard operation
polylith copied to clipboard

Enable the option to treat validation warnings as errors

Open tengstrand opened this issue 7 months ago • 1 comments

Today, the test command will not run if we have errors in the workspace, and if we run the check command it will return 0 (zero) only if there are no errors in the workspace.

If you prefer a stricter approach and want to avoid warnings in your workspace, it would be beneficial to have the option to disallow warnings.

The suggestion is that we add this key to workspace.edn:

{
  ...
  :allow-warnings true
}

If set to true then we get today's behavior, but if set to false then some commands, and the public API, will treat warnings more strictly.

check

:allow-warnings is set to false: Warnings will now be treated as errors, causing them to be displayed and returning the corresponding warning code (2xx), which can be used in scripts.

:allow-warnings is set to true: We get the today's behavior that displays OK and returns 0 (zero) if there are no errors, but allows warnings.

test

:allow-warnings is set to false: If warnings are present, they will be displayed, execution will stop, and the warning code will be returned, mirroring the behavior for errors.

:allow-warnings is set to true: We get today's behavior where the execution stops only if we have errors (warnings are ignored).

check - public API

The check command in the public API, will also be affected.

:allow-warnings is set to false: Will treat warnings in the same ways as errors, for example:

{:ok? false
 :error-messages [{:type "warning",
                   :code 202,
                   :message "Missing paths was found"}]}

:allow-warnings is set to true: The above example will work as today and notify that the workspace is okay:

{:ok? true
 :error-messages []}

test - public API

:allow-warnings is set to false: The test command in the public API will treat the workspace as invalid if there are any warnings, and it will stop the execution without running any tests.

{:ok? false}

:allow-warnings is set to false: Will have today's behavior where it treats the workspace as invalid if it has errors, and stop the execution, but will allow warnings. The error message is printed, returning false if errors are present and true otherwise:

{:ok? true}

tengstrand avatar Jun 30 '24 10:06 tengstrand