From a1074d6820c13d1d735f5b056dc2411859562878 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Mon, 30 Mar 2020 12:50:00 -0700 Subject: [PATCH] getdeps: fixup python3 usage on GitHub Actions CI Summary: My recent change to ensure that we were using python3 to launch everything failed on windows: the GH actions environment has `python.exe` in the path and it is python version 3. There is no such thing as `python3` in that environment, although there is a `python2`. Refs: https://github.com/facebook/watchman/pull/797 Reviewed By: chadaustin Differential Revision: D20740411 fbshipit-source-id: 0e40590ccedc18e327ebb84901e2509588fdd0ff --- build/fbcode_builder/getdeps.py | 36 ++++++++++++++++----------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/build/fbcode_builder/getdeps.py b/build/fbcode_builder/getdeps.py index d9e3c3f64..8a74647bc 100755 --- a/build/fbcode_builder/getdeps.py +++ b/build/fbcode_builder/getdeps.py @@ -610,6 +610,13 @@ jobs: if manifest.get("build", "builder", ctx=manifest_ctx) == "nop": return None + # We want to be sure that we're running things with python 3 + # but python versioning is honestly a bit of a frustrating mess. + # `python` may be version 2 or version 3 depending on the system. + # python3 may not be a thing at all! + # Assume an optimistic default + py3 = "python3" + if build_opts.is_linux(): job_name = "linux" runs_on = "ubuntu-18.04" @@ -620,10 +627,15 @@ jobs: # buildable with Visual Studio 2019 job_name = "windows" runs_on = "windows-2016" + # The windows runners are python 3 by default; python2.exe + # is available if needed. + py3 = "python" else: job_name = "mac" runs_on = "macOS-latest" + getdeps = f"{py3} build/fbcode_builder/getdeps.py" + out.write(" %s:\n" % job_name) out.write(" runs-on: %s\n" % runs_on) out.write(" steps:\n") @@ -640,29 +652,20 @@ jobs: for m in projects: if m != manifest: out.write(" - name: Fetch %s\n" % m.name) - out.write( - " run: python3 build/fbcode_builder/getdeps.py fetch " - "--no-tests %s\n" % m.name - ) + out.write(f" run: {getdeps} fetch --no-tests {m.name}\n") for m in projects: if m != manifest: out.write(" - name: Build %s\n" % m.name) - out.write( - " run: python3 build/fbcode_builder/getdeps.py build " - "--no-tests %s\n" % m.name - ) + out.write(f" run: {getdeps} build --no-tests {m.name}\n") out.write(" - name: Build %s\n" % manifest.name) - out.write( - " run: python3 build/fbcode_builder/getdeps.py build --src-dir=. %s\n" - % manifest.name - ) + out.write(f" run: {getdeps} build --src-dir=. {manifest.name}\n") out.write(" - name: Copy artifacts\n") out.write( - " run: python3 build/fbcode_builder/getdeps.py fixup-dyn-deps " - "--src-dir=. %s _artifacts/%s\n" % (manifest.name, job_name) + f" run: {getdeps} fixup-dyn-deps " + f"--src-dir=. {manifest.name} _artifacts/{job_name}\n" ) out.write(" - uses: actions/upload-artifact@master\n") out.write(" with:\n") @@ -670,10 +673,7 @@ jobs: out.write(" path: _artifacts\n") out.write(" - name: Test %s\n" % manifest.name) - out.write( - " run: python3 build/fbcode_builder/getdeps.py test --src-dir=. %s\n" - % manifest.name - ) + out.write(f" run: {getdeps} test --src-dir=. {manifest.name}\n") def setup_project_cmd_parser(self, parser): parser.add_argument("--output-file", help="The name of the yaml file")