Skip to content

Commit 83e6ada

Browse files
authored
Use cache for firefox only when version is not latest (#129)
* Don't use firefox cache when version is latest * Update syntax for conditions * Fix linter
1 parent 73fde88 commit 83e6ada

File tree

4 files changed

+26
-13
lines changed

4 files changed

+26
-13
lines changed

.circleci/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
version: 2.1
22
setup: true
33
orbs:
4-
orb-tools: circleci/orb-tools@12.0.3
5-
shellcheck: circleci/shellcheck@3.1
4+
orb-tools: circleci/orb-tools@12.3.1
5+
shellcheck: circleci/shellcheck@3.3
66

77
filters: &filters
88
tags:

.circleci/test-deploy.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
version: 2.1
22
orbs:
33
browser-tools: circleci/browser-tools@dev:<<pipeline.git.revision>>
4-
orb-tools: circleci/[email protected]
5-
jq: circleci/jq@2.2
4+
orb-tools: circleci/orb-tools@11.6.1
5+
jq: circleci/jq@3.0.2
66
filters: &filters
77
tags:
88
only: /.*/
@@ -105,12 +105,15 @@ jobs:
105105
parameters:
106106
executor:
107107
type: executor
108+
version:
109+
type: string
108110
executor: <<parameters.executor>>
109111
steps:
110112
- jq/install
111113
- browser-tools/install-firefox:
112114
use_cache: true
113-
cache_key: v2
115+
cache_key: v3-<<parameters.version>>
116+
version: <<parameters.version>>
114117
- checkout
115118
workflows:
116119
test-deploy:
@@ -122,10 +125,11 @@ workflows:
122125
executor: [cimg-node, macos]
123126
filters: *filters
124127
- int-test-firefox-cache:
125-
name: test-firefox-cache-<<matrix.executor>>
128+
name: test-firefox-cache-<<matrix.executor>>-<<matrix.version>>
126129
matrix:
127130
parameters:
128131
executor: [cimg-node, macos]
132+
version: ["latest", "90.0.1", "135.0"]
129133
filters: *filters
130134
- int-test-all:
131135
name: test-cimg-base-all
@@ -183,21 +187,21 @@ workflows:
183187
alias: test-specific-version-firefox-matrix
184188
parameters:
185189
firefox-version: ["90.0.1", "135.0"]
186-
name: test-specific-version-firefox
190+
name: test-specific-version-firefox-<<matrix.firefox-version>>
187191
executor: cimg-base
188192
chrome-version: "131.0.6778.85"
189193
firefox-version: "90.0.1"
190194
filters: *filters
191195
- int-test-firefox:
192-
name: test-macos-firefox
196+
name: test-macos-firefox-<<matrix.firefox-version>>
193197
executor: macos
194198
matrix:
195199
alias: test-macos-firefox-matrix
196200
parameters:
197201
firefox-version: ["90.0.1", "135.0"]
198202
filters: *filters
199203
- int-test-firefox:
200-
name: test-linux-firefox
204+
name: test-linux-firefox-<<matrix.firefox-version>>
201205
executor: linux
202206
matrix:
203207
alias: test-linux-firefox-matrix

src/commands/install-firefox.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ parameters:
2121
description: |
2222
Install firefox using a cached version of the installer.
2323
Using this option will increase costs and does not improve times considerable, use only if having problems with download.
24+
Cache won't be used when version is set to latest.
2425
Defaults to false.
2526
default: false
2627
type: boolean
@@ -32,7 +33,11 @@ parameters:
3233
type: string
3334
steps:
3435
- when:
35-
condition: <<parameters.use_cache>>
36+
condition:
37+
and:
38+
- equal: [ true, <<parameters.use_cache>> ]
39+
- not:
40+
equal: [ latest, <<parameters.version>> ]
3641
steps:
3742
- restore_cache:
3843
keys:
@@ -45,7 +50,11 @@ steps:
4550
ORB_PARAM_SAVE_CACHE: <<parameters.use_cache>>
4651
command: <<include(scripts/install-firefox.sh)>>
4752
- when:
48-
condition: <<parameters.use_cache>>
53+
condition:
54+
and:
55+
- equal: [ true, <<parameters.use_cache>> ]
56+
- not:
57+
equal: [ latest, <<parameters.version>> ]
4958
steps:
5059
- save_cache:
5160
key: firefox-<<parameters.cache_key>>-<<parameters.version>>-{{ arch }}

src/scripts/install-firefox.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ FIREFOX_FILE_LOCATION="$PLATFORM/en-US/$FIREFOX_FILE"
9898

9999
FIREFOX_FILE_NAME="$PLATFORM-en-US-$FIREFOX_FILE"
100100

101-
if [ "$ORB_PARAM_SAVE_CACHE" = 1 ] && [ -f "/tmp/firefox" ]; then
101+
if [ "$ORB_PARAM_SAVE_CACHE" = 1 ] && [ -f "/tmp/firefox" ] && [ "$ORB_PARAM_FIREFOX_VERSION" != "latest" ]; then
102102
echo "Cache found."
103103
mv /tmp/firefox "$FIREFOX_FILE_NAME.$FILE_EXT"
104104
else
@@ -109,7 +109,7 @@ else
109109
"$FIREFOX_URL_BASE/$FIREFOX_FILE_LOCATION.$FILE_EXT"
110110
fi
111111

112-
if [ "$ORB_PARAM_SAVE_CACHE" = 1 ]; then
112+
if [ "$ORB_PARAM_SAVE_CACHE" = 1 ] && [ "$ORB_PARAM_FIREFOX_VERSION" != "latest" ]; then
113113
cp "$FIREFOX_FILE_NAME.$FILE_EXT" /tmp/firefox
114114
fi
115115

0 commit comments

Comments
 (0)