version: 2.1 executors: node-executor: docker: - image: circleci/node:12 auth: username: $DOCKERHUB_LOGIN password: $DOCKERHUB_PASSWORD node-and-postgresql-executor: docker: - image: circleci/node:12 auth: username: $DOCKERHUB_LOGIN password: $DOCKERHUB_PASSWORD - image: circleci/postgres:9.6.2-alpine auth: username: $DOCKERHUB_LOGIN password: $DOCKERHUB_PASSWORD environment: DATABASE_URL: "postgres://postgres:$POSTGRES_PASSWORD@localhost:5432/postgres" JWT_SECRET: API_PORT: 3000 API_HOST: localhost API_PROTOCOL: http POSTGRES_USER: postgres POSTGRES_PASSWORD: $POSTGRES_PASSWORD POSTGRES_DB: postgres buildpack: docker: - image: circleci/buildpack-deps:stretch auth: username: $DOCKERHUB_LOGIN password: $DOCKERHUB_PASSWORD jobs: build: executor: node-executor steps: - checkout - run: name: Install dependencies command: yarn global add node-gyp && yarn install - save_cache: name: Save Yarn package cache key: npm-v7-dependencies-{{ checksum "yarn.lock" }} paths: - ./node_modules lint: executor: node-executor steps: - checkout - restore_cache: name: Restore yarn package cache key: npm-v7-dependencies-{{ checksum "yarn.lock" }} - run: name: Analyse code with tslint and format with prettier command: yarn lint && yarn format:check test: executor: node-executor steps: - checkout - restore_cache: name: Restore yarn package cache key: npm-v7-dependencies-{{ checksum "yarn.lock" }} - run: name: Run test with jest command: yarn test:ci test_end_to_end: executor: node-and-postgresql-executor steps: - checkout - restore_cache: name: Restore yarn package cache key: npm-v7-dependencies-{{ checksum "yarn.lock" }} - run: name: Run end to end test command: yarn test:e2e build_and_push_docker_image: executor: buildpack environment: IMAGE_NAME: my-awesome-ci-expr steps: - checkout - setup_remote_docker: version: 19.03.13 - run: name: Build Docker image command: docker build -t $IMAGE_NAME:app . - run: name: Login to Docker Hub command: | echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_LOGIN" --password-stdin - run: name: Tag Docker image command: docker tag $IMAGE_NAME:app $DOCKERHUB_LOGIN/$IMAGE_NAME:$CIRCLE_BUILD_NUM - run: name: Tag Docker image command: docker tag $IMAGE_NAME:app $DOCKERHUB_LOGIN/$IMAGE_NAME:latest - run: name: Push to Docker Hub command: docker push $DOCKERHUB_LOGIN/$IMAGE_NAME:latest generate_doc: executor: node-executor steps: - checkout - restore_cache: name: Restore yarn package cache key: npm-v7-dependencies-{{ checksum "yarn.lock" }} - run: name: Build doc command: yarn doc:build - store_artifacts: path: doc-server/ destination: doc-artifact/ workflows: version: 2 integration: jobs: - build - lint: requires: - build - test: requires: - build - test_end_to_end: requires: - build - build_and_push_docker_image: requires: - lint - test - test_end_to_end - generate_doc: requires: - build_and_push_docker_image