Skip to content

Commit

Permalink
chore(build): try to publish to npm (#3675)
Browse files Browse the repository at this point in the history
  • Loading branch information
sedghi authored Sep 26, 2023
1 parent 10ca35d commit c86b129
Show file tree
Hide file tree
Showing 19 changed files with 236 additions and 143 deletions.
266 changes: 150 additions & 116 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,24 @@ version: 2.1
##
orbs:
codecov: codecov/[email protected]
cypress: cypress-io/cypress@3
# executors:
# # Custom executor to override Cypress config
# deploy-to-prod-executor:
# docker:
# - image: cimg/node:16.14
# environment:
# CYPRESS_BASE_URL: https://ohif-staging.netlify.com/
# chrome-and-pacs:
# docker:
# # Primary container image where all steps run.
# - image: 'cypress/browsers:node18.12.0-chrome106-ff106'
cypress: cypress-io/[email protected]

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

defaults: &defaults
docker:
- image: cimg/node:16.14-browsers
- image: cimg/node:18.18
environment:
TERM: xterm # Enable colors in term
QUICK_BUILD: true
Expand All @@ -43,6 +45,7 @@ jobs:
steps:
# Update yarn
- run: yarn -v
- run: node --version
# Checkout code and ALL Git Tags
- checkout
- restore_cache:
Expand Down Expand Up @@ -93,39 +96,39 @@ jobs:
###
# Workflow: PR_OPTIONAL_DOCKER_PUBLISH
###
DOCKER_PR_PUBLISH:
<<: *defaults
steps:
# Enable yarn workspaces
- run: yarn config set workspaces-experimental true
# DOCKER_PR_PUBLISH:
# <<: *defaults
# steps:
# # Enable yarn workspaces
# - run: yarn config set workspaces-experimental true

# Checkout code and ALL Git Tags
- checkout
- 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-
# # Checkout code and ALL Git Tags
# - checkout
# - 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
# - run:
# name: Install Dependencies
# command: yarn install --frozen-lockfile

- setup_remote_docker:
docker_layer_caching: false
# - setup_remote_docker:
# docker_layer_caching: false

- run:
name: Build and push Docker image
command: |
# Remove npm config
rm -f ./.npmrc
# Set our version number using vars
echo $CIRCLE_BUILD_NUM
# Build our image, auth, and push
docker build --tag ohif/app:PR_BUILD-$CIRCLE_BUILD_NUM .
echo $DOCKER_PWD | docker login -u $DOCKER_LOGIN --password-stdin
docker push ohif/app:PR_BUILD-$CIRCLE_BUILD_NUM
# - run:
# name: Build and push Docker image
# command: |
# # Remove npm config
# rm -f ./.npmrc
# # Set our version number using vars
# echo $CIRCLE_BUILD_NUM
# # Build our image, auth, and push
# docker build --tag ohif/app:PR_BUILD-$CIRCLE_BUILD_NUM .
# echo $DOCKER_PWD | docker login -u $DOCKER_LOGIN --password-stdin
# docker push ohif/app:PR_BUILD-$CIRCLE_BUILD_NUM

###
# Workflow: DEPLOY
Expand Down Expand Up @@ -177,63 +180,6 @@ jobs:
- commit.txt
- version.json

# DEPLOY_TO_DEV:
# docker:
# - image: circleci/node:16.14.0
# environment:
# TERM: xterm
# NETLIFY_SITE_ID: 32708787-c9b0-4634-b50f-7ca41952da77
# working_directory: ~/repo
# steps:
# - attach_workspace:
# at: ~/repo
# - run: cd .netlify && npm install
# - run: cp .netlify/deploy-workflow/_redirects platform/app/dist/_redirects
# - run: cd .netlify && npm run deploy

# DEPLOY_TO_STAGING:
# docker:
# - image: circleci/node:16.14.0
# environment:
# TERM: xterm
# NETLIFY_SITE_ID: c7502ae3-b150-493c-8422-05701e44a969
# working_directory: ~/repo
# steps:
# - attach_workspace:
# at: ~/repo
# - run: cd .netlify && npm install
# - run: cp .netlify/deploy-workflow/_redirects platform/app/dist/_redirects
# - run: cd .netlify && npm run deploy

# DEPLOY_TO_PRODUCTION:
# docker:
# - image: circleci/node:16.14.0
# environment:
# TERM: xterm
# NETLIFY_SITE_ID: 79c4a5da-5c95-4dc9-84f7-45fd9dfe21b0
# working_directory: ~/repo
# steps:
# - attach_workspace:
# at: ~/repo
# - run: cd .netlify && npm install
# - run: cp .netlify/deploy-workflow/_redirects platform/app/dist/_redirects
# - run: cd .netlify && npm run deploy

# DEPLOY_TO_RELEASE_DEV:
# docker:
# - image: circleci/node:16.14.0
# environment:
# TERM: xterm
# NETLIFY_SITE_ID: 3270878-22
# working_directory: ~/repo
# steps:
# - attach_workspace:
# at: ~/repo
# - run: cd .netlify && npm install
# - run:
# cp .netlify/deploy-workflow/_redirects platform/app/dist/_redirects
# - run: cd .netlify && npm run deploy

###
# Workflow: RELEASE
###
Expand Down Expand Up @@ -362,28 +308,116 @@ jobs:
docker push ohif/app:$IMAGE_VERSION_FULL
fi
# 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 >>

workflows:
PR_CHECKS:
jobs:
- UNIT_TESTS

- cypress/run:
name: 'E2E: PWA'
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'
post-steps:
- store_artifacts:
path: platform/app/cypress/screenshots
- store_artifacts:
path: platform/app/cypress/videos
- store_test_results:
path: platform/app/cypress/results
- 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'
requires:
- UNIT_TESTS

Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ body:
attributes:
label: 'Node version'
description: 'Your Node.js version.'
placeholder: 'e.g., 16.14.0'
placeholder: 'e.g., 18.16.1'
validations:
required: true
- type: input
Expand Down
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ after the commits are squashed.
#### Tested Environment

- [] OS: <!--[e.g. Windows 10, macOS 10.15.4]-->
- [] Node version: <!--[e.g. 16.14.0]-->
- [] Node version: <!--[e.g. 18.16.1]-->
- [] Browser:
<!--[e.g. Chrome 83.0.4103.116, Firefox 77.0.1, Safari 13.1.1]-->

Expand Down
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16.14.0
18.16.1
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

# Stage 1: Build the application
# docker build -t ohif/viewer:latest .
FROM node:16.15.0-slim as json-copier
FROM node:18.16.1-slim as json-copier

RUN mkdir /usr/src/app
WORKDIR /usr/src/app
Expand All @@ -37,7 +37,7 @@ COPY platform /usr/src/app/platform
#RUN find platform \! -name "package.json" -mindepth 2 -maxdepth 2 -print | xargs rm -rf

# Copy Files
FROM node:16.15.0-slim as builder
FROM node:18.16.1-slim as builder
RUN apt-get update && apt-get install -y build-essential python3
RUN mkdir /usr/src/app
WORKDIR /usr/src/app
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
]
},
"engines": {
"node": ">=14",
"node": ">=16",
"npm": ">=6",
"yarn": ">=1.16.0"
},
Expand Down Expand Up @@ -104,7 +104,7 @@
"eslint-plugin-react-hooks": "^4.4.0",
"eslint-plugin-tsdoc": "^0.2.11",
"eslint-webpack-plugin": "^2.5.3",
"execa": "^7.1.1",
"execa": "^8.0.1",
"extract-css-chunks-webpack-plugin": "^4.5.4",
"html-webpack-plugin": "^5.3.2",
"husky": "^3.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@


# Stage 1: Build the application
FROM node:16.15.0-slim as builder
FROM node:18.16.1-slim as builder

RUN mkdir /usr/src/app
WORKDIR /usr/src/app
Expand Down
2 changes: 1 addition & 1 deletion platform/app/.recipes/OpenResty-Orthanc/dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@


# Stage 1: Build the application
FROM node:16.15.0-slim as builder
FROM node:18.16.1-slim as builder

RUN mkdir /usr/src/app
WORKDIR /usr/src/app
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('OHIF Context Menu', function () {
it('checks context menu customization', function () {
// Add length measurement
cy.addLengthMeasurement();
cy.get('[data-cy="prompt-begin-tracking-yes-btn"]').click();
cy.get('[data-cy="prompt-begin-tracking-yes-btn"]').as('yesBtn').click();
cy.get('[data-cy="measurement-item"]').click();

const [x1, y1] = [150, 100];
Expand Down
Loading

0 comments on commit c86b129

Please sign in to comment.