Skip to content

Commit

Permalink
preserve http_proxy in generated github actions sudo invocatons
Browse files Browse the repository at this point in the history
Summary:
X-link: facebookincubator/zstrong#1102

make it possible to run the generated github actions locally with [act](https://github.com/nektos/act) when behind a proxy by preserving http_proxy in generated github actions sudo invocatons

also updated to consistently write `apt-get` instead of the interactive `apt` (we had a mix)

example usage (substitute myproxy for your actual proxy):
```
mkdir $HOME/act-artifacts
cd ~/fizz
time act -r -j build -W .github/workflows/getdeps_linux.yml --artifact-server-path=$HOME/act-artifacts --artifact-server-addr=127.0.0.1 --cache-server-addr=127.0.0.1 --env http_proxy=http://myproxy:8080 --env https_proxy=myproxy:8080 --action-offline-mode
```

Reviewed By: bigfootjon

Differential Revision: D67864689

fbshipit-source-id: 45695675ca5672e56104c8c33803afe004ff98da
  • Loading branch information
ahornby authored and facebook-github-bot committed Jan 7, 2025
1 parent 3afb87c commit d0e920b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/getdeps_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Update system package info
run: sudo apt-get update
run: sudo --preserve-env=http_proxy apt-get update
- name: Install system deps
run: sudo python3 build/fbcode_builder/getdeps.py --allow-system-packages install-system-deps --recursive watchman && sudo python3 build/fbcode_builder/getdeps.py --allow-system-packages install-system-deps --recursive patchelf
run: sudo --preserve-env=http_proxy python3 build/fbcode_builder/getdeps.py --allow-system-packages install-system-deps --recursive watchman && sudo --preserve-env=http_proxy python3 build/fbcode_builder/getdeps.py --allow-system-packages install-system-deps --recursive patchelf
- id: paths
name: Query paths
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages query-paths --recursive --src-dir=. watchman >> "$GITHUB_OUTPUT"
Expand Down
10 changes: 8 additions & 2 deletions build/fbcode_builder/getdeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,13 @@ def run_project_cmd(self, args, loader, manifest):
elif manager == "deb":
packages = sorted(set(all_packages["deb"]))
if packages:
cmd_args = ["sudo", "apt", "install", "-y"] + packages
cmd_args = [
"sudo",
"--preserve-env=http_proxy",
"apt-get",
"install",
"-y",
] + packages
elif manager == "homebrew":
packages = sorted(set(all_packages["homebrew"]))
if packages:
Expand Down Expand Up @@ -1155,7 +1161,7 @@ def write_job_for_platform(self, platform, args): # noqa: C901
build_opts.allow_system_packages
and build_opts.host_type.get_package_manager()
):
sudo_arg = "sudo "
sudo_arg = "sudo --preserve-env=http_proxy "
allow_sys_arg = " --allow-system-packages"
if build_opts.host_type.get_package_manager() == "deb":
out.write(" - name: Update system package info\n")
Expand Down

0 comments on commit d0e920b

Please sign in to comment.