diff --git a/plans/license-validate/README.md b/plans/license-validate/README.md new file mode 100644 index 0000000..0d518f1 --- /dev/null +++ b/plans/license-validate/README.md @@ -0,0 +1,10 @@ +# License Validate + +Check if the License tag is SPDX formula and contains only allowed licenses. +Run [license-validate] on the SPEC file. + +## See Also + +- [license-validate] + +[license-validate]: https://github.com/fedora-copr/license-validate diff --git a/plans/license-validate/main.fmf b/plans/license-validate/main.fmf new file mode 100644 index 0000000..9c17725 --- /dev/null +++ b/plans/license-validate/main.fmf @@ -0,0 +1,12 @@ +summary: Run license-validate on the SPEC file + +description: | + Check if the License tag is SPDX formula and contains only allowed licenses. + +provision: + how: container + image: fedora:latest + +discover: + how: fmf + test: /tests/license-validate diff --git a/tests/license-validate/distgit-prepare.py b/tests/license-validate/distgit-prepare.py new file mode 120000 index 0000000..e2c9bb6 --- /dev/null +++ b/tests/license-validate/distgit-prepare.py @@ -0,0 +1 @@ +../rpmlint/distgit-prepare.py \ No newline at end of file diff --git a/tests/license-validate/main.fmf b/tests/license-validate/main.fmf new file mode 100644 index 0000000..46314a4 --- /dev/null +++ b/tests/license-validate/main.fmf @@ -0,0 +1,27 @@ +/: + inherit: false + +/prepare-distgit: + summary: Prepare with distgit environment + enabled: false + duration: 30m + order: 40 + require: + - koji + - git + test: python3 ./distgit-prepare.py + adjust: + # TODO: For now this is only available for distgit commits + when: initiator == fedora-ci and trigger == commit + enabled: true + +/run-license-validate: + summary: Run license-validate + duration: 30m + require: + - license-validate + # soft requirement of python3-specfile + - redhat-rpm-config + # can remove when license-validate-29 lands stable + - python3-specfile + test: python3 ./run-license-validate.py diff --git a/tests/license-validate/run-license-validate.py b/tests/license-validate/run-license-validate.py new file mode 100755 index 0000000..02da5f6 --- /dev/null +++ b/tests/license-validate/run-license-validate.py @@ -0,0 +1,37 @@ +#!/usr/bin/python3 +# /// script +# dependencies = [ ] +# /// + +import argparse +import os +import subprocess +import sys + + +def main(args: argparse.Namespace) -> None: + """ + Run rpmlint + """ + rpmlint_args = [] + if args.spec_file: + rpmlint_args.append(args.spec_file) + print(f"Running: license-validate -v --spec {rpmlint_args}") + result = subprocess.run(["license-validate", "-v", "--spec", *rpmlint_args]) + if result.returncode != 0: + print(f"Error: license-validate failed with exit code {result.returncode}") + sys.exit(1) + + +if __name__ == "__main__": + parser = argparse.ArgumentParser( + description="Simple wrapper for license-validate. Can also pass variables via environment variables." + ) + parser.add_argument( + "--spec-file", + help="Spec file to check.", + default=os.environ.get("SPEC_FILE"), + ) + + args = parser.parse_args() + main(args)