From 0fd6884e6868041971a5bcc5c9a354718b931b2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Se=CC=81rgio=20Ramos?= Date: Thu, 1 Jun 2017 13:03:11 +0100 Subject: [PATCH] ci: run test and lint in parallel --- circle.yml | 27 +++++++++++++-------------- package.json | 6 ++---- scripts/parallel-run | 23 +++++++++++++++++++++++ 3 files changed, 38 insertions(+), 18 deletions(-) create mode 100755 scripts/parallel-run diff --git a/circle.yml b/circle.yml index 582cedd2..2edd68dd 100644 --- a/circle.yml +++ b/circle.yml @@ -1,4 +1,3 @@ -# Customize the test machine machine: pre: - git config --global user.email "circleci@joyent.zone" @@ -7,7 +6,7 @@ machine: services: - docker node: - version: 7.7.3 + version: 7.10.0 dependencies: override: @@ -29,10 +28,18 @@ test: # mkdir coverage artifact folders - ls -1 packages | xargs -I % mkdir -p $CIRCLE_ARTIFACTS/"%" override: - # lint - - yarn run lint-ci - # test - - yarn run test-ci + # lint + - ./scripts/parallel-run --cmd="lint-ci": + parallel: true + files: + - packages/*/package.json + - package.json + # test + - ./scripts/parallel-run --cmd="test-ci": + parallel: true + files: + - packages/*/package.json + - package.json deployment: pre: @@ -46,11 +53,3 @@ deployment: branch: master commands: - ./scripts/deploy -# production: -# tag: /production-*/ -# commands: -# - CIRCLE_BRANCH=staging ./bin/docker-login -# - CIRCLE_BRANCH=staging ./bin/on-changes-publish-ui -# - CIRCLE_BRANCH=staging make -j2 build -# - CIRCLE_BRANCH=staging make -j2 push -# - CIRCLE_BRANCH=staging ./bin/deploy diff --git a/package.json b/package.json index 2b2109f7..e1076b60 100644 --- a/package.json +++ b/package.json @@ -15,12 +15,10 @@ "lint-docs": "./scripts/quality-docs", "lint:root": "eslint scripts/* --fix", "lint:packages": "lerna run lint", - "lint-ci:packages": "lerna run lint-ci", - "lint-ci:root": "eslint scripts/* --format junit --output-file $CIRCLE_TEST_REPORTS/lint/container-pilot-dashboard.xml", "lint": "redrun -s lint:*", "test": "lerna run test", - "lint-ci": "redrun -p lint-ci:*", - "test-ci": "lerna run test-ci", + "lint-ci": "eslint scripts/* --format junit --output-file $CIRCLE_TEST_REPORTS/lint/container-pilot-dashboard.xml", + "test-ci": "exit 0", "clean": "lerna clean --yes", "bootstrap": "lerna bootstrap", "dev": "redrun -p dev:*", diff --git a/scripts/parallel-run b/scripts/parallel-run new file mode 100755 index 00000000..b09d8066 --- /dev/null +++ b/scripts/parallel-run @@ -0,0 +1,23 @@ +#!/usr/bin/env node + +const argv = require('yargs').argv; +const forEach = require('apr-for-each'); +const main = require('apr-main'); +const execa = require('execa'); +const path = require('path'); + +const ROOT = process.cwd(); + +if (!argv.cmd) { + throw new Error('Missing --cmd argument'); +} + +const run = () => + forEach(argv._, file => + execa('yarn', ['run', argv.cmd], { + cwd: path.dirname(path.join(ROOT, file)), + stdio: 'inherit' + }) + ); + +main(run());