Skip to content

Commit 5356c87

Browse files
Use smarter cache key, cache Arduino IDE (#7791)
Thanks to @mcspr. Make sure the cached toolchain is only valid when the package.json file is identical. Also, add the Arduino IDE to the cache to avoid re-downloads.
1 parent c487ca5 commit 5356c87

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

.github/workflows/pull-request.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
uses: actions/cache@v2
3131
with:
3232
path: ./tools/dist
33-
key: key-linux-toolchain
33+
key: ${{ runner.os }}-${{ hashFiles('package/package_esp8266com_index.template.json', 'tests/common.sh') }}
3434
- name: Build Sketches
3535
env:
3636
TRAVIS_BUILD_DIR: ${{ github.workspace }}
@@ -62,7 +62,7 @@ jobs:
6262
uses: actions/cache@v2
6363
with:
6464
path: ./tools/dist
65-
key: key-linux-toolchain
65+
key: ${{ runner.os }}-${{ hashFiles('package/package_esp8266com_index.template.json', 'tests/common.sh') }}
6666
- name: Build Sketches
6767
env:
6868
TRAVIS_BUILD_DIR: ${{ github.workspace }}
@@ -90,7 +90,7 @@ jobs:
9090
uses: actions/cache@v2
9191
with:
9292
path: ./tools/dist
93-
key: key-windows-toolchain
93+
key: ${{ runner.os }}-${{ hashFiles('package/package_esp8266com_index.template.json', 'tests/common.sh') }}
9494
- name: Build Sketch
9595
env:
9696
TRAVIS_BUILD_DIR: ${{ github.workspace }}
@@ -122,7 +122,7 @@ jobs:
122122
uses: actions/cache@v2
123123
with:
124124
path: ./tools/dist
125-
key: key-mac-toolchain
125+
key: ${{ runner.os }}-${{ hashFiles('package/package_esp8266com_index.template.json', 'tests/common.sh') }}
126126
- name: Build Sketch
127127
env:
128128
TRAVIS_BUILD_DIR: ${{ github.workspace }}
@@ -260,7 +260,7 @@ jobs:
260260
uses: actions/cache@v2
261261
with:
262262
path: ./tools/dist
263-
key: key-linux-toolchain
263+
key: ${{ runner.os }}-${{ hashFiles('package/package_esp8266com_index.template.json', 'tests/common.sh') }}
264264
- name: Boards.txt diff
265265
env:
266266
TRAVIS_BUILD_DIR: ${{ github.workspace }}

tests/common.sh

+7-6
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,10 @@ function install_ide()
164164
local ide_path=$1
165165
local core_path=$2
166166
local debug=$3
167+
mkdir -p ${core_path}/tools/dist
167168
if [ "$WINDOWS" = "1" ]; then
168-
test -r arduino-windows.zip || curl --output arduino-windows.zip -L "${ideurl}-windows.zip"
169-
unzip -q arduino-windows.zip
169+
test -r ${core_path}/tools/dist/arduino-windows.zip || curl --output ${core_path}/tools/dist/arduino-windows.zip -L "${ideurl}-windows.zip"
170+
unzip -q ${core_path}/tools/dist/arduino-windows.zip
170171
mv arduino-${idever} arduino-distrib
171172
elif [ "$MACOSX" = "1" ]; then
172173
# MACOS only has next-to-obsolete Python2 installed. Install Python 3 from python.org
@@ -175,13 +176,13 @@ function install_ide()
175176
# Install the Python3 certificates, because SSL connections fail w/o them and of course they aren't installed by default.
176177
( cd "/Applications/Python 3.7/" && sudo "./Install Certificates.command" )
177178
# Hack to place arduino-builder in the same spot as sane OSes
178-
test -r arduino-macos.zip || wget -q -O arduino-macos.zip "${ideurl}-macosx.zip"
179-
unzip -q arduino-macos.zip
179+
test -r ${core_path}/tools/dist/arduino-macos.zip || wget -q -O ${core_path}/tools/dist/arduino-macos.zip "${ideurl}-macosx.zip"
180+
unzip -q ${core_path}/tools/dist/arduino-macos.zip
180181
mv Arduino.app arduino-distrib
181182
mv arduino-distrib/Contents/Java/* arduino-distrib/.
182183
else
183-
test -r arduino-linux.tar.xz || wget -q -O arduino-linux.tar.xz "${ideurl}-linux64.tar.xz"
184-
tar xf arduino-linux.tar.xz
184+
test -r ${core_path}/tools/dist/arduino-linux.tar.xz || wget -q -O ${core_path}/tools/dist/arduino-linux.tar.xz "${ideurl}-linux64.tar.xz"
185+
tar xf ${core_path}/tools/dist/arduino-linux.tar.xz
185186
mv arduino-${idever} arduino-distrib
186187
fi
187188
mv arduino-distrib $ide_path

0 commit comments

Comments
 (0)