From cddaa8a3b2b91725157e824d627dabe038615686 Mon Sep 17 00:00:00 2001 From: Andrey Kartashov Date: Mon, 19 Aug 2019 19:16:38 +0700 Subject: [PATCH 1/4] ci: create circleci workflows for publishing and premerge checks --- .circleci/config.yml | 84 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..b3a58c9 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,84 @@ +references: + master_only: &master_only + filters: + branches: + only: master + versions_only: &versions_only + filters: + tags: + only: /^v.*/ + branches: + ignore: /.*/ + not_master_branch: ¬_master_branch + filters: + branches: + ignore: master + + npm_cache_key: &npm_cache_key + v1-dependency-npm-{{ checksum "yarn.lock" }} + npm_backup_cache_key: &npm_backup_cache_key + v1-dependency-npm + + restore_node_modules: &restore_node_modules + restore_cache: + name: Restore node_modules from cache + keys: + - *npm_cache_key + - *npm_backup_cache_key + + save_node_modules: &save_node_modules + save_cache: + name: Save node_modules to cache + key: *npm_cache_key + paths: + - node_modules + +version: 2 + +workflows: + version: 2 + # every version (tagged commit) is published + publish: + jobs: + - publish: + <<: *versions_only + context: scalio-github-registry + premerge_check: + jobs: + - premerge_check: + <<: *not_master_branch + +jobs: + + publish: + docker: + - image: node:12 + steps: + - checkout + - *restore_node_modules + - run: yarn --frozen-lockfile + - *save_node_modules + - run: yarn build + - run: + name: configure access to GitHub NPM registry + command: | + echo "@scalio:registry=https://npm.pkg.github.com/" >> ~/.npmrc + echo "//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}" >> ~/.npmrc + - run: yarn publish --new-version ${CIRCLE_TAG} dist + + premerge_check: + docker: + - image: node:12 + - image: couchdb:latest + environment: + COUCHDB_PASSWORD: -pbkdf2-847043acc65626c8eb98da6d78682fbc493a1787,f7b1a3e4b624f4f0bbfe87e96841eda0,10 + COUCHDB_SECRET: 0123456789abcdef0123456789abcdef + COUCHDB_USER: couchdb + NODENAME: couchdb-0.docker.com + steps: + - checkout + - *restore_node_modules + - run: yarn + - *save_node_modules + - run: yarn lint + - run: yarn test From d16d6a7b56b8993f403095a2817bb1bc706745d5 Mon Sep 17 00:00:00 2001 From: Andrey Kartashov Date: Mon, 19 Aug 2019 19:20:28 +0700 Subject: [PATCH 2/4] ci: use `--frozen-lockfile` while installing deps with yarn --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index b3a58c9..5925fb0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -78,7 +78,7 @@ jobs: steps: - checkout - *restore_node_modules - - run: yarn + - run: yarn --frozen-lockfile - *save_node_modules - run: yarn lint - run: yarn test From 7b097ccd44ac6c8e5a04ccd32ca2c06b23b2a682 Mon Sep 17 00:00:00 2001 From: Andrey Kartashov Date: Mon, 19 Aug 2019 19:38:01 +0700 Subject: [PATCH 3/4] ci: add check (lint/test/build) for every commit to master --- .circleci/config.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 5925fb0..fb8a281 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -37,15 +37,21 @@ version: 2 workflows: version: 2 + # every commit to master is checked + master_lint_test_build: + jobs: + - lint_test_build: + <<: *master_only # every version (tagged commit) is published publish: jobs: - publish: <<: *versions_only context: scalio-github-registry + # every commit to branch which has PR is checked (CircleCI option 'Only build Pull Requests' should be enabled) premerge_check: jobs: - - premerge_check: + - lint_test_build: <<: *not_master_branch jobs: @@ -66,7 +72,7 @@ jobs: echo "//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}" >> ~/.npmrc - run: yarn publish --new-version ${CIRCLE_TAG} dist - premerge_check: + lint_test_build: docker: - image: node:12 - image: couchdb:latest @@ -82,3 +88,4 @@ jobs: - *save_node_modules - run: yarn lint - run: yarn test + - run: yarn build From 40628260d6009e1844ec7f4d238fe49bfbecbd68 Mon Sep 17 00:00:00 2001 From: Andrey Kartashov Date: Mon, 19 Aug 2019 19:39:10 +0700 Subject: [PATCH 4/4] chore: add circleci status badge to README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 0fb6cec..e2d51ff 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ ## Description +[![CircleCI](https://circleci.com/gh/scalio/nest-couchdb/tree/master.svg?style=svg)](https://circleci.com/gh/scalio/nest-couchdb/tree/master) + The [CouchDB](http://couchdb.apache.org/) module for Nest framework ## Installation