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.
126 lines
3.3 KiB
126 lines
3.3 KiB
|
|
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
|
|
|
|
test_unit:
|
|
<<: *shared-config
|
|
steps:
|
|
- checkout
|
|
- restore_cache:
|
|
key: dependencies-{{ checksum "package.json" }}-v1
|
|
- run:
|
|
command: yarn test
|
|
environment:
|
|
DATABASE_URL: postgres://psqluer:psqlpassword@localhost:5432/psqluer
|
|
end_to_end:
|
|
docker:
|
|
- image: circleci/node:lts-fermium
|
|
- image: circleci/postgres:9.6.5
|
|
environment:
|
|
POSTGRES_DB: $PG_DB
|
|
POSTGRES_USER: $PG_USER
|
|
POSTGRES_PASSWORD: $PG_PASS
|
|
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_PASS@localhost:5432/$PG_DB
|
|
lint:
|
|
<<: *shared-config
|
|
steps:
|
|
- checkout
|
|
- restore_cache:
|
|
key: dependencies-{{ checksum "package.json" }}-v1
|
|
- run: yarn lint
|
|
- run: yarn format:check
|
|
|
|
heroku_deploy:
|
|
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
|
|
|
|
docker-build:
|
|
working_directory: /dockerapp
|
|
docker:
|
|
- image: docker:17.05.0-ce-git
|
|
steps:
|
|
- checkout
|
|
- setup_remote_docker:
|
|
version: 19.03.13
|
|
- run:
|
|
name: Build application Docker image
|
|
command: |
|
|
docker build -t app .
|
|
- deploy:
|
|
name: Publish application to docker hub
|
|
command: |
|
|
docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD
|
|
docker tag app $DOCKERHUB_USERNAME/$DOCKERHUB_APP_NAME:$CIRCLE_BUILD_NUM
|
|
docker tag app $DOCKERHUB_USERNAME/$DOCKERHUB_APP_NAME:latest
|
|
docker push $DOCKERHUB_USERNAME/$DOCKERHUB_APP_NAME:$CIRCLE_BUILD_NUM
|
|
docker push $DOCKERHUB_USERNAME/$DOCKERHUB_APP_NAME:latest
|
|
|
|
|
|
version: 2
|
|
workflows:
|
|
my_workflow:
|
|
jobs:
|
|
- build
|
|
- test_unit
|
|
- end_to_end:
|
|
requires:
|
|
- build
|
|
- lint:
|
|
requires:
|
|
- build
|
|
- heroku_deploy:
|
|
requires:
|
|
- build
|
|
- test_unit
|
|
- end_to_end
|
|
- lint
|
|
filters:
|
|
branches:
|
|
only: main
|
|
|
|
- docker_build:
|
|
requires:
|
|
- build
|
|
- test_unit
|
|
- end_to_end
|
|
- lint
|
|
- heroku_deploy
|
|
filters:
|
|
branches:
|
|
only: main
|
|
version: 2
|