version: 2 jobs: build: &shared-config docker: - image: circleci/node:lts-fermium working_directory: ~/repo steps: - checkout - restore_cache: keys: - dependencies-{{ checksum "package.json" }}-v1 - dependencies- - run: yarn install - save_cache: paths: - node_modules key: dependencies-{{ checksum "package.json" }}-v1 lint: <<: *shared-config steps: - checkout - restore_cache: key: dependencies-{{ checksum "package.json" }}-v1 - run: yarn lint - run: yarn format:check back-test-unit: <<: *shared-config steps: - checkout - restore_cache: key: dependencies-{{ checksum "package.json" }}-v1 - run: command: yarn test environment: DATABASE_URL: postgres://$PG_USER:$PG_PASSWORD@localhost:5432/$PG_USER back-test-e2e: docker: - image: circleci/node:lts-fermium - image: circleci/postgres:9.6.5 environment: POSTGRES_DB: $PG_USER POSTGRES_USER: $PG_USER POSTGRES_PASSWORD: $PG_PASSWORD working_directory: ~/repo steps: - checkout - restore_cache: key: dependencies-{{ checksum "package.json" }}-v1 - run: command: yarn test:e2e environment: DATABASE_URL: postgres://$PG_USER:$PG_PASSWORD@localhost:5432/$PG_USER back-deploy-heroku: docker: - image: buildpack-deps:trusty steps: - checkout - run: name: Heroku Deploy command: git push https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_APP_NAME.git HEAD:main - run: name: Smoke Test command: | HTTPCODE=`curl -s -o /dev/null -w "%{http_code}" https://$HEROKU_APP_NAME.herokuapp.com/` if [ "$HTTPCODE" -ne 200 ];then echo "heroku app not responding, failing deploy" exit 1 fi server-doc-build: <<: *shared-config steps: - checkout - restore_cache: key: dependencies-{{ checksum "package.json" }}-v1 - run: yarn doc:build - run: name: Copy deployment artifacts to workspace command: | cp docs/ /tmp/server-doc -r - store_artifacts: path: /tmp/server-doc - persist_to_workspace: root: /tmp paths: - server-doc workflows: version: 2 build-test-and-lint: jobs: - build - lint: requires : - build - back-test-unit: requires: - build - back-test-e2e: requires: - build - back-deploy-heroku: requires: - build - lint - back-test-unit - back-test-e2e filters: branches: only: main - server-doc-build: requires: - build - lint - back-test-e2e - back-test-unit filters: branches: only: main