diff --git a/.circleci/config.yml b/.circleci/config.yml index e7656a046..24218d869 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -10,16 +10,19 @@ version: 2 ### defaults: &defaults - working_directory: ~/repo docker: - - image: circleci/node:10.15.1 + - image: circleci/node:10.16.0 + working_directory: ~/repo jobs: - build_and_test: + unit_tests: <<: *defaults steps: - # Download and cache dependencies - - checkout + # Checkout code and ALL Git Tags + - checkout: + post: + - git fetch --all + - restore_cache: name: Restore Yarn and Cypress Package Cache keys: @@ -27,27 +30,32 @@ jobs: - yarn-packages-v1-{{ .Branch }}-{{ checksum "yarn.lock" }} - yarn-packages-v1-{{ .Branch }}- - yarn-packages-v1- + - run: name: Install Dependencies command: yarn install --frozen-lockfile + - save_cache: name: Save Yarn Package Cache paths: - ~/.cache ## Cache yarn and Cypress key: yarn-packages-v1-{{ .Branch }}-{{ checksum "yarn.lock" }} - # Build & Test - - run: yarn build:package:ci + + # Test + # TODO: lerna:tests # https://www.viget.com/articles/using-junit-on-circleci-2-0-with-jest-and-eslint/ - run: - name: 'JavaScript Test Suite' - command: yarn test:unit:ci + name: "JavaScript Test Suite" + command: yarn run test:unit environment: - JEST_JUNIT_OUTPUT: 'reports/junit/js-test-results.xml' + JEST_JUNIT_OUTPUT: "reports/junit/js-test-results.xml" + # Store result - store_test_results: path: reports/junit - store_artifacts: path: reports/junit + # Persist :+1: - persist_to_workspace: root: ~/repo @@ -167,7 +175,7 @@ jobs: key: yarn-packages-v1-{{ .Branch }}-{{ checksum "yarn.lock" }} # Build & Test - run: - name: 'Build Demo Site, Upload SourceMaps, Send Deploy Notification' + name: "Build Demo Site, Upload SourceMaps, Send Deploy Notification" command: | yarn build:demo:ci perl -i -pe 's##`cat .circleci/rollbar.html` #e' build/index.html @@ -214,7 +222,7 @@ workflows: # PULL REQUESTS pull_requests: jobs: - - build_and_test: + - unit_tests: filters: branches: ignore: @@ -225,13 +233,13 @@ workflows: # MERGE TO MASTER cut_release: jobs: - - build_and_test: + - unit_tests: filters: branches: only: master - e2e_test: requires: - - build_and_test + - unit_tests # Update NPM - npm_publish: requires: diff --git a/.netlify/build-deploy-preview.sh b/.netlify/build-deploy-preview.sh index 97cd9aad9..971fd41f2 100644 --- a/.netlify/build-deploy-preview.sh +++ b/.netlify/build-deploy-preview.sh @@ -77,15 +77,15 @@ yarn install --no-ignore-optional --pure-lockfile cd ./platform/viewer/ # Create a Versions File -node -p -e "export default require('./package.json').version;" > src/version.js +node -p -e "'export default require(\'./package.json\').version;'" > src/version.js # Copy over wado-image-loader codecs and worker file -cp './../../node_modules/cornerstone-wado-image-loader/dist/*.min.js*' public -v +cp ./../../node_modules/cornerstone-wado-image-loader/dist/*.min.js* public -v # Build using react-scripts # npx cross-env PUBLIC_URL=/demo REACT_APP_CONFIG=config/netlify.js react-scripts --max_old_space_size=4096 build # Build using WebPack # TODO: consume public/config correctly instead of hardcode npx webpack --config config/webpack.prod.js --mode production --env.production # Copy output to the folder that is our publish target -cp 'dist/**/*' ./../../docs/latest/_book/demo --verbose +cp dist/**/* ./../../docs/latest/_book/demo --verbose echo 'Nothing left to see here. Go home, folks.' diff --git a/package.json b/package.json index 5c96bac72..41675613d 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,9 @@ }, "scripts": { "start": "lerna run lerna:start --parallel", - "build": "lerna run lerna:build --parallel" + "build": "lerna run lerna:build --parallel", + "test:unit": "lerna run lerna:test:unit --parallel", + "build:pwa:ci": "" }, "devDependencies": { "@babel/core": "^7.5.0", diff --git a/platform/viewer/package.json b/platform/viewer/package.json index 74cc7057e..69d59b54d 100644 --- a/platform/viewer/package.json +++ b/platform/viewer/package.json @@ -14,6 +14,7 @@ "proxy": "http://localhost:8042", "scripts": { "lerna:start": "cross-env NODE_ENV=development webpack-dev-server --config config/webpack.dev.js --mode development -w -d", + "lerna:test:unit": "jest --ci --runInBand --collectCoverage --reporters=default --reporters=jest-junit && codecov", "cm": "npx git-cz", "dev": "yarn run preBuild && react-scripts start", "dev:debug": "react-scripts start", @@ -23,7 +24,6 @@ "build:demo:ci": "yarn run preBuild && cross-env PUBLIC_URL=/ REACT_APP_CONFIG=config/demo.js react-scripts --max_old_space_size=4096 build", "lint": "eslint -c .eslintrc --fix src && prettier --single-quote --write src/**/*.{js,jsx,json,css}", "test:unit": "jest", - "test:unit:ci": "jest --ci --runInBand --collectCoverage --reporters=default --reporters=jest-junit && codecov", "test:e2e:ci": "start-server-and-test start http://localhost:5000 cy:run:ci", "start": "yarn run dev", "predeploy": "cd example && npm install && yarn run build:package",