You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
135 lines
3.7 KiB
135 lines
3.7 KiB
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: string
|
|
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_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 .
|
|
push_docker_image:
|
|
executor: buildpack
|
|
environment:
|
|
IMAGE_NAME: my-awesome-ci-expr
|
|
steps:
|
|
- checkout
|
|
- 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 nicodrg/my-awesome-ci-expr:$CIRCLE_BUILD_NUM
|
|
- run:
|
|
name: Tag Docker image
|
|
command: docker tag $IMAGE_NAME:app nicodrg/my-awesome-ci-expr:latest
|
|
- run:
|
|
name: Push to Docker Hub
|
|
command: docker push $IMAGE_NAME:latest
|
|
generate_doc:
|
|
executor: node-executor
|
|
steps:
|
|
- checkout
|
|
- run:
|
|
name: Build doc
|
|
command: yarn doc:build
|
|
workflows:
|
|
version: 2
|
|
integration:
|
|
jobs:
|
|
- build
|
|
- lint:
|
|
requires:
|
|
- build
|
|
- test:
|
|
requires:
|
|
- build
|
|
- test_end_to_end:
|
|
requires:
|
|
- build
|
|
- build_docker_image:
|
|
requires:
|
|
- lint
|
|
- test
|
|
- test_end_to_end
|
|
- push_to_hub:
|
|
requires:
|
|
- build_docker_image
|