From 52c331a220fa1fb753abb9f8a96cb841c9e936f1 Mon Sep 17 00:00:00 2001 From: Sergey Peshkov Date: Tue, 4 Feb 2020 15:06:15 +0300 Subject: [PATCH] feat(ci): added CircleCI --- .circleci/config.yml | 91 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 00000000..6f63cbfc --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,91 @@ +orbs: + slack: circleci/slack@3.4.1 +version: 2.1 +jobs: + test: + machine: + image: ubuntu-1604:201903-01 + steps: + - checkout + - run: docker run --name postgres -p 5432:5432 -d postgres:10.6 + - run: + name: Install Node + command: | + curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - + sudo apt-get install -y nodejs + echo 'export PATH=/usr/bin:$PATH' >> $BASH_ENV + which node && node -v + - run: npm install + - run: mkdir -p ~/reports/jest + - run: + name: Run tests + command: JEST_JUNIT_OUTPUT_DIR=$HOME/reports/jest npm test -- --reporters=default --reporters=jest-junit + - run: ./node_modules/.bin/codecov + - store_test_results: + path: ~/reports + - store_artifacts: + path: ~/reports + build: + machine: + image: ubuntu-1604:201903-01 + steps: + - checkout + - run: docker-compose -f docker/docker-compose.yml -f docker/docker-compose.dev.yml build --no-cache oms-core-js + lint: + machine: + image: ubuntu-1604:201903-01 + steps: + - checkout + - run: + name: Install Node + command: | + curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - + sudo apt-get install -y nodejs + echo 'export PATH=/usr/bin:$PATH' >> $BASH_ENV + which node && node -v + - run: npm install + - run: mkdir -p ~/reports + - run: npm run lint -- --format junit --output-file ~/reports/eslint.xml + - store_test_results: + path: ~/reports + - store_artifacts: + path: ~/reports + audit: + machine: + image: ubuntu-1604:201903-01 + steps: + - checkout + - run: npm audit + docker-build-and-push: + machine: + image: ubuntu-1604:201903-01 + steps: + - checkout + - run: docker build --tag aegee/oms-core-js:$(node -p "require('./package.json').version") --tag aegee/oms-core-js:latest -f docker/oms-core-js/Dockerfile . + - run: docker login --username $DOCKER_LOGIN --password $DOCKER_PASSWORD + - run: docker push aegee/oms-core-js:$(node -p "require('./package.json').version") + - run: docker push aegee/oms-core-js:latest + - slack/status: + success_message: The Docker image for \`$CIRCLE_PROJECT_REPONAME\` with tags \`$(node -p "require('./package.json').version")\` and \`latest\` has been pushed to Dockerhub. + failure_message: The Docker image for \`$CIRCLE_PROJECT_REPONAME\` build and push has failed. + +workflows: + version: 2 + # test: + # jobs: + # - test + lint: + jobs: + - lint + audit: + jobs: + - audit + build: + jobs: + - build + # docker-build-and-push: + # jobs: + # - docker-build-and-push: + # filters: + # branches: + # only: master