Skip to content

Commit

Permalink
fix getdeps actions generation for rust toolchain (#6924)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #6924

fix getdeps actions generation for rust toolchain

Generated actions files created from getdeps.py were missing rust toolchain which meant annoying manual edits

This change also makes the github actions generation honor the --no-tests argument, which is useful  when regenerating the edenfs actions

X-link: facebook/sapling#682

Test Plan:
To test we add the missing undeclared rust-shed dependency to the eden manifest and regenerate.

Generate updated actions yaml with:
```
./build/fbcode_builder/getdeps.py --allow-system-packages generate-github-actions --no-tests --free-up-disk --os-type=linux --src-dir=. --output-dir=.github/workflows --job-name "EdenFS " --job-file-prefix=edenfs_ eden
```

Before, was missing the rust toolchain in the auto regenerated eden actions file.  After, toolchain is present

Before, was missing the --no-tests in the "Build eden" step of the  auto-regenerated eden actions file.  After, has it

Eden stil needs some other fixes to build, which follow in this stqck

 ---
Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/sapling/pull/682).
* facebook/sapling#693
* facebook/sapling#696
* facebook/sapling#692
* facebook/sapling#691
* __->__ facebook/sapling#682
* facebook/sapling#689
* facebook/sapling#697
* facebook/sapling#706
* facebook/sapling#730

Reviewed By: sggutier

Differential Revision: D49875258

Pulled By: genevievehelsel

fbshipit-source-id: 173f86083ba92bab4063813d3e392df428b9ffe4
  • Loading branch information
ahornby authored and facebook-github-bot committed Oct 7, 2023
1 parent 6eafe44 commit 2a03f5f
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 15 deletions.
49 changes: 35 additions & 14 deletions build/fbcode_builder/getdeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,8 @@ def write_job_for_platform(self, platform, args): # noqa: C901
# We do this by looking at the builder type in the manifest file
# rather than creating a builder and checking its type because we
# don't know enough to create the full builder instance here.
if manifest.get("build", "builder", ctx=manifest_ctx) == "nop":
builder_name = manifest.get("build", "builder", ctx=manifest_ctx)
if builder_name == "nop":
return None

# We want to be sure that we're running things with python 3
Expand Down Expand Up @@ -1058,18 +1059,30 @@ def write_job_for_platform(self, platform, args): # noqa: C901
main_repo_url = manifest.get_repo_url(manifest_ctx)
has_same_repo_dep = False

# Add the rust dep which doesn't have a manifest
for m in projects:
if m != manifest:
if m.name == "rust":
out.write(" - name: Install Rust Stable\n")
out.write(" uses: dtolnay/rust-toolchain@stable\n")
else:
ctx = loader.ctx_gen.get_context(m.name)
if m.get_repo_url(ctx) != main_repo_url:
out.write(" - name: Fetch %s\n" % m.name)
out.write(
f" run: {getdepscmd}{allow_sys_arg} fetch --no-tests {m.name}\n"
)
if m == manifest:
continue
mbuilder_name = m.get("build", "builder", ctx=manifest_ctx)
if (
m.name == "rust"
or builder_name == "cargo"
or mbuilder_name == "cargo"
):
out.write(" - name: Install Rust Stable\n")
out.write(" uses: dtolnay/rust-toolchain@stable\n")
break

# Normal deps that have manifests
for m in projects:
if m == manifest or m.name == "rust":
continue
ctx = loader.ctx_gen.get_context(m.name)
if m.get_repo_url(ctx) != main_repo_url:
out.write(" - name: Fetch %s\n" % m.name)
out.write(
f" run: {getdepscmd}{allow_sys_arg} fetch --no-tests {m.name}\n"
)

for m in projects:
if m != manifest:
Expand Down Expand Up @@ -1100,8 +1113,12 @@ def write_job_for_platform(self, platform, args): # noqa: C901
if has_same_repo_dep:
no_deps_arg = "--no-deps "

no_tests_arg = ""
if not args.enable_tests:
no_tests_arg = "--no-tests "

out.write(
f" run: {getdepscmd}{allow_sys_arg} build {no_deps_arg}--src-dir=. {manifest.name} {project_prefix}\n"
f" run: {getdepscmd}{allow_sys_arg} build {no_tests_arg}{no_deps_arg}--src-dir=. {manifest.name} {project_prefix}\n"
)

out.write(" - name: Copy artifacts\n")
Expand All @@ -1125,7 +1142,11 @@ def write_job_for_platform(self, platform, args): # noqa: C901
out.write(" name: %s\n" % manifest.name)
out.write(" path: _artifacts\n")

if manifest.get("github.actions", "run_tests", ctx=manifest_ctx) != "off":
if (
args.enable_tests
and manifest.get("github.actions", "run_tests", ctx=manifest_ctx)
!= "off"
):
out.write(" - name: Test %s\n" % manifest.name)
out.write(
f" run: {getdepscmd}{allow_sys_arg} test --src-dir=. {manifest.name} {project_prefix}\n"
Expand Down
3 changes: 2 additions & 1 deletion build/fbcode_builder/manifests/eden
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ shipit_project = eden
shipit_fbcode_builder = true

[git]
repo_url = https://github.com/facebookexperimental/eden.git
repo_url = https://github.com/facebook/sapling.git

[github.actions]
run_tests = off
Expand All @@ -30,6 +30,7 @@ pexpect
python-toml
python-filelock
edencommon
rust-shed

[dependencies.fbsource=on]
rust
Expand Down

0 comments on commit 2a03f5f

Please sign in to comment.