Skip to content

Commit d474e65

Browse files
ahornbymeta-codesync[bot]
authored andcommitted
renable github actions for linux
Summary: X-link: facebook/sapling#1135 Renable mononoke linux github actions so that folks externally can see that it current builds, and so they can see the breaks easily if it later doesn't build. Added support for pinning rust version as during developement needed to pin to rust 1.90 as didn't yet compile with 1.91. In the meantime 1.91 support landed so pinned to 1.91. Also saw that it was running out of disk space on the github actions runner so switched it to use MinSizeRel cmake build type and added a cargo mapping for it Reviewed By: genevievehelsel Differential Revision: D82818583 fbshipit-source-id: 6f0c54caa5b9593135a6977b1409f416ca622d81
1 parent 3462acf commit d474e65

4 files changed

Lines changed: 44 additions & 14 deletions

File tree

build/fbcode_builder/getdeps.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -964,6 +964,13 @@ def setup_project_cmd_parser(self, parser):
964964
default=None,
965965
help="Timeout in seconds for each individual test",
966966
)
967+
parser.add_argument(
968+
"--build-type",
969+
help="Set the build type explicitly. Cmake and cargo builders act on them. Only Debug and RelWithDebInfo widely supported.",
970+
choices=["Debug", "Release", "RelWithDebInfo", "MinSizeRel"],
971+
action="store",
972+
default=None,
973+
)
967974

968975

969976
@cmd(
@@ -1049,6 +1056,13 @@ def write_job_for_platform(self, platform, args): # noqa: C901
10491056
args.enable_tests
10501057
and manifest.get("github.actions", "run_tests", ctx=manifest_ctx) != "off"
10511058
)
1059+
rust_version = (
1060+
manifest.get("github.actions", "rust_version", ctx=manifest_ctx) or "stable"
1061+
)
1062+
1063+
override_build_type = args.build_type or manifest.get(
1064+
"github.actions", "build_type", ctx=manifest_ctx
1065+
)
10521066
if run_tests:
10531067
manifest_ctx.set("test", "on")
10541068
run_on = self.get_run_on(args)
@@ -1163,8 +1177,8 @@ def write_job_for_platform(self, platform, args): # noqa: C901
11631177
out.write(" - uses: actions/checkout@v4\n")
11641178

11651179
build_type_arg = ""
1166-
if args.build_type:
1167-
build_type_arg = f"--build-type {args.build_type} "
1180+
if override_build_type:
1181+
build_type_arg = f"--build-type {override_build_type} "
11681182

11691183
if build_opts.free_up_disk:
11701184
free_up_disk = "--free-up-disk "
@@ -1241,8 +1255,8 @@ def write_job_for_platform(self, platform, args): # noqa: C901
12411255
or builder_name == "cargo"
12421256
or mbuilder_name == "cargo"
12431257
):
1244-
out.write(" - name: Install Rust Stable\n")
1245-
out.write(" uses: dtolnay/rust-toolchain@stable\n")
1258+
out.write(f" - name: Install Rust {rust_version.capitalize()}\n")
1259+
out.write(f" uses: dtolnay/rust-toolchain@{rust_version}\n")
12461260
break
12471261

12481262
# Normal deps that have manifests
@@ -1360,7 +1374,7 @@ def write_job_for_platform(self, platform, args): # noqa: C901
13601374

13611375
out.write(" - name: Test %s\n" % manifest.name)
13621376
out.write(
1363-
f" run: {getdepscmd}{allow_sys_arg} test {num_jobs_arg}--src-dir=. {manifest.name}{project_prefix}\n"
1377+
f" run: {getdepscmd}{allow_sys_arg} test {build_type_arg}{num_jobs_arg}--src-dir=. {manifest.name}{project_prefix}\n"
13641378
)
13651379
if build_opts.free_up_disk and not build_opts.is_windows():
13661380
out.write(" - name: Show disk space at end\n")

build/fbcode_builder/getdeps/cargo.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def cargo_config_file(self):
9595
if self.cargo_config_file_subdir:
9696
return os.path.join(build_source_dir, self.cargo_config_file_subdir)
9797
else:
98-
return os.path.join(build_source_dir, ".cargo", "config")
98+
return os.path.join(build_source_dir, ".cargo", "config.toml")
9999

100100
def _create_cargo_config(self):
101101
cargo_config_file = self.cargo_config_file()
@@ -122,8 +122,12 @@ def _create_cargo_config(self):
122122
[profile.dev]
123123
debug = false
124124
incremental = false
125+
126+
[profile.release]
127+
opt-level = "{}"
125128
""".format(
126-
self.build_dir.replace("\\", "\\\\")
129+
self.build_dir.replace("\\", "\\\\"),
130+
"z" if self.build_opts.build_type == "MinSizeRel" else "s",
127131
)
128132

129133
# Point to vendored sources from getdeps manifests
@@ -173,7 +177,7 @@ def _build(self, reconfigure) -> None:
173177
build_source_dir = self.build_source_dir()
174178

175179
build_args = [
176-
"--out-dir",
180+
"--artifact-dir",
177181
os.path.join(self.inst_dir, "bin"),
178182
"-Zunstable-options",
179183
]
@@ -206,20 +210,26 @@ def _build(self, reconfigure) -> None:
206210
def run_tests(
207211
self, schedule_type, owner, test_filter, retry, no_testpilot, timeout=None
208212
) -> None:
213+
build_args = []
214+
if self.build_opts.build_type != "Debug":
215+
build_args.append("--release")
216+
209217
if test_filter:
210-
args = ["--", test_filter]
218+
filter_args = ["--", test_filter]
211219
else:
212-
args = []
220+
filter_args = []
213221

214222
if self.manifests_to_build is None:
215-
self.run_cargo(self.install_dirs, "test", args)
216-
if self.build_doc:
223+
self.run_cargo(self.install_dirs, "test", build_args + filter_args)
224+
if self.build_doc and not filter_args:
217225
self.run_cargo(self.install_dirs, "doc", ["--no-deps"])
218226
else:
219227
for manifest in self.manifests_to_build:
220228
margs = ["--manifest-path", self.manifest_dir(manifest)]
221-
self.run_cargo(self.install_dirs, "test", args + margs)
222-
if self.build_doc:
229+
self.run_cargo(
230+
self.install_dirs, "test", build_args + filter_args + margs
231+
)
232+
if self.build_doc and not filter_args:
223233
self.run_cargo(self.install_dirs, "doc", ["--no-deps"] + margs)
224234

225235
def _patchup_workspace(self, dep_to_git) -> None:

build/fbcode_builder/getdeps/manifest.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@
9898
"fields": {
9999
"run_tests": OPTIONAL,
100100
"required_locales": OPTIONAL,
101+
"rust_version": OPTIONAL,
102+
"build_type": OPTIONAL,
101103
},
102104
},
103105
"crate.pathmap": {"optional_section": True},

build/fbcode_builder/manifests/mononoke

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ builder = nop
1818
build_doc = true
1919
workspace_dir = eden/mononoke
2020

21+
[github.actions]
22+
rust_version = 1.91
23+
build_type = MinSizeRel
24+
2125
[shipit.pathmap]
2226
fbcode/configerator/structs/scm/hg = configerator/structs/scm/hg
2327
fbcode/configerator/structs/scm/hg/public_autocargo = configerator/structs/scm/hg

0 commit comments

Comments
 (0)