mirror of
https://github.com/facebook/proxygen.git
synced 2025-08-08 18:02:05 +03:00
Allow a project to have Actions run on all branches
Summary: - I find the ability to make a branch and play with CI on GitHub super handy - Removing the `- master` limitation gives me this ability Reviewed By: yi-xian Differential Revision: D22771835 fbshipit-source-id: 8e8839cb860ab4d1dfa0dda590afaf165127f60d
This commit is contained in:
committed by
Facebook GitHub Bot
parent
90a27aa52b
commit
90c201fc23
@@ -723,6 +723,15 @@ class TestCmd(ProjectCmdBase):
|
|||||||
|
|
||||||
@cmd("generate-github-actions", "generate a GitHub actions configuration")
|
@cmd("generate-github-actions", "generate a GitHub actions configuration")
|
||||||
class GenerateGitHubActionsCmd(ProjectCmdBase):
|
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):
|
def run_project_cmd(self, args, loader, manifest):
|
||||||
platforms = [
|
platforms = [
|
||||||
HostType("linux", "ubuntu", "18"),
|
HostType("linux", "ubuntu", "18"),
|
||||||
@@ -733,12 +742,14 @@ class GenerateGitHubActionsCmd(ProjectCmdBase):
|
|||||||
for p in platforms:
|
for p in platforms:
|
||||||
self.write_job_for_platform(p, args)
|
self.write_job_for_platform(p, args)
|
||||||
|
|
||||||
def write_job_for_platform(self, platform, args):
|
# TODO: Break up complex function
|
||||||
|
def write_job_for_platform(self, platform, args): # noqa: C901
|
||||||
build_opts = setup_build_options(args, platform)
|
build_opts = setup_build_options(args, platform)
|
||||||
ctx_gen = build_opts.get_context_generator()
|
ctx_gen = build_opts.get_context_generator()
|
||||||
loader = ManifestLoader(build_opts, ctx_gen)
|
loader = ManifestLoader(build_opts, ctx_gen)
|
||||||
manifest = loader.load_manifest(args.project)
|
manifest = loader.load_manifest(args.project)
|
||||||
manifest_ctx = loader.ctx_gen.get_context(manifest.name)
|
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
|
||||||
|
|
||||||
# Some projects don't do anything "useful" as a leaf project, only
|
# 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
|
# as a dep for a leaf project. Check for those here; we don't want
|
||||||
@@ -785,13 +796,7 @@ class GenerateGitHubActionsCmd(ProjectCmdBase):
|
|||||||
f"""
|
f"""
|
||||||
name: {job_name}
|
name: {job_name}
|
||||||
|
|
||||||
on:
|
on:{run_on}
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
"""
|
"""
|
||||||
@@ -891,6 +896,11 @@ jobs:
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--output-dir", help="The directory that will contain the yml files"
|
"--output-dir", help="The directory that will contain the yml files"
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--run-on-all-branches",
|
||||||
|
action="store_true",
|
||||||
|
help="Allow CI to fire on all branches - Handy for testing",
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--ubuntu-version", default="18.04", help="Version of Ubuntu to use"
|
"--ubuntu-version", default="18.04", help="Version of Ubuntu to use"
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user