From 552df4c9a8079778b185065235751bc881de0524 Mon Sep 17 00:00:00 2001 From: Danny Brown Date: Mon, 26 Aug 2019 22:19:05 -0400 Subject: [PATCH] ci: test docs-publish (#803) * ci: test docs-publish * Require unit tests for dry run * ci: Make sure our docs publish is executable * Try to correct path issue * Try repo prefix * Try as yarn command * Need a workspace to attach to from previous step * Add before we call our bash script * See if we can enforce commands being available -- or just install locally? * Try again * Try SSH * Include username in gh https url * Note regarding failure on PR branches * Remove docs publish from PR workflow --- .circleci/build-and-publish-docs.sh | 83 +++++++++++++++++++++++++++++ .circleci/config.yml | 18 +++---- .netlify/build-deploy-preview.sh | 3 -- .netlify/publishStaticSite.sh | 13 ----- build-and-publish-docs.sh | 64 ++++++++++++++++++++++ package.json | 1 + yarn.lock | 32 ++++++----- 7 files changed, 175 insertions(+), 39 deletions(-) create mode 100644 .circleci/build-and-publish-docs.sh delete mode 100644 .netlify/publishStaticSite.sh create mode 100644 build-and-publish-docs.sh diff --git a/.circleci/build-and-publish-docs.sh b/.circleci/build-and-publish-docs.sh new file mode 100644 index 00000000000..3b27976cd97 --- /dev/null +++ b/.circleci/build-and-publish-docs.sh @@ -0,0 +1,83 @@ +#!/bin/bash + +# Set directory to location of this script +# https://stackoverflow.com/a/3355423/1867984 +cd "$(dirname "$0")" + +yarn -v +node -v + +echo 'Installing Gitbook CLI' +yarn global bin +yarn config get prefix +yarn config set prefix ~/.yarn +export PATH="$PATH:`yarn global bin`" +# yarn global add gitbook-cli +# yarn global add gh-pages +# npm i gitbook-cli -g +# npm i gh-pages -g +# yarn list + +# export PATH="$(yarn global bin):$PATH" + +which gitbook +which gh-pages + +echo 'Running Gitbook installation' + +# Generate all version's GitBook output +# For each directory in /docs ... +cd ./../docs/ +for D in *; do + if [ -d "${D}" ]; then + + echo "Generating output for: ${D}" + cd "${D}" + + # Clear previous output, generate new + rm -rf _book + gitbook install + gitbook build + + cd .. + + fi +done + +# Move CNAME File into `latest` +cp CNAME ./latest/_book/CNAME + +# Create a history folder in our latest version's output +mkdir ./latest/_book/history + +# Move each version's files to latest's history folder +for D in *; do + if [ -d "${D}" ]; then + if [ "${D}" == v* ] ; then + + echo "Moving ${D} to the latest version's history folder" + + mkdir "./latest/_book/history/${D}" + cp -v -r "./${D}/_book"/* "./latest/_book/history/${D}" + + fi + fi +done + +# Back to repo root +cd .. + +echo "Done generating documentation output" +echo 'PUBLISHING' + +# git config --global user.email "danny.ri.brown+ohif-bot@gmail.com" +# git config --global user.name "ohif-bot" +# git config user.email "danny.ri.brown+ohif-bot@gmail.com" +# git config user.name "ohif-bot" + +# WILL ALWAYS FAIL IF INITIATED FROM PR BRANCH +./node_modules/.bin/gh-pages \ + --silent \ + --repo https://$GITHUB_TOKEN@github.com/OHIF/Viewers.git \ + --message 'Autogenerated Message: [ci skip]' \ + --dist docs/latest/_book diff --git a/.circleci/config.yml b/.circleci/config.yml index b31ef9d349f..291efb76989 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -187,13 +187,13 @@ jobs: no\n" > ~/.ssh/config - run: git config --global user.email "danny.ri.brown+ohif-bot@gmail.com" - run: git config --global user.name "ohif-bot" + - run: yarn global add gitbook-cli - run: yarn global add gh-pages - - run: - name: Generate Docs - command: yarn run staticDeploy - - run: - name: Publish Docs - command: yarn run docs:publish + - run: chmod +x ~/repo/.circleci/build-and-publish-docs.sh + - run: ~/repo/.circleci/build-and-publish-docs.sh + # - run: + # name: Generate & Publish Docs + # command: yarn run docs:publish docker_publish: <<: *defaults @@ -330,9 +330,9 @@ workflows: requires: - cypress/run # Update docs.ohif.org - # - docs_publish: - # requires: - # - cypress/run + - docs_publish: + requires: + - cypress/run # Update hub.docker.org # - docker_publish: # requires: diff --git a/.netlify/build-deploy-preview.sh b/.netlify/build-deploy-preview.sh index b088f9d46f7..55047883a5c 100644 --- a/.netlify/build-deploy-preview.sh +++ b/.netlify/build-deploy-preview.sh @@ -13,9 +13,6 @@ node -v # should also symlink all projects appropriately yarn install --no-ignore-optional --pure-lockfile -dir -ls - # Build && Move PWA Output yarn run build:ci mkdir -p ./.netlify/www/pwa diff --git a/.netlify/publishStaticSite.sh b/.netlify/publishStaticSite.sh deleted file mode 100644 index cd5529882f9..00000000000 --- a/.netlify/publishStaticSite.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -# Set directory to location of this script -# https://stackoverflow.com/a/3355423/1867984 -cd "$(dirname "$0")" - -echo 'PUBLISHING' - -./node_modules/.bin/gh-pages \ - --silent \ - --repo https://$GITHUB_TOKEN@github.com/OHIF/Viewers.git \ - --message 'Autogenerated Message: [ci skip]' \ - --dist docs/latest/_book diff --git a/build-and-publish-docs.sh b/build-and-publish-docs.sh new file mode 100644 index 00000000000..66852b380b6 --- /dev/null +++ b/build-and-publish-docs.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +# Set directory to location of this script +# https://stackoverflow.com/a/3355423/1867984 +cd "$(dirname "$0")" + +yarn -v +node -v + +echo 'Installing Gitbook CLI' +yarn global add gitbook-cli + +echo 'Running Gitbook installation' + +# Generate all version's GitBook output +# For each directory in /docs ... +cd ./../docs/ +for D in *; do + if [ -d "${D}" ]; then + + echo "Generating output for: ${D}" + cd "${D}" + + # Clear previous output, generate new + rm -rf _book + gitbook install + gitbook build + + cd .. + + fi +done + +# Move CNAME File into `latest` +cp CNAME ./latest/_book/CNAME + +# Create a history folder in our latest version's output +mkdir ./latest/_book/history + +# Move each version's files to latest's history folder +for D in *; do + if [ -d "${D}" ]; then + if [ "${D}" == v* ] ; then + + echo "Moving ${D} to the latest version's history folder" + + mkdir "./latest/_book/history/${D}" + cp -v -r "./${D}/_book"/* "./latest/_book/history/${D}" + + fi + fi +done + +# Back to repo root +cd .. + +echo "Done generating documentation output" +echo 'PUBLISHING' + +./node_modules/.bin/gh-pages \ + --silent \ + --repo https://$GITHUB_TOKEN@github.com/OHIF/Viewers.git \ + --message 'Autogenerated Message: [ci skip]' \ + --dist docs/latest/_book diff --git a/package.json b/package.json index 846f84e15fe..1e8d858c3a6 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "test:unit:ci": "lerna run test:unit:ci --parallel --stream", "test:e2e:ci": "cd platform/viewer && yarn run test:e2e:ci", "see-changed": "lerna changed", + "docs:publish": "chmod +x ./build-and-publish-docs.sh && ./build-and-publish-docs.sh", "release": "yarn run lerna:version && yarn run lerna:publish", "lerna:version": "npx lerna version prerelease --force-publish", "lerna:publish": "lerna publish from-package --canary --dist-tag canary" diff --git a/yarn.lock b/yarn.lock index 9c047d5c5c5..90b01d98358 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3823,11 +3823,6 @@ balanced-match@^1.0.0: resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c= -base64-js@1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.2.1.tgz#a91947da1f4a516ea38e5b4ec0ec3773675e0886" - integrity sha512-dwVUVIXsBZXwTuwnXI9RK8sBmgq09NDHzyR9SAph9eqk76gKK2JSQmZARC2zRC81JC2QTtxD0ARU5qTS25gIGw== - base64-js@^1.0.2: version "1.3.1" resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.3.1.tgz#58ece8cb75dd07e71ed08c736abc5fac4dbf8df1" @@ -5899,6 +5894,16 @@ dcmjs@^0.4.7: loglevelnext "^3.0.0" ndarray "^1.0.18" +dcmjs@^0.5.1: + version "0.5.1" + resolved "https://registry.yarnpkg.com/dcmjs/-/dcmjs-0.5.1.tgz#9c069081213b9946196b8faf83b79602db2e7582" + integrity sha512-r6/S4tHqhPqsuwbuFmxpah31IeJPKtEOEm2Uf+FW3P68a9V4liVZzKmF7QzoI8sZWgBxmmwdtVr47JC1jHldJw== + dependencies: + "@babel/polyfill" "^7.2.5" + "@babel/runtime" "^7.3.1" + loglevelnext "^3.0.0" + ndarray "^1.0.18" + debug@*, debug@4.1.1, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/debug/-/debug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791" @@ -14906,10 +14911,10 @@ react-transition-group@^4.1.1: loose-envify "^1.4.0" prop-types "^15.6.2" -react-vtkjs-viewport@0.0.9: - version "0.0.9" - resolved "https://registry.yarnpkg.com/react-vtkjs-viewport/-/react-vtkjs-viewport-0.0.9.tgz#da79aa66f52dcd731bcc5abd2587cbb120a25331" - integrity sha512-VwRCY2DPxWMhix4v3PAtdENp3U1p+Z9nKf1Ch5+KWRKF6fWeA+B2glYKMYNpPnP4bULzVz9iwV+Zeojt3gEibA== +react-vtkjs-viewport@0.0.11: + version "0.0.11" + resolved "https://registry.yarnpkg.com/react-vtkjs-viewport/-/react-vtkjs-viewport-0.0.11.tgz#cedd993ca226502bf0417a3748a5b2f806522519" + integrity sha512-ttWw7bU/lL/nJuaaKdtAc8448vMJmlRQzpkpuP/J+3lTzIQbQPCPU40LqgONjr7LvL5++61N2GJ8m+PRgHyfxQ== dependencies: moment "^2.24.0" @@ -18291,12 +18296,11 @@ void-elements@^2.0.1: resolved "https://registry.yarnpkg.com/void-elements/-/void-elements-2.0.1.tgz#c066afb582bb1cb4128d60ea92392e94d5e9dbec" integrity sha1-wGavtYK7HLQSjWDqkjkulNXp2+w= -vtk.js@^8.11.0: - version "8.14.0" - resolved "https://registry.yarnpkg.com/vtk.js/-/vtk.js-8.14.0.tgz#c3be94c846a732a6f3e812a8a45a5dd3105939f2" - integrity sha512-/marh1LOJSxPYOc2j+GxiWUJt5EyFh9L2H+92vcgSn+AQ/FuaU7ovA2Q9BD0Sr2PJuIA7LlgxA6xOQzKHTJ1Yw== +vtk.js@^9.5.0: + version "9.7.0" + resolved "https://registry.yarnpkg.com/vtk.js/-/vtk.js-9.7.0.tgz#763767607a958fba5c70754434612f3066bd96a0" + integrity sha512-4IJJr2slOY+W/GjUdjElg3ViJSt6IF+siIJ4FmqOYQeOdTKRVxVYb7dAYVOH3MyVz8Zs39DEwJHHhRK5hkjsjg== dependencies: - base64-js "1.2.1" blueimp-md5 "2.10.0" commander "2.11.0" gl-matrix "3.0.0"