Yield generated for 4156d3f3-fcd0-4573-aa22-18d62c9887f0
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.
 
 

198 lines
4.7 KiB

globals:
credentials:
dockerhub_username: &dockerhub_username anthonyjhoiro
docker-config:
- &docker-config
image: cimg/node:16.10.0
auth:
username: *dockerhub_username
password: $DOCKERHUB_PASSWORD
setup:
- &install-cache
restore_cache:
keys:
- npm-v1-dependencies-{{ checksum "yarn.lock" }}
- &lint-cache
restore_cache:
keys:
- npm-v1-lint-{{ .BuildNum }}
version: 2.1
jobs:
install:
docker:
- *docker-config
steps:
- checkout
- *install-cache
- run:
name: Install deps using Yarn
command: yarn install
- save_cache:
name: Save Yarn Package Cache
key: npm-v1-dependencies-{{ checksum "yarn.lock" }}
paths:
- node_modules
lint:
docker:
- *docker-config
steps:
- checkout
- *install-cache
- *lint-cache
- run:
name: Check files format
command: yarn format:check
- run:
name: Lint files
command: yarn lint
- save_cache:
name: Save linted files
key: npm-v1-lint-{{ .BuildNum }}
paths:
- src
test-ci:
docker:
- *docker-config
steps:
- checkout
- *install-cache
- run:
name: Unit Tests
command: yarn test
test-e2e:
docker:
- *docker-config
- image: circleci/postgres:9.6-alpine
auth:
username: *dockerhub_username
password: $DOCKERHUB_PASSWORD
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: psdb
steps:
- checkout
- *install-cache
- run:
name: Run e2e tests
environment:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/psdb
command: yarn test:e2e
gendoc:
docker:
- *docker-config
steps:
- checkout
- *install-cache
- *lint-cache
- run:
name: Generate doc
command: yarn doc:build
- store_artifacts:
path: docs
builddocker:
docker:
- *docker-config
steps:
- checkout
- *install-cache
- setup_remote_docker # Can not cache docker in images in free tier
- run:
name: Build and Push docker image
command: docker build -t .
- run:
name: Login to docker hub
command: echo $DOCKERHUB_PASSWORD | docker login -u $DOCKERHUB_LOGIN --password-stdin
- when:
condition:
equal:
- main
- << pipeline.git.branch >>
steps:
- run:
name: Push Latest and Build number
command: |
docker tag app $DOCKERHUB_LOGIN/$DOCKERHUB_REPOSITORY:${CIRCLE_BUILD_NUM}
docker tag app $DOCKERHUB_LOGIN/$DOCKERHUB_REPOSITORY:latest
docker push $DOCKERHUB_LOGIN/$DOCKERHUB_REPOSITORY:${CIRCLE_BUILD_NUM}
docker push $DOCKERHUB_LOGIN/$DOCKERHUB_REPOSITORY:latest
- when:
condition:
equal:
- << pipeline.git.branch >>
- develop
steps:
- run: docker tag app $DOCKERHUB_LOGIN/$DOCKERHUB_REPOSITORY:${CIRCLE_BUILD_NUM}-dev
- run: docker push $DOCKERHUB_LOGIN/$DOCKERHUB_REPOSITORY:${CIRCLE_BUILD_NUM}-dev
- when:
condition:
or:
- matches:
value: << pipeline.git.branch >>
pattern: /^hotfix\/.*/
- matches:
value: << pipeline.git.branch >>
pattern: /^release\/.*/
steps:
- run: docker tag app $DOCKERHUB_LOGIN/$DOCKERHUB_REPOSITORY:${CIRCLE_BUILD_NUM}-prep
- run: docker push $DOCKERHUB_LOGIN/$DOCKERHUB_REPOSITORY:${CIRCLE_BUILD_NUM}-prep
- run:
name: Build and Push docker image
command: docker build -t .
workflows:
build-workflow:
jobs:
- install
- lint:
requires:
- install
- test-ci:
requires:
- install
- test-e2e:
requires:
- install
- gendoc:
requires:
- lint
- test-ci
- test-e2e
- builddocker:
filters:
branches:
# Run only on main branch
only:
- main
- develop
- /^hotfix\/.*/
- /^release\/.*/
requires:
- lint
- test-ci
- test-e2e