forked from Mirror/pmbootstrap
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:
parent
6ac39d17e7
commit
0bcd58765c
5 changed files with 228 additions and 0 deletions
|
@ -12,6 +12,7 @@ import pmb.build.autodetect
|
|||
import pmb.chroot
|
||||
import pmb.chroot.initfs
|
||||
import pmb.chroot.other
|
||||
import pmb.ci
|
||||
import pmb.config
|
||||
import pmb.export
|
||||
import pmb.flasher
|
||||
|
@ -623,3 +624,39 @@ def lint(args):
|
|||
def status(args):
|
||||
if not pmb.helpers.status.print_status(args, args.details):
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def ci(args):
|
||||
topdir = pmb.helpers.git.get_topdir(args, os.getcwd())
|
||||
if not os.path.exists(topdir):
|
||||
logging.error("ERROR: change your current directory to a git"
|
||||
" repository (e.g. pmbootstrap, pmaports) before running"
|
||||
" 'pmbootstrap ci'.")
|
||||
exit(1)
|
||||
|
||||
scripts_available = pmb.ci.get_ci_scripts(topdir)
|
||||
scripts_available = pmb.ci.sort_scripts_by_speed(scripts_available)
|
||||
if not scripts_available:
|
||||
logging.error("ERROR: no supported CI scripts found in current git"
|
||||
" repository, see https://postmarketos.org/pmb-ci")
|
||||
exit(1)
|
||||
|
||||
scripts_selected = {}
|
||||
if args.scripts:
|
||||
for script in args.scripts:
|
||||
if script not in scripts_available:
|
||||
logging.error(f"ERROR: script '{script}' not found in git"
|
||||
" repository, found these:"
|
||||
f" {', '.join(scripts_available.keys())}")
|
||||
exit(1)
|
||||
scripts_selected[script] = scripts_available[script]
|
||||
elif args.all:
|
||||
scripts_selected = scripts_available
|
||||
|
||||
if not pmb.helpers.git.clean_worktree(args, topdir):
|
||||
logging.warning("WARNING: this git repository has uncommitted changes")
|
||||
|
||||
if not scripts_selected:
|
||||
scripts_selected = pmb.ci.ask_which_scripts_to_run(scripts_available)
|
||||
|
||||
pmb.ci.run_scripts(args, topdir, scripts_selected)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue