2019-08-13 21:36:46 +02:00
version : 2.1
2019-04-25 21:34:59 +02:00
### ABOUT
#
# This configuration powers our Circleci.io integration
#
# Note:
# Netlify works independently from this configuration to
# create pull request previews and to update `https://docs.ohif.org`
###
2019-09-10 03:33:38 +02:00
## https://github.com/cypress-io/circleci-orb
##
2019-08-13 21:36:46 +02:00
orbs :
codecov : codecov/codecov@1.0.5
2024-03-27 21:01:32 +01:00
cypress : cypress-io/cypress@3.3.1
2023-09-26 05:13:43 +02:00
executors :
cypress-custom :
description : |
Single Docker container used to run Cypress Tests
docker :
- image : cimg/node:<< parameters.node-version >>-browsers
parameters :
node-version :
default : '18.16.1'
description : |
The version of Node to run your tests with.
type : string
2019-08-13 21:36:46 +02:00
2019-04-25 21:34:59 +02:00
defaults : &defaults
docker :
2023-09-26 05:13:43 +02:00
- image : cimg/node:18.18
2019-08-13 21:36:46 +02:00
environment :
TERM : xterm # Enable colors in term
2019-11-14 21:27:34 +01:00
QUICK_BUILD : true
2019-08-13 21:36:46 +02:00
working_directory : ~/repo
2019-04-25 21:34:59 +02:00
jobs :
2019-11-14 21:01:55 +01:00
###
# Workflow: PR_CHECKS
###
2019-10-11 17:40:21 +02:00
UNIT_TESTS :
2019-04-25 21:34:59 +02:00
<< : *defaults
steps :
2019-10-11 17:40:21 +02:00
# Update yarn
- run : yarn -v
2023-09-26 05:13:43 +02:00
- run : node --version
2019-08-13 21:36:46 +02:00
# Checkout code and ALL Git Tags
2023-06-06 23:40:00 +02:00
- checkout
2019-04-25 21:34:59 +02:00
- restore_cache :
2019-06-22 16:02:07 +02:00
name : Restore Yarn and Cypress Package Cache
2019-04-25 21:34:59 +02:00
keys :
# when lock file changes, use increasingly general patterns to restore cache
2019-10-11 17:40:21 +02:00
- yarn-packages-{{ checksum "yarn.lock" }}
- yarn-packages-
2019-04-25 21:34:59 +02:00
- run :
name : Install Dependencies
command : yarn install --frozen-lockfile
- save_cache :
name : Save Yarn Package Cache
paths :
2019-06-22 16:02:07 +02:00
- ~/.cache ## Cache yarn and Cypress
2019-10-11 17:40:21 +02:00
key : yarn-packages-{{ checksum "yarn.lock" }}
# RUN TESTS
- run :
name : 'JavaScript Test Suite'
command : yarn run test:unit:ci
2023-06-06 19:34:26 +02:00
# platform/app
2019-10-11 17:40:21 +02:00
- run :
name: 'VIEWER : Combine report output'
command : |
2023-06-06 19:34:26 +02:00
viewerCov="/home/circleci/repo/platform/app/coverage"
2019-10-11 17:40:21 +02:00
touch "${viewerCov}/reports"
cat "${viewerCov}/clover.xml" >> "${viewerCov}/reports"
echo "\<<\<<\<< EOF" >> "${viewerCov}/reports"
cat "${viewerCov}/lcov.info" >>"${viewerCov}/reports"
echo "\<<\<<\<< EOF" >> "${viewerCov}/reports"
- codecov/upload :
2023-06-06 19:34:26 +02:00
file : '/home/circleci/repo/platform/app/coverage/reports'
2019-10-11 17:40:21 +02:00
flags : 'viewer'
# PLATFORM/CORE
- run :
name: 'CORE : Combine report output'
command : |
coreCov="/home/circleci/repo/platform/core/coverage"
touch "${coreCov}/reports"
cat "${coreCov}/clover.xml" >> "${coreCov}/reports"
echo "\<<\<<\<< EOF" >> "${coreCov}/reports"
cat "${coreCov}/lcov.info" >> "${coreCov}/reports"
echo "\<<\<<\<< EOF" >> "${coreCov}/reports"
- codecov/upload :
file : '/home/circleci/repo/platform/core/coverage/reports'
flags : 'core'
2019-11-14 21:01:55 +01:00
###
# Workflow: DEPLOY
###
BUILD :
<< : *defaults
steps :
# Checkout code and ALL Git Tags
2023-06-06 23:40:00 +02:00
- checkout
2019-11-14 21:01:55 +01:00
- restore_cache :
name : Restore Yarn and Cypress Package Cache
keys :
# when lock file changes, use increasingly general patterns to restore cache
- yarn-packages-{{ checksum "yarn.lock" }}
- yarn-packages-
- run :
name : Install Dependencies
command : yarn install --frozen-lockfile
2019-10-11 17:40:21 +02:00
- save_cache :
name : Save Yarn Package Cache
paths :
- ~/.cache ## Cache yarn and Cypress
key : yarn-packages-{{ checksum "yarn.lock" }}
2019-11-14 21:01:55 +01:00
# Build & Test
2023-06-06 20:15:36 +02:00
- run :
name : 'Perform the versioning before build'
2023-06-06 20:25:53 +02:00
command : node ./version.mjs
2019-08-13 21:36:46 +02:00
- run :
2019-11-14 21:01:55 +01:00
name : 'Build the OHIF Viewer'
command : yarn run build
no_output_timeout : 45m
2023-06-06 19:34:26 +02:00
- run :
name : 'Upload SourceMaps, Send Deploy Notification'
command : |
# export FILE_1=$(find ./build/static/js -type f -name "2.*.js" -exec basename {} \;)
# export FILE_MAIN=$(find ./build/static/js -type f -name "main.*.js" -exec basename {} \;)
# export FILE_RUNTIME_MAIN=$(find ./build/static/js -type f -name "runtime~main.*.js" -exec basename {} \;)
# curl https://api.rollbar.com/api/1/sourcemap -F source_map=@build/static/js/$FILE_1.map -F access_token=$ROLLBAR_TOKEN -F version=$CIRCLE_SHA1 -F minified_url=https://$GOOGLE_STORAGE_BUCKET/static/js/$FILE_1
# curl https://api.rollbar.com/api/1/sourcemap -F source_map=@build/static/js/$FILE_MAIN.map -F access_token=$ROLLBAR_TOKEN -F version=$CIRCLE_SHA1 -F minified_url=https://$GOOGLE_STORAGE_BUCKET/static/js/$FILE_MAIN
# curl https://api.rollbar.com/api/1/sourcemap -F source_map=@build/static/js/$FILE_RUNTIME_MAIN.map -F access_token=$ROLLBAR_TOKEN -F version=$CIRCLE_SHA1 -F minified_url=https://$GOOGLE_STORAGE_BUCKET/static/js/$FILE_RUNTIME_MAIN
curl --request POST https://api.rollbar.com/api/1/deploy/ -F access_token=$ROLLBAR_TOKEN -F environment=$GOOGLE_STORAGE_BUCKET -F revision=$CIRCLE_SHA1 -F local_username=CircleCI
2019-08-13 21:36:46 +02:00
# Persist :+1:
2019-11-14 21:01:55 +01:00
- persist_to_workspace :
2019-08-13 21:36:46 +02:00
root : ~/repo
2019-11-14 21:27:34 +01:00
paths :
2023-06-06 19:34:26 +02:00
- platform/app/dist
2023-06-06 23:17:26 +02:00
- Dockerfile
2023-06-06 22:02:59 +02:00
- version.txt
- commit.txt
- version.json
2019-06-22 16:02:07 +02:00
2023-10-03 17:44:56 +02:00
# just to make sure later on we can publish them
BUILD_PACKAGES_QUICK :
<< : *defaults
steps :
- run : yarn -v
# Checkout code and ALL Git Tags
- checkout
- attach_workspace :
at : ~/repo
# Use increasingly general patterns to restore cache
- restore_cache :
name : Restore Yarn and Cypress Package Cache
keys :
- yarn-packages-{{ checksum "yarn.lock" }}
- yarn-packages-
- run :
name : Install Dependencies
command : yarn install --frozen-lockfile
- save_cache :
name : Save Yarn Package Cache
paths :
- ~/.cache/yarn
key : yarn-packages-{{ checksum "yarn.lock" }}
- run :
name : Avoid hosts unknown for github
command : |
rm -rf ~/.ssh
mkdir ~/.ssh/
echo -e "Host github.com\n\tStrictHostKeyChecking no\n" > ~/.ssh/config
git config --global user.email "danny.ri.brown+ohif-bot@gmail.com"
git config --global user.name "ohif-bot"
- run :
name : Authenticate with NPM registry
command : echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/repo/.npmrc
- run :
name : Increase the event emitter limit
command : |
node ./increaseEventEmitterLimit.mjs
- run :
name : build half of the packages (to avoid out of memory in circleci)
command : |
yarn run build:package-all
- run :
name : build the other half of the packages
command : |
yarn run build:package-all-1
2019-11-14 21:01:55 +01:00
###
# Workflow: RELEASE
###
2019-09-10 03:34:23 +02:00
NPM_PUBLISH :
2019-04-26 20:24:59 +02:00
<< : *defaults
steps :
2019-11-14 22:32:14 +01:00
- run : yarn -v
# Checkout code and ALL Git Tags
2023-06-06 23:40:00 +02:00
- checkout
- attach_workspace :
at : ~/repo
2019-11-15 15:11:31 +01:00
# Use increasingly general patterns to restore cache
2019-11-14 22:32:14 +01:00
- restore_cache :
name : Restore Yarn and Cypress Package Cache
keys :
- yarn-packages-{{ checksum "yarn.lock" }}
- yarn-packages-
- run :
name : Install Dependencies
command : yarn install --frozen-lockfile
- save_cache :
name : Save Yarn Package Cache
paths :
2019-11-15 15:11:31 +01:00
- ~/.cache/yarn
2019-11-14 22:32:14 +01:00
key : yarn-packages-{{ checksum "yarn.lock" }}
2019-04-26 20:24:59 +02:00
- run :
name : Avoid hosts unknown for github
2019-11-15 15:11:31 +01:00
command : |
rm -rf ~/.ssh
mkdir ~/.ssh/
echo -e "Host github.com\n\tStrictHostKeyChecking no\n" > ~/.ssh/config
git config --global user.email "danny.ri.brown+ohif-bot@gmail.com"
git config --global user.name "ohif-bot"
2019-08-14 03:06:07 +02:00
- run :
2019-11-15 15:11:31 +01:00
name : Authenticate with NPM registry
2023-09-01 22:19:39 +02:00
command : echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/repo/.npmrc
2023-06-06 20:15:36 +02:00
- run :
name : Increase the event emitter limit
command : |
2023-06-06 20:25:53 +02:00
node ./increaseEventEmitterLimit.mjs
2023-06-06 20:15:36 +02:00
- run :
2023-06-06 22:49:18 +02:00
name : build half of the packages (to avoid out of memory in circleci)
2023-06-06 20:15:36 +02:00
command : |
yarn run build:package-all
2023-06-06 22:02:59 +02:00
- run :
name : build the other half of the packages
command : |
yarn run build:package-all-1
2023-09-26 17:43:37 +02:00
- run :
name : increase min time out
command : |
npm config set fetch-retry-mintimeout 20000
- run :
name : increase max time out
command : |
npm config set fetch-retry-maxtimeout 120000
2023-06-06 20:15:36 +02:00
- run :
2023-06-06 22:49:18 +02:00
name : publish package versions
2023-06-06 20:15:36 +02:00
command : |
2023-06-06 22:49:18 +02:00
node ./publish-version.mjs
- run :
name : Again set the NPM registry (was deleted in the version script)
2023-09-01 22:19:39 +02:00
command : echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/repo/.npmrc
2023-06-06 22:49:18 +02:00
- run :
name : publish package dist
command : |
node ./publish-package.mjs
2023-06-06 23:40:00 +02:00
- persist_to_workspace :
root : ~/repo
paths :
- .
2019-05-21 03:26:39 +02:00
2023-06-06 19:34:26 +02:00
DOCKER_RELEASE_PUBLISH :
2019-05-16 05:12:46 +02:00
<< : *defaults
steps :
2023-06-06 19:34:26 +02:00
- attach_workspace :
at : ~/repo
- setup_remote_docker :
docker_layer_caching : false
2019-05-16 06:05:19 +02:00
- run :
2023-06-06 19:34:26 +02:00
name : Build and push Docker image from the release branch
2019-11-15 15:11:47 +01:00
command : |
2023-06-06 19:34:26 +02:00
# This file will exist if a new version was published by
# our command in the previous job.
2023-06-06 22:02:59 +02:00
if [[ ! -e version.txt ]]; then
2023-06-06 19:34:26 +02:00
exit 0
else
# Remove npm config
rm -f ./.npmrc
# Set our version number using vars
2023-06-06 22:02:59 +02:00
export IMAGE_VERSION=$(cat version.txt)
2023-06-06 19:34:26 +02:00
export IMAGE_VERSION_FULL=v$IMAGE_VERSION
echo $IMAGE_VERSION
echo $IMAGE_VERSION_FULL
# Build our image, auth, and push
docker build --tag ohif/app:$IMAGE_VERSION_FULL --tag ohif/app:latest .
echo $DOCKER_PWD | docker login -u $DOCKER_LOGIN --password-stdin
docker push ohif/app:$IMAGE_VERSION_FULL
docker push ohif/app:latest
fi
2019-05-16 05:12:46 +02:00
2023-06-06 19:34:26 +02:00
DOCKER_BETA_PUBLISH :
2019-05-21 18:53:15 +02:00
<< : *defaults
steps :
- attach_workspace :
at : ~/repo
2019-10-11 11:14:54 +02:00
- setup_remote_docker :
2019-10-11 20:26:24 +02:00
docker_layer_caching : false
2019-05-21 18:53:15 +02:00
- run :
2023-09-01 22:19:39 +02:00
name : Build and push Docker image from the master branch (beta releases)
2019-05-21 18:53:15 +02:00
command : |
2023-06-06 21:49:31 +02:00
echo $(ls -l)
2019-05-21 20:51:57 +02:00
# This file will exist if a new version was published by
2023-06-06 19:34:26 +02:00
# our command in the previous job.
2023-06-06 22:02:59 +02:00
if [[ ! -e version.txt ]]; then
2023-06-06 21:49:31 +02:00
echo "don't have version txt"
2019-05-21 20:42:47 +02:00
exit 0
else
2023-06-06 21:49:31 +02:00
echo "Building and pushing Docker image from the master branch (beta releases)"
rm -f ./.npmrc
# Set our version number using vars
2023-06-06 22:02:59 +02:00
export IMAGE_VERSION=$(cat version.txt)
2023-06-06 21:49:31 +02:00
export IMAGE_VERSION_FULL=v$IMAGE_VERSION
echo $IMAGE_VERSION
echo $IMAGE_VERSION_FULL
# Build our image, auth, and push
echo "starting docker build"
docker build --tag ohif/app:$IMAGE_VERSION_FULL .
echo $DOCKER_PWD | docker login -u $DOCKER_LOGIN --password-stdin
echo "starting docker push"
docker push ohif/app:$IMAGE_VERSION_FULL
2019-05-21 20:42:47 +02:00
fi
2019-06-22 16:02:07 +02:00
2023-09-26 05:13:43 +02:00
# This is copied from the Cypress orb since the default for cypress/run is node 16 and
# we migrated to 18
CYPRESS_CUSTOM_RUN :
description : |
A single, complete job to run Cypress end-to-end tests in your application.
executor : cypress-custom
parallelism : << parameters.parallelism >>
parameters :
cypress-cache-key :
default : cypress-cache-{{ arch }}-{{ checksum "package.json" }}
description : Cache key used to cache the Cypress binary.
type : string
cypress-cache-path :
default : ~/.cache/Cypress
description : |
By default, this will cache the '~/.cache/Cypress' directory so that the Cypress binary is cached. You can override this by providing your own cache path.
type : string
cypress-command :
default : npx cypress run
description : Command used to run your Cypress tests
type : string
include-branch-in-node-cache-key :
default : false
description : |
If true, this cache will only apply to runs within the same branch. (Adds -{{ .Branch }}- to the node cache key)
type : boolean
install-browsers :
default : false
description : |
Cypress runs by default in the Electron browser. Use this flag to install additional browsers to run your tests in.
This is only needed if you are passing the `--browser` flag in your `cypress-command`.
This parameter leverages the `circleci/browser-tools` orb and includes Chrome and FireFox.
If you need additional browser support you can set this to false and use an executor with a docker image
that includes the browsers of your choosing. See https://hub.docker.com/r/cypress/browsers/tags
type : boolean
install-command :
default : ''
description : Overrides the default NPM command (npm ci)
type : string
node-cache-version :
default : v1
description :
Change the default node cache version if you need to clear the cache for any reason.
type : string
package-manager :
default : npm
description : Select the default node package manager to use. NPM v5+ Required.
enum :
- npm
- yarn
- yarn-berry
type : enum
parallelism :
default : 1
description : |
Number of Circle machines to use for load balancing, min 1
(requires `parallel` and `record` flags in your `cypress-command`)
type : integer
post-install :
default : ''
description : |
Additional commands to run after running install but before verifying Cypress and saving cache.
type : string
start-command :
default : ''
description : Command used to start your local dev server for Cypress to tests against
type : string
working-directory :
default : ''
description : Directory containing package.json
type : string
steps :
- cypress/install :
cypress-cache-key : << parameters.cypress-cache-key >>
cypress-cache-path : << parameters.cypress-cache-path >>
include-branch-in-node-cache-key : << parameters.include-branch-in-node-cache-key >>
install-browsers : << parameters.install-browsers >>
install-command : << parameters.install-command >>
node-cache-version : << parameters.node-cache-version >>
package-manager : << parameters.package-manager >>
post-install : << parameters.post-install >>
working-directory : << parameters.working-directory >>
- cypress/run-tests :
cypress-command : << parameters.cypress-command >>
start-command : << parameters.start-command >>
working-directory : << parameters.working-directory >>
2019-04-25 21:34:59 +02:00
workflows :
2021-03-01 16:52:54 +01:00
PR_CHECKS :
jobs :
2023-10-03 20:02:21 +02:00
- BUILD_PACKAGES_QUICK :
filters :
branches :
ignore : master
2023-10-03 17:44:56 +02:00
- UNIT_TESTS :
requires :
- BUILD_PACKAGES_QUICK
2023-09-26 05:13:43 +02:00
- CYPRESS_CUSTOM_RUN :
name : 'Cypress Tests'
context : cypress
matrix :
parameters :
start-command :
- yarn run test:data && yarn run test:e2e:serve
install-browsers :
- true
cypress-command :
- 'npx wait-on@latest http://localhost:3000 && cd platform/app && npx cypress run
--record --browser chrome --parallel'
package-manager :
- 'yarn'
cypress-cache-key :
- 'yarn-packages-{{ checksum "yarn.lock" }}'
cypress-cache-path :
- '~/.cache/Cypress'
2021-03-01 16:52:54 +01:00
requires :
2023-10-03 17:44:56 +02:00
- BUILD_PACKAGES_QUICK
2021-03-01 16:52:54 +01:00
2023-09-22 16:23:44 +02:00
# PR_OPTIONAL_VISUAL_TESTS:
# jobs:
# - AWAIT_APPROVAL:
# type: approval
# # Update hub.docker.org
# - cypress/run:
# name: 'Generate Percy Snapshots'
# executor: cypress/browsers-chrome76
# browser: chrome
# pre-steps:
# - run: 'rm -rf ~/.yarn && yarn -v && yarn global add wait-on'
# yarn: true
# store_artifacts: false
# working_directory: platform/app
# build:
# yarn test:data && npx cross-env QUICK_BUILD=true APP_CONFIG=config/dicomweb-server.js
# yarn run build
# # start server --> verify running --> percy + chrome + cypress
# command: yarn run test:e2e:dist
# cache-key: 'yarn-packages-{{ checksum "yarn.lock" }}'
# no-workspace: true # Don't persist workspace
# post-steps:
# - store_artifacts:
# path: platform/app/cypress/screenshots
# - store_artifacts:
# path: platform/app/cypress/videos
# requires:
# - AWAIT_APPROVAL
2019-12-11 04:17:21 +01:00
2023-06-06 19:34:26 +02:00
# Our master branch deploys to viewer-dev.ohif.org, the viewer.ohif.org is
# deployed from the release branch which is more stable and less frequently updated.
DEPLOY_MASTER :
2019-04-25 21:34:59 +02:00
jobs :
2019-11-14 21:01:55 +01:00
- BUILD :
2019-04-25 21:34:59 +02:00
filters :
branches :
2019-08-14 14:49:46 +02:00
only : master
2023-06-06 19:34:26 +02:00
- NPM_PUBLISH :
2019-11-14 21:01:55 +01:00
requires :
- BUILD
2023-06-06 19:34:26 +02:00
- DOCKER_BETA_PUBLISH :
requires :
2023-06-06 23:40:00 +02:00
- NPM_PUBLISH
2023-06-06 19:34:26 +02:00
# Our release branch deploys to viewer.ohif.org and is more stable and less
# frequently updated after being tested in the staging environment.
DEPLOY_RELEASE :
jobs :
- BUILD :
filters :
branches :
only : release
- NPM_PUBLISH :
2021-03-01 16:52:54 +01:00
requires :
2023-06-06 19:34:26 +02:00
- BUILD
- DOCKER_RELEASE_PUBLISH :
2021-03-01 16:52:54 +01:00
requires :
2023-06-06 23:40:00 +02:00
- NPM_PUBLISH
2021-03-01 16:52:54 +01:00
###
# Unit and E2E tests have already run for PR_CHECKS
# Re-running should not gain us any confidence here
###
2023-06-01 14:02:40 +02:00
# RELEASE:
# jobs:
# - NPM_PUBLISH:
# filters:
# branches:
# only: master
# - DOCS_PUBLISH:
# filters:
# branches:
# only: master
# # Update base branch snapshots
# # and record a Cypress dashboard test run
# - cypress/run:
# name: 'Generate Percy Snapshots'
# executor: cypress/browsers-chrome76
# browser: chrome
# pre-steps:
# - run: 'rm -rf ~/.yarn && npm i -g yarn && yarn -v && yarn global
# add wait-on' # Use yarn latest
# yarn: true
# store_artifacts: false
2023-06-06 19:34:26 +02:00
# working_directory: platform/app
2023-06-01 14:02:40 +02:00
# build:
# npx cross-env QUICK_BUILD=true APP_CONFIG=config/e2e.js yarn run
# build
# # start server --> verify running --> percy + chrome + cypress
# command: yarn run test:e2e:dist
# cache-key: 'yarn-packages-{{ checksum "yarn.lock" }}'
# no-workspace: true # Don't persist workspace
# post-steps:
# - store_artifacts:
2023-06-06 19:34:26 +02:00
# path: platform/app/cypress/screenshots
2023-06-01 14:02:40 +02:00
# - store_artifacts:
2023-06-06 19:34:26 +02:00
# path: platform/app/cypress/videos
2023-06-01 14:02:40 +02:00
# - store_test_results:
2023-06-06 19:34:26 +02:00
# path: platform/app/cypress/results
2023-06-01 14:02:40 +02:00
# filters:
# branches:
# only: master
# - DOCKER_MASTER_PUBLISH:
# requires:
# - NPM_PUBLISH