Skip to content

Commit

Permalink
fix(ci): cache ipfs-webui (#1913)
Browse files Browse the repository at this point in the history
This stabilizes CI by reducing the umber of times we fetch
the same version of ipfs-webui.
  • Loading branch information
lidel authored Oct 1, 2021
1 parent 35b312a commit 18c34e3
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 4 deletions.
62 changes: 60 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,52 @@ env:

jobs:

webui:
runs-on: ubuntu-latest
steps:
- name: Check out Git repository
uses: actions/checkout@v2

- name: Install Node.js
uses: actions/setup-node@v2
with:
node-version: 'lts/*'

- name: Cache webui
uses: actions/cache@v2
id: webui-cache
with:
path: assets/webui
key: ${{ hashFiles('package.json') }} # webui CID is defined in this file

- name: Cache bigger downloads
uses: actions/cache@v2
id: cache
if: steps.webui-cache.outputs.cache-hit != 'true'
with:
path: ${{ github.workspace }}/.cache
key: ${{ runner.os }}-${{ hashFiles('package.json', 'package-lock.json', 'electron-builder.yml') }}
restore-keys: |
${{ runner.os }}-${{ hashFiles('package.json', 'package-lock.json', 'electron-builder.yml') }}
${{ runner.os }}-
- name: Install dependencies and fetch ipfs-webui
if: steps.webui-cache.outputs.cache-hit != 'true'
run: |
npm ci --prefer-offline --no-audit --progress=false --cache ${{ github.workspace }}/.cache/npm
npm run clean
npm run force-webui-download
- name: Attach cached ipfs-webui to Github Action
uses: actions/upload-artifact@v2
with:
name: ipfs-webui
path: assets/webui
if-no-files-found: error

test:
runs-on: ${{ matrix.os }}
needs: webui
strategy:
fail-fast: false
matrix:
Expand All @@ -22,7 +66,14 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@v2
with:
node-version: '14'
node-version: 'lts/*'

- name: Cache webui
uses: actions/cache@v2
id: webui-cache
with:
path: assets/webui
key: ${{ hashFiles('package.json') }}

- name: Cache bigger downloads
uses: actions/cache@v2
Expand Down Expand Up @@ -67,7 +118,14 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@v2
with:
node-version: '14'
node-version: 'lts/*'

- name: Cache webui
uses: actions/cache@v2
id: webui-cache
with:
path: assets/webui
key: ${{ hashFiles('package.json') }}

- name: Cache bigger downloads
uses: actions/cache@v2
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
"test:e2e": "xvfb-maybe cross-env NODE_ENV=test LIBP2P_ALLOW_WEAK_RSA_KEYS=1 mocha test/e2e/**/*.e2e.js --exit",
"postinstall": "run-s install-app-deps",
"install-app-deps": "electron-builder install-app-deps",
"clean": "shx rm -rf assets/webui/ node_modules/go-ipfs/bin",
"clean": "shx rm -rf node_modules/go-ipfs/bin",
"force-webui-download": "shx rm -rf assets/webui && run-s build:webui",
"build": "run-s clean build:webui",
"build:webui": "run-s build:webui:*",
"build:webui:download": "npx ipfs-or-gateway -c bafybeihcyruaeza7uyjd6ugicbcrqumejf6uf353e5etdkhotqffwtguva -p assets/webui/ -t 360000 --verbose --clean",
"build:webui:download": "npx ipfs-or-gateway -c bafybeihcyruaeza7uyjd6ugicbcrqumejf6uf353e5etdkhotqffwtguva -p assets/webui/ -t 360000 --verbose",
"build:webui:minimize": "shx rm -rf assets/webui/static/js/*.map && shx rm -rf assets/webui/static/css/*.map",
"package": "shx rm -rf dist/ && run-s build && electron-builder --publish onTag"
},
Expand Down

0 comments on commit 18c34e3

Please sign in to comment.