Skip to content

Commit

Permalink
CI: Reusable command for cloning and installing dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
cameel committed Feb 7, 2022
1 parent 08ae214 commit 00c2750
Showing 1 changed file with 30 additions and 6 deletions.
36 changes: 30 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,34 @@ workflows:
- node-v17

version: 2.1

commands:
install-dependencies:
parameters:
cache-id:
type: string
path:
type: string
default: .
package-manager:
type: string
default: npm
dependency-file:
type: string
default: package.json
steps:
- restore_cache:
key: <<parameters.cache-id>>-dependency-cache-v2-{{ .Environment.CIRCLE_JOB }}-{{ checksum "<<parameters.path>>/<<parameters.dependency-file>>" }}
- run:
name: "<<parameters.package-manager>> install in <<parameters.path>>"
command: |
cd "<<parameters.path>>"
[[ -e node_modules/ ]] || <<parameters.package-manager>> install
- save_cache:
key: <<parameters.cache-id>>-dependency-cache-v2-{{ .Environment.CIRCLE_JOB }}-{{ checksum "<<parameters.path>>/<<parameters.dependency-file>>" }}
paths:
- "<<parameters.path>>/node_modules/"

jobs:
node-base: &node-base
working_directory: ~/solc-js
Expand All @@ -24,8 +52,8 @@ jobs:
name: Versions
command: npm version
- checkout
- restore_cache:
key: dependency-cache-{{ .Environment.CIRCLE_JOB }}-{{ checksum "package.json" }}
- install-dependencies:
cache-id: solc-js
- run:
name: install-npm
command: npm install
Expand All @@ -41,10 +69,6 @@ jobs:
- run:
name: coveralls
command: npm run coveralls
- save_cache:
key: dependency-cache-{{ .Environment.CIRCLE_JOB }}-{{ checksum "package.json" }}
paths:
- ./node_modules

node-v10:
<<: *node-base
Expand Down

0 comments on commit 00c2750

Please sign in to comment.