aboutsummaryrefslogtreecommitdiffstats
path: root/python/servo/devenv_commands.py
diff options
context:
space:
mode:
authorSamson <16504129+sagudev@users.noreply.github.com>2024-01-26 13:29:37 +0100
committerGitHub <noreply@github.com>2024-01-26 12:29:37 +0000
commita5c512808a0fd58a46220c2651003143add87543 (patch)
tree889106b1d9b1867bb554972c5ed220f68f7a4ea5 /python/servo/devenv_commands.py
parent266a082206fe55f7d49163a015c2a65c4a360a8b (diff)
downloadservo-a5c512808a0fd58a46220c2651003143add87543.tar.gz
servo-a5c512808a0fd58a46220c2651003143add87543.zip
Matrix in CI and `mach try` with presets (#31141)
* Matrix in CI and mach try with presets * small fixups * names in trigger try run comment * let * f * rename step * fix running try on win * fix try branch full * py3.10 * typo * Make unit-tests default to false, except in basic os runs Fixes https://github.com/servo/servo/issues/31174 * make full use linux-wpt & linux-wpt also include unit-tests so full is equal to main workflow * Stylish fixes * cmp json as dict
Diffstat (limited to 'python/servo/devenv_commands.py')
-rw-r--r--python/servo/devenv_commands.py75
1 files changed, 31 insertions, 44 deletions
diff --git a/python/servo/devenv_commands.py b/python/servo/devenv_commands.py
index dd4009fe8c2..ed260cf8b3b 100644
--- a/python/servo/devenv_commands.py
+++ b/python/servo/devenv_commands.py
@@ -22,17 +22,7 @@ from mach.decorators import (
)
from servo.command_base import CommandBase, cd, call
-
-VALID_TRY_BRACHES = [
- "try",
- "try-linux",
- "try-mac",
- "try-windows",
- "try-wpt",
- "try-wpt-2020",
- "try-wpt-mac",
- "try-wpt-mac-2020"
-]
+from servo.try_parser import Config
@CommandProvider
@@ -284,38 +274,35 @@ class MachCommands(CommandBase):
return p.wait()
@Command('try',
- description='Runs try jobs by force pushing to personal fork try branches',
+ description='Runs try jobs by force pushing to try branch',
category='devenv')
@CommandArgument(
- 'jobs', default=["try"], nargs='...',
- help="Name(s) of job(s) (ex: try, linux, mac, windows, wpt)")
- def try_jobs(self, jobs):
- branches = []
- # we validate branches because force pushing is destructive
- for job in jobs:
- # branches must start with try-
- if "try" not in job:
- job = "try-" + job
- if job not in VALID_TRY_BRACHES:
- print(job + " job doesn't exist")
- return -1
- branches.append(job)
- remote = "origin"
- if "servo/servo" in subprocess.check_output(["git", "config", "--get", "remote.origin.url"]).decode():
- # if we have servo/servo for origin check try remote
- try:
- if "servo/servo" in subprocess.check_output(["git", "config", "--get", "remote.try.url"]).decode():
- # User has servo/servo for try remote
- print("You should not use servo/servo for try remote!")
- return -1
- else:
- remote = "try"
- except subprocess.CalledProcessError:
- print("It looks like you are patching in upstream servo.")
- print("Set try remote to your personal fork with `git remote add try https://github.com/user/servo`")
- return -1
- for b in branches:
- res = call(["git", "push", remote, "--force", f"HEAD:{b}"], env=self.build_env())
- if res != 0:
- return res
- return 0
+ '--remote', '-r', default="origin",
+ help='git remote to use for try pushes')
+ @CommandArgument(
+ 'try_string', default=None, nargs='...',
+ help="Try string")
+ def try_jobs(self, remote="origin", try_string=None):
+ if not try_string:
+ try_string = "full"
+ else:
+ try_string = " ".join(try_string)
+ conf = Config(try_string)
+ result = call(["git", "commit", "--allow-empty", "-m", try_string, "-m", f"{conf.to_json()}"])
+ if result != 0:
+ return result
+
+ git_remote = subprocess.check_output(["git", "config", "--get", f"remote.{remote}.url"]).decode()
+ if "servo/servo" in git_remote:
+ print("WARNING: You are triggering try build in upstream repo!")
+
+ result = call(["git", "push", remote, "--force", "HEAD:try"])
+ if result != 0:
+ return result
+
+ git_remote = git_remote.replace(".git", "/actions")
+ print(f"You can find triggered workflow here: {git_remote}")
+
+ # Remove the last commit which only contains the try configuration.
+ result += call(["git", "reset", "--soft", "HEAD~1"])
+ return result