From a56ecb62530c1048fefeee34299384946fb7ecf0 Mon Sep 17 00:00:00 2001 From: Erik Ziegler Date: Mon, 13 Sep 2021 11:52:25 +0200 Subject: [PATCH] chore: Switch from Travis to CircleCI (#473) --- .circleci/config.yml | 151 +++++++++++++++++++++++++++++++++++++++++++ .circleci/version.sh | 27 ++++++++ .travis.yml | 15 ----- 3 files changed, 178 insertions(+), 15 deletions(-) create mode 100644 .circleci/config.yml create mode 100644 .circleci/version.sh delete mode 100644 .travis.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 00000000..77c9cbd1 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,151 @@ +version: 2.1 + +orbs: + coveralls: coveralls/coveralls@1.0.6 + puppeteer: threetreeslight/puppeteer@0.1.2 + +defaults: &defaults + working_directory: ~/repo + docker: + - image: circleci/node:latest-browsers + +jobs: + checkout_code: + <<: *defaults + steps: + - checkout + - attach_workspace: + at: ~/repo + - restore_cache: + keys: + - v1-dependencies-{{ checksum "package.json" }} + - v1-dependencies- + - puppeteer/install + - run: npm install + - save_cache: + paths: + - node_modules + key: v1-dependencies-{{ checksum "package.json" }} + - persist_to_workspace: + root: ~/repo + paths: . + + test_and_report: + <<: *defaults + steps: + - attach_workspace: + at: ~/repo + - run: npm install + - run: npm rebuild + - run: + name: Install codecov + command: npm install --save-dev codecov + - run: + name: Tests && Codecov Report + command: npm run test + - coveralls/upload + - store_artifacts: + path: ./coverage/ + prefix: tests + - store_artifacts: + path: coverage + prefix: coverage + - store_test_results: + path: ./coverage/ + + build: + <<: *defaults + steps: + - attach_workspace: + at: ~/repo + - run: npm install + - run: npm rebuild + - run: + name: Build our app + command: npm run build + - persist_to_workspace: + root: ~/repo + paths: . + + publish_npm: + <<: *defaults + steps: + - attach_workspace: + at: ~/repo + - run: npm install + - run: + name: Avoid hosts unknown for github + command: mkdir ~/.ssh/ && echo -e "Host github.com\n\tStrictHostKeyChecking no\n" > ~/.ssh/config + - run: + name: Publish using Semantic Release + command: npx semantic-release + - persist_to_workspace: + root: ~/repo + paths: . + + publish_docs: + working_directory: ~/repo + docker: + - image: circleci/ruby:2.6.0-node + environment: + BUNDLE_PATH: ~/repo/vendor/bundle + steps: + - attach_workspace: + at: ~/repo + - run: + name: Avoid hosts unknown for github + command: mkdir ~/.ssh/ && echo -e "Host github.com\n\tStrictHostKeyChecking no\n" > ~/.ssh/config + - run: npm install + - run: sudo npm install gitbook-cli -g + - run: + name: Do Magic + command: sh ~/repo/build/update-docs.sh + +workflows: + version: 2 + + ### + # PULL REQUESTS + ### + test_build: + jobs: + - checkout_code: + filters: + branches: + ignore: + - master + - feature/* + - hotfix/* + - test_and_report: + requires: + - checkout_code + - build: + requires: + - checkout_code + + ### + # MERGE: MASTER + ### + test_build_publish: + jobs: + - checkout_code: + filters: + branches: + only: master + - test_and_report: + requires: + - checkout_code + - build: + requires: + - checkout_code + - publish_npm: + requires: + - checkout_code + - test_and_report + - build + # - build_examples: + # requires: + # - publish_npm + - publish_docs: + requires: + - publish_npm \ No newline at end of file diff --git a/.circleci/version.sh b/.circleci/version.sh new file mode 100644 index 00000000..caf470b8 --- /dev/null +++ b/.circleci/version.sh @@ -0,0 +1,27 @@ +# reads version from package.json and sets prelease equal to Circle CI build number +if [ $CI ] && [ $CIRCLE_BUILD_NUM ] +then + PACKAGE_VERSION=$(cat package.json \ + | grep version \ + | head -1 \ + | awk -F: '{ print $2 }' \ + | sed 's/[",]//g' \ + | tr -d '[[:space:]]') + + NEW_PACKAGE_VERSION=$(echo $PACKAGE_VERSION | sed -e "s/^\([0-9]*\.[0-9]*\.[0-9]*\-[a-z]*\).[0-9]*$/\1.$CIRCLE_BUILD_NUM/") + echo "Found package version: $PACKAGE_VERSION" + echo "Setting version to: $NEW_PACKAGE_VERSION" + # uses npm-version to set version in package.json + # see https://docs.npmjs.com/cli/version + npm version $NEW_PACKAGE_VERSION --no-git-tag-version + # + git config credential.helper 'cache --timeout=120' + git config user.email "danny.ri.brown@gmail.com" + git config user.name "Daniel Brown" + git add . + git commit --allow-empty -m "Version Bump" + # Push quietly to prevent showing the token in log + # git push -q https://${GITHUB_TOKEN}@github.com/cornerstonejs/cornerstoneTools.git vNext +else + echo "Don't forget to update the build version!" +fi \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 5db934da..00000000 --- a/.travis.yml +++ /dev/null @@ -1,15 +0,0 @@ -language: node_js - -addons: - chrome: stable - -node_js: - - "lts/*" - -cache: - yarn: true - directories: - - node_modules - -after_success: - cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js \ No newline at end of file