mirror of
https://github.com/servo/servo.git
synced 2025-08-02 20:20:14 +01:00
Fix the WPT exporter (#30870)
* Fix the WPT exporter * apply fixes by @mrobinson * fix mach test-scripts on NixOS * rename main_branch_name to default_branch
This commit is contained in:
parent
29eb4878ed
commit
0be30b30ce
4 changed files with 17 additions and 11 deletions
|
@ -19,6 +19,7 @@ import dataclasses
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from typing import Callable, Optional
|
from typing import Callable, Optional
|
||||||
|
@ -50,8 +51,12 @@ class LocalGitRepo:
|
||||||
self.path = path
|
self.path = path
|
||||||
self.sync = sync
|
self.sync = sync
|
||||||
|
|
||||||
|
# We pass env to subprocess, which may clobber PATH, so we need to find
|
||||||
|
# git in advance and run the subprocess by its absolute path.
|
||||||
|
self.git_path = shutil.which("git")
|
||||||
|
|
||||||
def run_without_encoding(self, *args, env: dict = {}):
|
def run_without_encoding(self, *args, env: dict = {}):
|
||||||
command_line = ["git"] + list(args)
|
command_line = [self.git_path] + list(args)
|
||||||
logging.info(" → Execution (cwd='%s'): %s",
|
logging.info(" → Execution (cwd='%s'): %s",
|
||||||
self.path, " ".join(command_line))
|
self.path, " ".join(command_line))
|
||||||
|
|
||||||
|
@ -142,9 +147,9 @@ class WPTSync:
|
||||||
suppress_force_push: bool = False
|
suppress_force_push: bool = False
|
||||||
|
|
||||||
def __post_init__(self):
|
def __post_init__(self):
|
||||||
self.servo = GithubRepository(self, self.servo_repo)
|
self.servo = GithubRepository(self, self.servo_repo, "main")
|
||||||
self.wpt = GithubRepository(self, self.wpt_repo)
|
self.wpt = GithubRepository(self, self.wpt_repo, "master")
|
||||||
self.downstream_wpt = GithubRepository(self, self.downstream_wpt_repo)
|
self.downstream_wpt = GithubRepository(self, self.downstream_wpt_repo, "master")
|
||||||
self.local_servo_repo = LocalGitRepo(self.servo_path, self)
|
self.local_servo_repo = LocalGitRepo(self.servo_path, self)
|
||||||
self.local_wpt_repo = LocalGitRepo(self.wpt_path, self)
|
self.local_wpt_repo = LocalGitRepo(self.wpt_path, self)
|
||||||
|
|
||||||
|
|
|
@ -55,9 +55,10 @@ class GithubRepository:
|
||||||
This class allows interacting with a single GitHub repository.
|
This class allows interacting with a single GitHub repository.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, sync: WPTSync, repo: str):
|
def __init__(self, sync: WPTSync, repo: str, default_branch: str):
|
||||||
self.sync = sync
|
self.sync = sync
|
||||||
self.repo = repo
|
self.repo = repo
|
||||||
|
self.default_branch = default_branch
|
||||||
self.org = repo.split("/")[0]
|
self.org = repo.split("/")[0]
|
||||||
self.pulls_url = f"repos/{self.repo}/pulls"
|
self.pulls_url = f"repos/{self.repo}/pulls"
|
||||||
|
|
||||||
|
@ -105,7 +106,7 @@ class GithubRepository:
|
||||||
data = {
|
data = {
|
||||||
"title": title,
|
"title": title,
|
||||||
"head": branch.get_pr_head_reference_for_repo(self),
|
"head": branch.get_pr_head_reference_for_repo(self),
|
||||||
"base": "main",
|
"base": self.default_branch,
|
||||||
"body": body,
|
"body": body,
|
||||||
"maintainer_can_modify": False,
|
"maintainer_can_modify": False,
|
||||||
}
|
}
|
||||||
|
|
|
@ -190,7 +190,7 @@ class CreateOrUpdateBranchForPRStep(Step):
|
||||||
return branch_name
|
return branch_name
|
||||||
finally:
|
finally:
|
||||||
try:
|
try:
|
||||||
run.sync.local_wpt_repo.run("checkout", "main")
|
run.sync.local_wpt_repo.run("checkout", "master")
|
||||||
run.sync.local_wpt_repo.run("branch", "-D", branch_name)
|
run.sync.local_wpt_repo.run("branch", "-D", branch_name)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -644,17 +644,17 @@ def setUpModule():
|
||||||
suppress_force_push=True,
|
suppress_force_push=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
def setup_mock_repo(repo_name, local_repo):
|
def setup_mock_repo(repo_name, local_repo, default_branch: str):
|
||||||
subprocess.check_output(
|
subprocess.check_output(
|
||||||
["cp", "-R", "-p", os.path.join(TESTS_DIR, repo_name), local_repo.path])
|
["cp", "-R", "-p", os.path.join(TESTS_DIR, repo_name), local_repo.path])
|
||||||
local_repo.run("init", "-b", "main")
|
local_repo.run("init", "-b", default_branch)
|
||||||
local_repo.run("add", ".")
|
local_repo.run("add", ".")
|
||||||
local_repo.run("commit", "-a", "-m", "Initial commit")
|
local_repo.run("commit", "-a", "-m", "Initial commit")
|
||||||
|
|
||||||
logging.info("=" * 80)
|
logging.info("=" * 80)
|
||||||
logging.info("Setting up mock repositories")
|
logging.info("Setting up mock repositories")
|
||||||
setup_mock_repo("servo-mock", SYNC.local_servo_repo)
|
setup_mock_repo("servo-mock", SYNC.local_servo_repo, "main")
|
||||||
setup_mock_repo("wpt-mock", SYNC.local_wpt_repo)
|
setup_mock_repo("wpt-mock", SYNC.local_wpt_repo, "master")
|
||||||
logging.info("=" * 80)
|
logging.info("=" * 80)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue