Last active
August 5, 2019 03:05
-
-
Save rasmar/1ef7ea547ca8f19d52e7a4c62d525cbe to your computer and use it in GitHub Desktop.
Frontend E2E Circle 2.0 config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defaults: &defaults | |
working_directory: ~/repo | |
docker: | |
- image: circleci/node:8.2.1 | |
version: 2 | |
jobs: | |
checkout_code: | |
<<: *defaults | |
steps: | |
- checkout | |
- persist_to_workspace: | |
root: ~/repo | |
paths: | |
- . | |
bundle_yarn: | |
<<: *defaults | |
steps: | |
- attach_workspace: | |
at: ~/repo | |
- restore-cache: | |
key: yarn-{{ checksum "yarn.lock" }} | |
- run: yarn install | |
- save-cache: | |
key: yarn-{{ checksum "yarn.lock" }} | |
paths: | |
- ~/repo/node_modules | |
- persist_to_workspace: | |
root: ~/repo | |
paths: | |
- node_modules | |
bundle_deployment_ruby: | |
docker: | |
- image: circleci/ruby:2.5 | |
working_directory: ~/repo/deployment | |
steps: | |
- attach_workspace: | |
at: ~/repo | |
- run: gem install bundler | |
- restore-cache: | |
key: deployment-gems-{{ checksum "Gemfile.lock" }} | |
- run: bundle install --deployment --path ~/repo/deployment/vendor/bundle | |
- save-cache: | |
key: deployment-gems-{{ checksum "Gemfile.lock" }} | |
paths: | |
- ~/repo/deployment/vendor/bundle | |
run_yarn_test: | |
<<: *defaults | |
steps: | |
- attach_workspace: | |
at: ~/repo | |
- restore-cache: | |
key: yarn-{{ checksum "yarn.lock" }} | |
- run: | |
name: Run yarn test | |
command: yarn test --coverage | |
run_lint: | |
<<: *defaults | |
steps: | |
- attach_workspace: | |
at: ~/repo | |
- restore-cache: | |
key: yarn-{{ checksum "yarn.lock" }} | |
- run: | |
name: Run lint | |
command: yarn eslint && yarn stylelint | |
build_frontend: | |
<<: *defaults | |
docker: | |
- image: circleci/node:8.2.1 | |
environment: | |
- NODE_ENV: test | |
- REACT_APP_API_BASE_URL: http://backend:5001 | |
steps: | |
- attach_workspace: | |
at: ~/repo | |
- restore-cache: | |
key: build-{{ .Branch }}-{{ .Revision }} | |
- run: yarn build | |
- save-cache: | |
key: build-{{ .Branch }}-{{ .Revision }} | |
paths: | |
- ~/repo/build | |
- persist_to_workspace: | |
root: ~/repo | |
paths: | |
- build | |
run_e2e_tests: | |
working_directory: ~/repo/e2e | |
machine: | |
image: circleci/classic:latest | |
environment: | |
- NODE_ENV: test | |
- REACT_APP_API_BASE_URL: http://backend:5001 | |
docker_layer_caching: true | |
steps: | |
- checkout | |
- attach_workspace: | |
at: ~/repo | |
- run: | |
name: pull backend repo | |
command: >- | |
GIT_SSH_COMMAND='ssh -i ~/.ssh/custom_ssh_key' | |
git clone [email protected]:netguru/backend_project.git ~/backend | |
- run: | |
name: prepare temporary directory for rspec results | |
command: sudo mkdir /rspec_output | |
- run: | |
name: build containers with docker-compose | |
command: docker-compose -f docker-compose.ci.yml build | |
- run: | |
name: start containers and run e2e tests | |
command: docker-compose -f docker-compose.ci.yml up --exit-code-from backend | |
- store_test_results: | |
path: /rspec_output | |
deploy_staging: | |
docker: | |
- image: circleci/ruby:2.5 | |
working_directory: ~/repo/deployment | |
steps: | |
- attach_workspace: | |
at: ~/repo | |
- restore-cache: | |
key: deployment-gems-{{ checksum "Gemfile.lock" }} | |
- run: | |
name: bundle config | |
command: bundle config --local path ~/repo/deployment/vendor/bundle | |
- run: | |
name: Deploy To Staging | |
command: bundle exec cap staging deploy | |
deploy_production: | |
docker: | |
- image: circleci/ruby:2.5 | |
working_directory: ~/repo/deployment | |
steps: | |
- attach_workspace: | |
at: ~/repo | |
- restore-cache: | |
key: deployment-gems-{{ checksum "Gemfile.lock" }} | |
- run: | |
name: bundle config | |
command: bundle config --local path ~/repo/deployment/vendor/bundle | |
- run: | |
name: Deploy To Staging | |
command: bundle exec cap production deploy | |
workflows: | |
version: 2 | |
build-and-deploy: | |
jobs: | |
- run_e2e_tests | |
- checkout_code | |
- bundle_yarn: | |
requires: | |
- checkout_code | |
- bundle_deployment_ruby: | |
requires: | |
- checkout_code | |
- run_yarn_test: | |
requires: | |
- bundle_yarn | |
- run_lint: | |
requires: | |
- bundle_yarn | |
- build_frontend: | |
requires: | |
- run_yarn_test | |
- deploy_staging: | |
requires: | |
- bundle_deployment_ruby | |
filters: | |
branches: | |
only: master | |
- deploy_production: | |
requires: | |
- bundle_deployment_ruby | |
filters: | |
branches: | |
only: production |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment