Skip to content

Commit 8d30825

Browse files
committed
cache node and pip dependencies
1 parent 59664bd commit 8d30825

File tree

1 file changed

+118
-18
lines changed

1 file changed

+118
-18
lines changed

.github/workflows/main.yml

Lines changed: 118 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ env:
99
NODE_VERSION: 14.4.0
1010

1111
jobs:
12-
build:
12+
build-dh:
1313
name: Docker Hub Cache
1414
runs-on: ubuntu-latest
1515
steps:
@@ -101,7 +101,7 @@ jobs:
101101
run: docker push $GPR_CACHE_IMAGE:stage
102102

103103
test:
104-
needs: build
104+
needs: build-dh
105105
runs-on: ubuntu-latest
106106
container: fmrcampos/docker-ci-cache:stage
107107
services:
@@ -116,6 +116,42 @@ jobs:
116116
- name: Check out repository
117117
uses: actions/checkout@v2
118118

119+
- name: Cache pip dependencies
120+
uses: actions/cache@v2
121+
env:
122+
cache-name: cache-pip-deps-tests
123+
with:
124+
path: ./.cache/pip
125+
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('requirements.txt') }}
126+
restore-keys: |
127+
${{ runner.os }}-${{ env.cache-name }}-
128+
${{ runner.os }}-
129+
130+
- name: Cache node version manager
131+
uses: actions/cache@v2
132+
id: nvm-cache
133+
env:
134+
cache-name: cache-nvm-tests
135+
with:
136+
path: ~/.nvm/versions/
137+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
138+
restore-keys: |
139+
${{ runner.os }}-build-${{ env.cache-name }}-
140+
${{ runner.os }}-build-
141+
${{ runner.os }}-
142+
143+
- name: Cache node modules
144+
uses: actions/cache@v2
145+
env:
146+
cache-name: cache-node-modules-tests
147+
with:
148+
path: ~/.npm
149+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
150+
restore-keys: |
151+
${{ runner.os }}-build-${{ env.cache-name }}-
152+
${{ runner.os }}-build-
153+
${{ runner.os }}-
154+
119155
- name: Install dependencies
120156
run: |
121157
apt-get update && apt-get -y install make locales build-essential curl libpq-dev autoconf
@@ -128,16 +164,27 @@ jobs:
128164
echo "LANG=en_US.UTF-8" > /etc/locale.conf
129165
locale-gen en_US.UTF-8
130166
131-
- name: Setup tests
167+
- name: Install nvm
168+
# if: steps.nvm-cache.outputs.cache-hit == false
169+
run: curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash
170+
171+
- name: Install node
132172
run: |
133-
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash
134173
export NVM_DIR="$HOME/.nvm"
135174
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
136175
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
137176
nvm install $NODE_VERSION
138-
pip install -U pip setuptools wheel
139-
pip install -r requirements.txt
140-
pip install -r requirements/dev.txt
177+
178+
- name: Install pip requirements
179+
run: |
180+
mkdir ./.cache && mkdir ./.cache/pip
181+
chown -R $(whoami) ./.cache/pip
182+
pip install -U pip setuptools wheel --cache-dir ./.cache/pip
183+
pip install -r requirements.txt --cache-dir ./.cache/pip
184+
pip install -r requirements/dev.txt --cache-dir ./.cache/pip
185+
186+
- name: Setup node
187+
run: |
141188
npm i -g npm
142189
npm install -g gulp-cli
143190
npm ci
@@ -154,7 +201,7 @@ jobs:
154201
POSTGRES_PORT: 5432
155202

156203
lint:
157-
needs: build
204+
needs: build-dh
158205
runs-on: ubuntu-latest
159206
container: fmrcampos/docker-ci-cache:stage
160207
steps:
@@ -171,7 +218,7 @@ jobs:
171218
make lint ACTIONS=true
172219
173220
docs:
174-
needs: build
221+
needs: build-dh
175222
runs-on: ubuntu-latest
176223
container: fmrcampos/docker-ci-cache:stage
177224
steps:
@@ -184,24 +231,37 @@ jobs:
184231
make docs
185232
186233
deps:
187-
needs: build
234+
needs: build-dh
188235
runs-on: ubuntu-latest
189236
container: fmrcampos/docker-ci-cache:stage
190237
steps:
191238
- name: Check out repository
192239
uses: actions/checkout@v2
193240

