Skip to content

Commit

Permalink
Top level "no validation" (#264)
Browse files Browse the repository at this point in the history
* no validation should be top level for usage on package or release

* warning message

* no_validation takes priority over no semvar compliance

* docstring
  • Loading branch information
why-not-try-calmer authored Dec 22, 2023
1 parent df39548 commit f94c7f4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
11 changes: 6 additions & 5 deletions qgispluginci/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ def cli():
version=__version__,
)

parser.add_argument(
"--no-validation",
action="store_true",
help="Turn off validation of the version to be released or packaged",
)

subparsers = parser.add_subparsers(
title="commands", description="qgis-plugin-ci command", dest="command"
)
Expand Down Expand Up @@ -71,11 +77,6 @@ def cli():
action="append",
help="An additional asset path to add. Can be specified multiple times.",
)
package_parser.add_argument(
"--no-validation",
action="store_true",
help="Turn off validation of `release version`",
)

# changelog
changelog_parser = subparsers.add_parser(
Expand Down
11 changes: 5 additions & 6 deletions qgispluginci/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,23 +252,22 @@ def validate_args(args: Namespace):
Raise an exception just in case:
- the user didn't opt-out of validation using the `--no-validation` flag; and
- the value of `release_version` matches no supported pattern.
In any case, warn the user if the value of `release_version` doesn't match the semver pattern.
"""
if not hasattr(args, "release_version") or not args.release_version:
return

if args.no_validation:
logging.warning("Disabled release version validation.")
return

patterns = Parameters.get_release_version_patterns()
semver_compliance = re.match(patterns.pop("semver"), args.release_version)

if not semver_compliance:
logging.warning(
f"Be aware that '{args.release_version}' is not a semver-compliant version."
f"Be aware that '{args.release_version}' is not a semver-compliant version. It might still comply with acceptable practices."
)

if args.no_validation:
logging.warning("Disabled release version validation.")
return

if semver_compliance or any(
re.match(other_pattern, args.release_version)
for other_pattern in patterns.values()
Expand Down

0 comments on commit f94c7f4

Please sign in to comment.