Skip to content

Instantly share code, notes, and snippets.

@alvincrespo
Created April 28, 2019 16:50
Show Gist options
  • Save alvincrespo/9492b9d53689fffac4f7b0923d994000 to your computer and use it in GitHub Desktop.
Save alvincrespo/9492b9d53689fffac4f7b0923d994000 to your computer and use it in GitHub Desktop.
Reusing Configuration across Jobs in CircleCI 2.1
version: 2.1
executors:
my-executor:
docker:
- image: cypress/base:8
environment:
TERM: xterm
working_directory: ~/app
jobs:
build:
executor: my-executor
steps:
- checkout
- restore_cache:
keys:
- v2-deps-{{ .Branch }}-{{ checksum "package-lock.json" }}
- v2-deps-{{ .Branch }}-
- v2-deps-
- run:
name: Install Dependencies
command: npm install
- save_cache:
key: v2-deps-{{ .Branch }}-{{ checksum "package-lock.json" }}
paths:
- ~/.npm
- ~/.cache
- run:
name: Linting Project
command: npm run lint
- run:
name: Installing Static Site Server
command: npm i -g serve
- run:
name: Building Application
command: npm run build
- run:
name: Running Create React App
command: npm run start
background: true
- run:
name: Running Cypress
command: npm run cypress
- store_artifacts:
path: cypress/videos
- store_artifacts:
path: cypress/screenshots
release:
executor: my-executor
steps:
- checkout
- restore_cache:
keys:
- v2-deps-{{ .Branch }}-{{ checksum "package-lock.json" }}
- v2-deps-{{ .Branch }}-
- v2-deps-
- run:
name: Semantic Release
command: npx semantic-release
workflows:
version: 2
test_and_release:
jobs:
- build
- release:
requires:
- build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment