Skip to content

Instantly share code, notes, and snippets.

@willmendesneto
Last active April 9, 2018 23:38
Show Gist options
  • Save willmendesneto/ed3e2d02e692bf8e41ac8dbbdbc219b1 to your computer and use it in GitHub Desktop.
Save willmendesneto/ed3e2d02e692bf8e41ac8dbbdbc219b1 to your computer and use it in GitHub Desktop.
Using workflow to parallelise automated tasks on Circle CI
version: 2
docker_defaults: &docker_defaults
docker:
- image: circleci/node:8.11.1-browsers
working_directory: ~/project/repo
attach_workspace: &attach_workspace
attach_workspace:
at: ~/project
install_steps: &install_steps
steps:
- checkout
- restore_cache:
name: Restore node_modules cache
keys:
- dependency-cache-{{ .Branch }}-{{ checksum "package.json" }}
- dependency-cache-{{ .Branch }}-
- dependency-cache-
- run:
name: Installing Dependencies
command: |
if [ ! -d "./node_modules" ]; then
echo ">>> Installing Node packages using NPM"
npm install --silent
else
echo ">>> Using cached 'node_modules'"
fi
- save_cache:
name: Save node_modules cache
key: dependency-cache-{{ .Branch }}-{{ checksum "package.json" }}
paths:
- node_modules/
- persist_to_workspace:
root: ~/project
paths:
- repo
workflows:
version: 2
build_pipeline:
jobs:
- build
- unit_test:
requires:
- build
- bundle_size:
requires:
- build
- end_to_end:
requires:
- build
jobs:
build:
<<: *docker_defaults
<<: *install_steps
unit_test:
<<: *docker_defaults
steps:
- *attach_workspace
- run:
name: Running unit tests
command: |
sudo npm test -- --single-run --no-progress -cc
sudo npm run coveralls
bundle_size:
<<: *docker_defaults
steps:
- *attach_workspace
- run:
name: Checking bundle size
command: |
sudo npm run build
sudo npm run bundlesize
end_to_end:
<<: *docker_defaults
steps:
- *attach_workspace
- run:
name: Running E2E tests
command: |
sudo npm run e2e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment