mirror of
https://github.com/facebook/proxygen.git
synced 2025-08-05 19:55:47 +03:00
add support to custom main branch name
Summary: This diff adds support to customize main branch name when generating GitHub Actions. Differential Revision: D30679305 fbshipit-source-id: 0fc7eb1c97c27e2b42e60cc1ab69a48ab93b93fa
This commit is contained in:
committed by
Facebook GitHub Bot
parent
1d1e764697
commit
a1c00f89da
@@ -772,13 +772,6 @@ class TestCmd(ProjectCmdBase):
|
||||
@cmd("generate-github-actions", "generate a GitHub actions configuration")
|
||||
class GenerateGitHubActionsCmd(ProjectCmdBase):
|
||||
RUN_ON_ALL = """ [push, pull_request]"""
|
||||
RUN_ON_DEFAULT = """
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- master"""
|
||||
|
||||
def run_project_cmd(self, args, loader, manifest):
|
||||
platforms = [
|
||||
@@ -790,6 +783,17 @@ class GenerateGitHubActionsCmd(ProjectCmdBase):
|
||||
for p in platforms:
|
||||
self.write_job_for_platform(p, args)
|
||||
|
||||
def get_run_on(self, args):
|
||||
if args.run_on_all_branches:
|
||||
return self.RUN_ON_ALL
|
||||
return f"""
|
||||
push:
|
||||
branches:
|
||||
- {args.main_branch}
|
||||
pull_request:
|
||||
branches:
|
||||
- {args.main_branch}"""
|
||||
|
||||
# TODO: Break up complex function
|
||||
def write_job_for_platform(self, platform, args): # noqa: C901
|
||||
build_opts = setup_build_options(args, platform)
|
||||
@@ -797,7 +801,7 @@ class GenerateGitHubActionsCmd(ProjectCmdBase):
|
||||
loader = ManifestLoader(build_opts, ctx_gen)
|
||||
manifest = loader.load_manifest(args.project)
|
||||
manifest_ctx = loader.ctx_gen.get_context(manifest.name)
|
||||
run_on = self.RUN_ON_ALL if args.run_on_all_branches else self.RUN_ON_DEFAULT
|
||||
run_on = self.get_run_on(args)
|
||||
|
||||
# Some projects don't do anything "useful" as a leaf project, only
|
||||
# as a dep for a leaf project. Check for those here; we don't want
|
||||
@@ -945,6 +949,11 @@ jobs:
|
||||
parser.add_argument(
|
||||
"--ubuntu-version", default="18.04", help="Version of Ubuntu to use"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--main-branch",
|
||||
default="master",
|
||||
help="Main branch to trigger GitHub Action on",
|
||||
)
|
||||
|
||||
|
||||
def get_arg_var_name(args):
|
||||
|
Reference in New Issue
Block a user