pmbootstrap ci: new command

Add a new command that makes running CI scripts easy. The user goes to
the git repository of choice, which has CI scripts written in a certain
format, and then runs 'pmbootstrap ci' to get an interactive selection
of which of the available scripts to run (or "all"). Specifying one or
multiple scripts on the command-line is also possible, e.g.

$ pmbootstrap ci flake8
$ pmbootstrap ci shellcheck flake8 pytest
$ pmbootstrap ci --all

pmbootstrap then either runs the selected scripts in a chroot (and
installs dependencies as defined at the beginning of the CI scripts), or
natively (with checks inside the scripts for having dependencies
installed). Running natively is needed for .ci/pytest.sh in this
pmbootstrap.git repository, as pmbootstrap can't run inside pmbootstrap.
Running natively or in chroot is defined in an "# Options: " comment
inside the script file.

Documentation for this command and how script files look like:
https://postmarketos.org/pmb-ci
This commit is contained in:
Oliver Smith 2022-10-20 21:08:42 +02:00
parent 6ac39d17e7
commit 0bcd58765c
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
5 changed files with 228 additions and 0 deletions

View file

@ -546,6 +546,19 @@ def arguments_netboot(subparser):
return ret
def arguments_ci(subparser):
ret = subparser.add_parser("ci", help="run continuous integration scripts"
" locally of git repo in current"
" directory")
ret.add_argument("-a", "--all", action="store_true",
help="name of the CI script to run, depending on the git"
" repository")
ret.add_argument("scripts", nargs="*", metavar="script",
help="name of the CI script to run, depending on the git"
" repository")
return ret
def package_completer(prefix, action, parser=None, parsed_args=None):
args = parsed_args
pmb.config.merge_with_args(args)
@ -693,6 +706,7 @@ def arguments():
arguments_newapkbuild(sub)
arguments_lint(sub)
arguments_status(sub)
arguments_ci(sub)
# Action: log
log = sub.add_parser("log", help="follow the pmbootstrap logfile")