diff --git a/.circleci/config.yml b/.circleci/config.yml index 1467e6c691..5463aa7816 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,22 +1,50 @@ version: 2 +job_common: &job_common + docker: + - image: circleci/node:9.11.2 + working_directory: ~/colonyNetwork +step_save_cache: &step_save_cache + save_cache: + paths: + - ~/.cache/yarn + key: node-modules-{{ checksum "yarn.lock" }} +step_restore_cache: &step_restore_cache + restore_cache: + keys: + - node-modules-{{ checksum "yarn.lock" }} + - node-modules- +step_setup_global_packages: &step_setup_global_packages + run: + name: "Set up global packages" + command: | + yarn --pure-lockfile + git submodule update --init +step_setup_greenkeeper: &step_setup_greenkeeper + run: + name: "Add greenkeeper-lockfile-update" + command: yarn global add greenkeeper-lockfile@1 jobs: - lint-and-unit-test: - docker: - - image: circleci/node:9.11.2 - working_directory: ~/colonyNetwork + greenkeeper-updates: + <<: *job_common steps: - checkout - - restore_cache: - keys: - - node-modules-{{ checksum "yarn.lock" }} - - node-modules- + - <<: *step_restore_cache + - <<: *step_setup_global_packages + - <<: *step_setup_greenkeeper - run: - name: "Set up global packages" - command: | - yarn global add greenkeeper-lockfile@1 - yarn --pure-lockfile - git submodule update --init + name: "Run Greenkeeper lockfile update" + command: $(yarn global bin)/greenkeeper-lockfile-update + environment: + GK_LOCK_YARN_OPTS: "--ignore-workspace-root-check" + - <<: *step_save_cache + lint-and-unit-test: + <<: *job_common + steps: + - checkout + - <<: *step_restore_cache + - <<: *step_setup_global_packages + - <<: *step_setup_greenkeeper - run: name: "Setup parity" command: | @@ -28,20 +56,11 @@ jobs: sed -i "s/xxxxx/$(parity --keys-path ./keys --password ./parityPassword account new)/g" ./parity-genesis.json sed -i "s/yyyyy/$(parity --keys-path ./keys --password ./parityPassword account new)/g" ./parity-genesis.json sed -i "s/zzzzz/$(parity --keys-path ./keys --password ./parityPassword account new)/g" ./parity-genesis.json - - save_cache: - paths: - - node_modules - key: node-modules-{{ checksum "yarn.lock" }} - run: name: "Install lsof" command: | sudo apt-get update sudo apt-get install lsof - - run: - name: "Greenkeeper lockfile update" - command: $(yarn global bin)/greenkeeper-lockfile-update - environment: - GK_LOCK_YARN_OPTS: "--ignore-workspace-root-check" - run: name: "Linting JavaScript" command: yarn run eslint @@ -66,6 +85,7 @@ jobs: - run: name: "Running colony-contract-loader-network tests" command: cd packages/colony-js-contract-loader-network && yarn run test + - <<: *step_save_cache - run: name: "Greenkeeper uploading lockfile" command: $(yarn global bin)/greenkeeper-lockfile-upload @@ -74,27 +94,15 @@ jobs: path: test-results.xml - store_artifacts: path: test-results.xml - test-coverage: - docker: - - image: circleci/node:9.11.2 - working_directory: ~/colonyNetwork + <<: *job_common steps: - checkout - - restore_cache: - keys: - - node-modules-{{ checksum "yarn.lock" }} - - node-modules- - - run: - name: "Set up global packages" - command: | - yarn global add greenkeeper-lockfile@1 - yarn --pure-lockfile - git submodule update --init + - <<: *step_restore_cache + - <<: *step_setup_global_packages - run: name: "Running unit tests with coverage" command: yarn run test:contracts:coverage - # Save coverage artifacts - store_artifacts: path: coverage @@ -103,5 +111,10 @@ workflows: version: 2 commit: jobs: - - lint-and-unit-test - - test-coverage + - greenkeeper-updates + - lint-and-unit-test: + requires: + - greenkeeper-updates + - test-coverage: + requires: + - greenkeeper-updates