Skip to content

Commit

Permalink
chore: Switch from Travis to CircleCI (#473)
Browse files Browse the repository at this point in the history
  • Loading branch information
swederik authored Sep 13, 2021
1 parent 725bf5b commit a56ecb6
Show file tree
Hide file tree
Showing 3 changed files with 178 additions and 15 deletions.
151 changes: 151 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
version: 2.1

orbs:
coveralls: coveralls/[email protected]
puppeteer: threetreeslight/[email protected]

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
27 changes: 27 additions & 0 deletions .circleci/version.sh
Original file line number Diff line number Diff line change
@@ -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 "[email protected]"
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
15 changes: 0 additions & 15 deletions .travis.yml

This file was deleted.

0 comments on commit a56ecb6

Please sign in to comment.