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 <sattard@salesforce.com>
This commit is contained in:
John Kleinschmidt 2022-06-01 12:59:26 -04:00 committed by GitHub
parent cda8f3c15c
commit a38e5d20ff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 >>