1
0
mirror of https://github.com/facebook/proxygen.git synced 2025-08-08 18:02:05 +03:00

getdeps: split monolithic GH actions CI spec up (#1360)

Summary:
Rather than have a single main.yml file containing all off the different
builds, split that up so that we have one file per build environment
(linux, mac, windows).

This has a couple of advantages:

* It is quicker to see the status of just one of the platforms
* Artifact collection for one platform is not blocked pending completion
  of the builds for all systems
* It's a little easier to understand what is happening for a single platform

To support having multiple files I've changed the output-file option to
be an output-dir.

I've included the rm of main.yml in this commit.  Once this gets
imported back to the FB internal system I'll amend in an update to
the helper script that updates all of our opensource builds and run
and amend that.
Pull Request resolved: https://github.com/facebook/folly/pull/1360

Test Plan:
the GH action status on this PR should show three different
actions running, one for each platform.

I updated and ran
`fbcode/opensource/fbcode_builder/getdeps/facebook/update-all-github-actions.sh`
to regenerate all the actions files for FB.

Reviewed By: yfeldblum

Differential Revision: D21310991

Pulled By: wez

fbshipit-source-id: 604ef652c8f746781a4b410c6b996cdee4524e0d
This commit is contained in:
Wez Furlong
2020-04-29 15:26:55 -07:00
committed by Facebook GitHub Bot
parent ac9ed30d40
commit 5de48576f0
3 changed files with 201 additions and 181 deletions

View File

@@ -633,32 +633,11 @@ class GenerateGitHubActionsCmd(ProjectCmdBase):
HostType("windows", None, None),
]
with open(args.output_file, "w") as out:
# Deliberate line break here because the @ and the generated
# symbols are meaningful to our internal tooling when they
# appear in a single token
out.write("# This file was @")
out.write("generated by getdeps.py\n")
out.write(
"""
name: CI
for p in platforms:
self.write_job_for_platform(p, args)
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
"""
)
for p in platforms:
build_opts = setup_build_options(args, p)
self.write_job_for_platform(out, args, build_opts)
def write_job_for_platform(self, out, args, build_opts):
def write_job_for_platform(self, platform, args):
build_opts = setup_build_options(args, platform)
ctx_gen = build_opts.get_context_generator()
loader = ManifestLoader(build_opts, ctx_gen)
manifest = loader.load_manifest(args.project)
@@ -697,78 +676,106 @@ jobs:
job_name = "mac"
runs_on = "macOS-latest"
getdeps = f"{py3} build/fbcode_builder/getdeps.py --allow-system-packages"
out.write(" %s:\n" % job_name)
out.write(" runs-on: %s\n" % runs_on)
out.write(" steps:\n")
out.write(" - uses: actions/checkout@v1\n")
if build_opts.is_windows():
# cmake relies on BOOST_ROOT but GH deliberately don't set it in order
# to avoid versioning issues:
# https://github.com/actions/virtual-environments/issues/319
# Instead, set the version we think we need; this is effectively
# coupled with the boost manifest
# This is the unusual syntax for setting an env var for the rest of
# the steps in a workflow:
# https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
out.write(" - name: Export boost environment\n")
os.makedirs(args.output_dir, exist_ok=True)
output_file = os.path.join(args.output_dir, f"getdeps_{job_name}.yml")
with open(output_file, "w") as out:
# Deliberate line break here because the @ and the generated
# symbols are meaningful to our internal tooling when they
# appear in a single token
out.write("# This file was @")
out.write("generated by getdeps.py\n")
out.write(
' run: "echo ::set-env name=BOOST_ROOT::%BOOST_ROOT_1_69_0%"\n'
)
out.write(" shell: cmd\n")
f"""
name: {job_name}
# The git installation may not like long filenames, so tell it
# that we want it to use them!
out.write(" - name: Fix Git config\n")
out.write(" run: git config --system core.longpaths true\n")
else:
out.write(" - name: Install system deps\n")
out.write(
f" run: sudo {getdeps} install-system-deps --recursive {manifest.name}\n"
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
"""
)
projects = loader.manifests_in_dependency_order()
getdeps = f"{py3} build/fbcode_builder/getdeps.py --allow-system-packages"
for m in projects:
if m != manifest:
out.write(" - name: Fetch %s\n" % m.name)
out.write(f" run: {getdeps} fetch --no-tests {m.name}\n")
out.write(" build:\n")
out.write(" runs-on: %s\n" % runs_on)
out.write(" steps:\n")
out.write(" - uses: actions/checkout@v1\n")
for m in projects:
if m != manifest:
out.write(" - name: Build %s\n" % m.name)
out.write(f" run: {getdeps} build --no-tests {m.name}\n")
if build_opts.is_windows():
# cmake relies on BOOST_ROOT but GH deliberately don't set it in order
# to avoid versioning issues:
# https://github.com/actions/virtual-environments/issues/319
# Instead, set the version we think we need; this is effectively
# coupled with the boost manifest
# This is the unusual syntax for setting an env var for the rest of
# the steps in a workflow:
# https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
out.write(" - name: Export boost environment\n")
out.write(
' run: "echo ::set-env name=BOOST_ROOT::%BOOST_ROOT_1_69_0%"\n'
)
out.write(" shell: cmd\n")
out.write(" - name: Build %s\n" % manifest.name)
# The git installation may not like long filenames, so tell it
# that we want it to use them!
out.write(" - name: Fix Git config\n")
out.write(" run: git config --system core.longpaths true\n")
else:
out.write(" - name: Install system deps\n")
out.write(
f" run: sudo {getdeps} install-system-deps --recursive {manifest.name}\n"
)
project_prefix = ""
if not build_opts.is_windows():
project_prefix = " --project-install-prefix %s:/usr/local" % manifest.name
projects = loader.manifests_in_dependency_order()
out.write(
f" run: {getdeps} build --src-dir=. {manifest.name} {project_prefix}\n"
)
for m in projects:
if m != manifest:
out.write(" - name: Fetch %s\n" % m.name)
out.write(f" run: {getdeps} fetch --no-tests {m.name}\n")
out.write(" - name: Copy artifacts\n")
out.write(
f" run: {getdeps} fixup-dyn-deps "
f"--src-dir=. {manifest.name} _artifacts/{job_name} --final-install-prefix /usr/local\n"
)
for m in projects:
if m != manifest:
out.write(" - name: Build %s\n" % m.name)
out.write(f" run: {getdeps} build --no-tests {m.name}\n")
out.write(" - uses: actions/upload-artifact@master\n")
out.write(" with:\n")
out.write(" name: %s\n" % manifest.name)
out.write(" path: _artifacts\n")
out.write(" - name: Build %s\n" % manifest.name)
out.write(" - name: Test %s\n" % manifest.name)
out.write(
f" run: {getdeps} test --src-dir=. {manifest.name} {project_prefix}\n"
)
project_prefix = ""
if not build_opts.is_windows():
project_prefix = (
" --project-install-prefix %s:/usr/local" % manifest.name
)
out.write(
f" run: {getdeps} build --src-dir=. {manifest.name} {project_prefix}\n"
)
out.write(" - name: Copy artifacts\n")
out.write(
f" run: {getdeps} fixup-dyn-deps "
f"--src-dir=. {manifest.name} _artifacts/{job_name} --final-install-prefix /usr/local\n"
)
out.write(" - uses: actions/upload-artifact@master\n")
out.write(" with:\n")
out.write(" name: %s\n" % manifest.name)
out.write(" path: _artifacts\n")
out.write(" - name: Test %s\n" % manifest.name)
out.write(
f" run: {getdeps} test --src-dir=. {manifest.name} {project_prefix}\n"
)
def setup_project_cmd_parser(self, parser):
parser.add_argument("--output-file", help="The name of the yaml file")
parser.add_argument(
"--output-dir", help="The directory that will contain the yml files"
)
def get_arg_var_name(args):