From a38e5d20ff0ffa9cd2875e95755b1ce4be0ebb83 Mon Sep 17 00:00:00 2001 From: John Kleinschmidt Date: Wed, 1 Jun 2022 12:59:26 -0400 Subject: [PATCH] ci: cache python install to better deal with download errors. (#34360) * ci: cache python install to better deal with download errors. * chore: use our CDN to download python2 * build: DRY up the python install steps Co-authored-by: Samuel Attard --- .circleci/config/base.yml | 40 +++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/.circleci/config/base.yml b/.circleci/config/base.yml index a579069c96e..c37b1ecd67a 100644 --- a/.circleci/config/base.yml +++ b/.circleci/config/base.yml @@ -527,15 +527,6 @@ step-install-gnutar-on-mac: &step-install-gnutar-on-mac ln -fs /usr/local/bin/gtar /usr/local/bin/tar fi -step-install-python2-on-mac: &step-install-python2-on-mac - run: - name: Install python2 on macos - command: | - if [ "`uname`" == "Darwin" ]; then - curl -O https://www.python.org/ftp/python/2.7.18/python-2.7.18-macosx10.9.pkg - sudo installer -pkg python-2.7.18-macosx10.9.pkg -target / - fi - step-gn-gen-default: &step-gn-gen-default run: name: Default GN gen @@ -1011,7 +1002,7 @@ steps-electron-gn-check: &steps-electron-gn-check - *step-checkout-electron - *step-depot-tools-get - *step-depot-tools-add-to-path - - *step-install-python2-on-mac + - install-python2-mac - *step-setup-env-for-build - *step-setup-goma-for-build - *step-generate-deps-hash @@ -1130,6 +1121,31 @@ steps-test-node: &steps-test-node # Command Aliases commands: + install-python2-mac: + steps: + - restore_cache: + keys: + - v2.7.18-python-cache-{{ arch }} + name: Restore python cache + - run: + name: Install python2 on macos + command: | + if [ "`uname`" == "Darwin" ]; then + if [ ! -f "python-downloads/python-2.7.18-macosx10.9.pkg" ]; then + mkdir python-downloads + echo 'Downloading Python 2.7.18' + curl -O https://dev-cdn.electronjs.org/python/python-2.7.18-macosx10.9.pkg + mv python-2.7.18-macosx10.9.pkg python-downloads + else + echo 'Using Python install from cache' + fi + sudo installer -pkg python-downloads/python-2.7.18-macosx10.9.pkg -target / + fi + - save_cache: + paths: + - python-downloads + key: v2.7.18-python-cache-{{ arch }} + name: Persisting python cache maybe-restore-portaled-src-cache: parameters: halt-if-successful: @@ -1296,7 +1312,7 @@ commands: - run: rm -rf src/electron - *step-restore-brew-cache - *step-install-gnutar-on-mac - - *step-install-python2-on-mac + - install-python2-mac - *step-save-brew-cache - when: condition: << parameters.build >> @@ -1488,7 +1504,7 @@ commands: - *step-depot-tools-get - *step-depot-tools-add-to-path - *step-restore-brew-cache - - *step-install-python2-on-mac + - install-python2-mac - *step-get-more-space-on-mac - when: condition: << parameters.checkout >>