241+
- name: Cache pip dependencies
242+
uses: actions/cache@v2
243+
env:
244+
cache-name: cache-pip-deps-deps
245+
with:
246+
path: ./.cache/pip
247+
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('requirements.txt') }}
248+
restore-keys: |
249+
${{ runner.os }}-${{ env.cache-name }}-
250+
${{ runner.os }}-
251+
194252
- name: Dependencies
195253
run: |
196254
apt-get update && apt-get -y install build-essential make libpq-dev
197255
apt -y install libcurl4-openssl-dev libssl-dev pkg-config
198-
pip install -U pip setuptools wheel
199-
pip install -r requirements.txt
200-
pip install -r requirements/dev.txt # this is probably happening twice
256+
mkdir ./.cache && mkdir ./.cache/pip
257+
chown -R $(whoami) ./.cache/pip
258+
pip install -U pip setuptools wheel --cache-dir ./.cache/pip
259+
pip install -r requirements.txt --cache-dir ./.cache/pip
260+
pip install -r requirements/dev.txt --cache-dir ./.cache/pip
201261
make deps
202262
203263
licenses:
204-
needs: build
264+
needs: build-dh
205265
runs-on: ubuntu-latest
206266
container: fmrcampos/docker-ci-cache:stage
207267
steps:
@@ -212,7 +272,7 @@ jobs:
212272
run: bin/licenses
213273

214274
translations:
215-
needs: build
275+
needs: build-dh
216276
runs-on: ubuntu-latest
217277
container: fmrcampos/docker-ci-cache:stage
218278
steps:
@@ -225,7 +285,7 @@ jobs:
225285
make translations
226286
227287
static-lint:
228-
needs: build
288+
needs: build-dh
229289
runs-on: ubuntu-latest
230290
container: fmrcampos/docker-ci-cache:static
231291
steps:
@@ -239,13 +299,27 @@ jobs:
239299
./node_modules/.bin/sass-lint --verbose
240300
241301
static-tests:
242-
needs: build
302+
needs: build-dh
243303
runs-on: ubuntu-latest
244304
container: fmrcampos/docker-ci-cache:static
245305
steps:
246306
- name: Check out repository
247307
uses: actions/checkout@v2
248308

309+
- name: Cache node modules
310+
uses: actions/cache@v2
311+
env:
312+
cache-name: cache-node-modules-static
313+
with:
314+
path: |
315+
~/.npm
316+
**/node_modules
317+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
318+
restore-keys: |
319+
${{ runner.os }}-build-${{ env.cache-name }}-
320+
${{ runner.os }}-build-
321+
${{ runner.os }}-
322+
249323
- name: Static Tests
250324
run: |
251325
apt-get update && apt-get -y install locales
@@ -257,13 +331,39 @@ jobs:
257331
bin/static_tests
258332
259333
static-pipeline:
260-
needs: build
334+
needs: build-dh
261335
runs-on: ubuntu-latest
262336
container: fmrcampos/docker-ci-cache:static
263337
steps:
264338
- name: Check out repository
265339
uses: actions/checkout@v2
266340

341+
- name: Cache node version manager
342+
uses: actions/cache@v2
343+
env:
344+
cache-name: cache-nvm-pipeline
345+
with:
346+
path: ~/.nvm/versions/
347+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
348+
restore-keys: |
349+
${{ runner.os }}-build-${{ env.cache-name }}-
350+
${{ runner.os }}-build-
351+
${{ runner.os }}-
352+
353+
- name: Cache node modules
354+
uses: actions/cache@v2
355+
env:
356+
cache-name: cache-node-modules-static
357+
with:
358+
path: |
359+
~/.npm
360+
**/node_modules
361+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
362+
restore-keys: |
363+
${{ runner.os }}-build-${{ env.cache-name }}-
364+
${{ runner.os }}-build-
365+
${{ runner.os }}-
366+
267367
- name: Locale & Dependency Setup
268368
run: |
269369
apt-get update && apt-get -y install locales

0 commit comments

Comments
 (0)