From 43df299096f02cfee21cbe7f011d5fc1619ee670 Mon Sep 17 00:00:00 2001 From: Eugenio Romano Date: Thu, 29 Aug 2019 12:01:49 +0100 Subject: [PATCH] release update commands pipeline --- .travis.yml | 41 +++-- appveyor.yml | 63 -------- lib/cli/README.md | 21 --- scripts/lint.sh | 3 + scripts/misc/config/config-verdaccio.yaml | 26 ---- scripts/misc/simulate-publish.sh | 23 --- scripts/npm-build-all.sh | 100 +----------- scripts/npm-publish.sh | 182 ---------------------- scripts/remove-alfresco-dependencies.sh | 9 -- scripts/travis/build/build.sh | 16 +- scripts/travis/deploy/deploy.sh | 6 - scripts/travis/release/release.sh | 5 - 12 files changed, 39 insertions(+), 456 deletions(-) delete mode 100644 appveyor.yml delete mode 100644 scripts/misc/config/config-verdaccio.yaml delete mode 100755 scripts/misc/simulate-publish.sh delete mode 100755 scripts/npm-publish.sh delete mode 100755 scripts/remove-alfresco-dependencies.sh diff --git a/.travis.yml b/.travis.yml index 54f2e42846..628e8813e4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,10 +33,9 @@ stages: - name: Check bundle if: type = push - name: e2e Test - - name: Deploy PR + - name: Update Rancher PR if: type = pull_request - addons: chrome: stable before_script: @@ -58,6 +57,8 @@ jobs: - stage: Lint & Build Dist name: Lint script: ./scripts/lint.sh || exit 1; + + - stage: Unit test name: Unit test content script: ./scripts/travis/unit-test/content.sh @@ -67,45 +68,48 @@ jobs: - stage: Unit test name: Unit test process process-cloud insights script: ./scripts/travis/unit-test/process.sh - - stage: Deploy PR - name: Deploy PR - script: - ./scripts/travis/deploy/deploy.sh + + - stage: Update children projects dependency #Update children projects dependency name: Update Related Project if: tag =~ .*beta.* script: ./scripts/travis/update/update-children.sh + + - stage: e2e Test name: core script: ./scripts/travis/e2e/core-e2e.sh - stage: e2e Test name: content - script: - ./scripts/travis/e2e/content-services-e2e.sh + script: ./scripts/travis/e2e/content-services-e2e.sh - stage: e2e Test name: search - script: - ./scripts/travis/e2e/search-e2e.sh + script: ./scripts/travis/e2e/search-e2e.sh - stage: e2e Test name: process - script: - ./scripts/travis/e2e/process-services-e2e.sh + script: ./scripts/travis/e2e/process-services-e2e.sh - stage: e2e Test name: process Cloud - script: - ./scripts/travis/e2e/process-services-cloud-e2e.sh + script: ./scripts/travis/e2e/process-services-cloud-e2e.sh + + - stage: Release on npm - script: - ./scripts/travis/release/release.sh + script: ./scripts/travis/release/release.sh + + - stage: Check bundle script: - ADF_VERSION=$(npm view @alfresco/adf-core@${TAG_NPM} version) - ./scripts/npm-check-bundles.sh -v ${ADF_VERSION} + + - stage: Deploy docker script: - TAG_VERSION=$(./scripts/travis/deploy/tag-travis-branch.sh) - echo "Running the docker with tag" $TAG_VERSION - ./lib/dist/cli/bin/adf-cli docker-publish --loginCheck --loginUsername "$DOCKER_REPOSITORY_USER" --loginPassword "$DOCKER_REPOSITORY_PASSWORD" --loginRepo "$DOCKER_REPOSITORY_DOMAIN" --dockerRepo "$DOCKER_REPOSITORY" --dockerTags "$TAG_VERSION" --pathProject "$(pwd)" + + - stage: Update Rancher script: - TAG_VERSION=$(./scripts/travis/deploy/tag-travis-branch.sh) @@ -113,6 +117,11 @@ jobs: - ./scripts/rancher-update.sh --access_key $RANCHER_TOKEN --secret_key $RANCHER_SECRET --url $REPO_RANCHER --environment_name $REPO_RANCHER_ADF_NAME --image docker:$DOCKER_REPOSITORY:$TAG_VERSION + - stage: Update Rancher PR + name: Update Rancher PR + script: ./scripts/travis/deploy/deploy.sh + + before_deploy: # Set up git user name and tag this commit - git config --local user.name "Alfresco" diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 47b1aeeea9..0000000000 --- a/appveyor.yml +++ /dev/null @@ -1,63 +0,0 @@ -# Test against this version of Node.js -branches: - only: - - master - - development - - dev-build-test - -environment: - nodejs_version: "8" - - matrix: - - COMPONENT_NAME: process-service - - COMPONENT_NAME: content-service - - COMPONENT_NAME: core - - COMPONENT_NAME: insights -# - COMPONENT_NAME: ng2-demo-shell - -# Install scripts. (runs after repo cloning) -install: - # Get the latest stable version of Node.js or io.js - - ps: Install-Product node $env:nodejs_version - # install module - - if %COMPONENT_NAME% EQU process-service ( - if %APPVEYOR_REPO_BRANCH EQU master - (cd scripts && sh npm-build-all.sh -t "process-services" || exit 1) - else - (cd scripts && sh npm-build-all.sh -t "process-services" -vjsapi alpha|| exit 1) - ) - - if %COMPONENT_NAME% EQU content-service ( - if %APPVEYOR_REPO_BRANCH EQU master - (cd scripts && sh npm-build-all.sh -t "content-services" || exit 1) - else - (cd scripts && sh npm-build-all.sh -t "content-services" -vjsapi alpha|| exit 1) - ) - - if %COMPONENT_NAME% EQU insights ( - if %APPVEYOR_REPO_BRANCH EQU master - (cd scripts && sh npm-build-all.sh -t "insights" || exit 1) - else - (cd scripts && sh npm-build-all.sh -t "insights" -vjsapi alpha|| exit 1) - ) - - if %COMPONENT_NAME% EQU core ( - if %APPVEYOR_REPO_BRANCH EQU master - (cd scripts && sh npm-build-all.sh -t "core" || exit 1) - else - (cd scripts && sh npm-build-all.sh -t "core" -vjsapi alpha|| exit 1) - ) - - if %COMPONENT_NAME% EQU process-service-cloud ( - if %APPVEYOR_REPO_BRANCH EQU master - (cd scripts && sh npm-build-all.sh -t "process-services-cloud" || exit 1) - else - (cd scripts && sh npm-build-all.sh -t "process-services-cloud" -vjsapi alpha|| exit 1) - ) -# - if %COMPONENT_NAME% EQU ng2-demo-shell ( -# if %APPVEYOR_REPO_BRANCH EQU master -# (cd scripts && sh start.sh -t -ss || exit 1) -# else -# (cd scripts && sh start.sh -dev -t -ss -vjsapi alpha || exit 1) -# ) - -# Don't actually build. -build: off -matrix: - fast_finish: true diff --git a/lib/cli/README.md b/lib/cli/README.md index 1bf46affb9..aba09e0637 100644 --- a/lib/cli/README.md +++ b/lib/cli/README.md @@ -114,24 +114,3 @@ Run command locally ```bash adf-cli update-commit-sha --pathProject "$(pwd)" --skipGnu ``` - -### npm publish - -This command allows you to publish your lib on the npm. - -```bash -adf-cli npm-publish --pathProject "$(pwd)" -``` - -You can use the option --npmRegistry "localhost:4873" to chose a different registry and --tokenRegistry "VALID_TOKEN" to pass the token. - -```bash -adf-cli update-commit-sha --npmRegistry "localhost:4873" --tokenRegistry "VALID_TOKEN" --pathProject "$(pwd)" -``` - -In case you want to add a tag you can use the option --tag "alpha|beta|latest" . - -```bash -adf-cli update-commit-sha --tag "beta" --pathProject "$(pwd)" -``` - diff --git a/scripts/lint.sh b/scripts/lint.sh index 6ffff11297..709d0ac384 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -18,3 +18,6 @@ if grep "envalfresco" . -R --exclude-dir={node_modules,.history,.idea,scripts,di echo not permitted word exit 1 fi + +echo "====== License Check =====" +npm run license-checker || exit 1 diff --git a/scripts/misc/config/config-verdaccio.yaml b/scripts/misc/config/config-verdaccio.yaml deleted file mode 100644 index 77a72472dc..0000000000 --- a/scripts/misc/config/config-verdaccio.yaml +++ /dev/null @@ -1,26 +0,0 @@ -storage: ./.verdaccio_test_env/test-storage - -uplinks: - npmjs: - url: https://registry.npmjs.org/ - -auth: - auth-memory: - users: - test: - name: test - password: test - -logs: - - {type: stdout, format: pretty, level: trace} - -packages: - '@*/*': - # scoped packages - access: $all - publish: $anonymous - proxy: npmjs - '**': - access: $all - publish: $anonymous - proxy: npmjs diff --git a/scripts/misc/simulate-publish.sh b/scripts/misc/simulate-publish.sh deleted file mode 100755 index 070d62c64b..0000000000 --- a/scripts/misc/simulate-publish.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env bash - -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - -npm set registry https://registry.npmjs.org/ - -echo "====== Install verdaccio ===== " - -npm install -g verdaccio -npm install -g concurrently -npm install -g verdaccio-auth-memory - -echo "====== Update version ===== " - -$DIR/update-version.sh -nextbeta -components - -echo "====== Change registry ===== " - -npm set registry http://localhost:4873/ - -echo "====== Run verdaccio ===== " - -concurrently "verdaccio --listen 4873 --config $DIR/config/config-verdaccio.yaml" "$DIR/npm-publish.sh --sleep 20 -f" diff --git a/scripts/npm-build-all.sh b/scripts/npm-build-all.sh index d86b543729..f7274733c1 100755 --- a/scripts/npm-build-all.sh +++ b/scripts/npm-build-all.sh @@ -2,15 +2,8 @@ set -f DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -eval RUN_TEST=false -eval RUN_TESTBROWSER=false -eval EXEC_CLEAN=false -eval EXEC_BUILD=true -eval EXEC_INSTALL=true -eval EXEC_SINGLE_TEST=false eval EXEC_GIT_NPM_INSTALL_JSAPI=false eval GIT_ISH="" -eval SINGLE_TEST="" eval EXEC_VERSION_JSAPI=false eval JSAPI_VERSION="" @@ -25,45 +18,10 @@ eval projects=( "core" show_help() { echo "Usage: npm-build-all.sh" echo "" - echo "-t or --test Build your local components and run their tests, this parameter also accept a wildecard to execute test e.g: -t "core"." - echo "-d or --debug Build your local components and run their tests IN THE BROWSER, this parameter also accept a wildecard to execute test e.g: -t "core"." - echo "-c or --clean Clean the node_modules before starting the build." - echo "-si or --skipinstall Skip the install of node_modules before starting the build." - echo "-sb or --skipbuild Skip the build of ng-components." echo "-gitjsapi Build all the components against a commit-ish version of the JS-API" echo "-vjsapi Install different version from npm of JS-API defined in the package.json" } -enable_test(){ - if [[ ! -z $1 ]]; then - if [[ $1 != "-"* ]]; then - EXEC_SINGLE_TEST=true - SINGLE_TEST=$1 - fi - fi - RUN_TEST=true -} - -enable_testbrowser(){ - if [[ ! -z $1 ]]; then - if [[ $1 != "-"* ]]; then - EXEC_SINGLE_TEST=true - SINGLE_TEST=$1 - fi - fi - RUN_TESTBROWSER=true -} - -test_project() { - echo "====== test project: $1 =====" - ng test $1 --watch=false || exit 1 -} - -debug_project() { - echo "====== debug project: $1 =====" - ng test $1 || exit 1 -} - enable_js_api_git_link() { GIT_ISH='git://github.com/Alfresco/alfresco-js-api.git#'$1 EXEC_GIT_NPM_INSTALL_JSAPI=true @@ -81,14 +39,6 @@ version_js_api() { EXEC_VERSION_JSAPI=true } -clean() { - EXEC_CLEAN=true -} - -exclude_build(){ - EXEC_BUILD=false -} - exec_install(){ EXEC_INSTALL=false } @@ -96,35 +46,14 @@ exec_install(){ while [[ $1 == -* ]]; do case "$1" in -h|--help|-\?) show_help; exit 0;; - -t|--test) enable_test $2; - shift; - if $EXEC_SINGLE_TEST == true; then - shift; - fi - ;; - -d|--debug) enable_testbrowser $2; shift; if $EXEC_SINGLE_TEST == true; then shift; fi ;; -gitjsapi) enable_js_api_git_link $2; shift 2;; -vjsapi) version_js_api $2; shift 2;; - -c|--clean) clean; shift;; - -si|--skipinstall) exec_install; shift;; - -sb|--skipbuild) exclude_build; shift;; -*) echo "invalid option: $1" 1>&2; show_help; exit 1;; esac done cd "$DIR/../" -if $EXEC_CLEAN == true; then - echo "====== Clean components =====" - npm install rimraf -g - npm run clean -fi - -if $EXEC_INSTALL == true; then - echo "====== Install components dependencies =====" - npm install -fi - if $EXEC_GIT_NPM_INSTALL_JSAPI == true; then echo "====== Use the alfresco JS-API '$GIT_ISH'=====" npm install $GIT_ISH --no-save @@ -138,30 +67,5 @@ if $EXEC_VERSION_JSAPI == true; then npm install alfresco-js-api@${JSAPI_VERSION} --no-save fi -if $EXEC_BUILD == true; then - echo "====== Build components =====" - npm run build-lib || exit 1 -fi - -if $RUN_TEST == true; then - if $EXEC_SINGLE_TEST == true; then - test_project $SINGLE_TEST - else - for PACKAGE in ${projects[@]} - do - test_project $PACKAGE - done - fi -fi - -if $RUN_TESTBROWSER == true; then - if $EXEC_SINGLE_TEST == true; then - debug_project $SINGLE_TEST - else - for PACKAGE in ${projects[@]} - do - debug_project $PACKAGE - done - fi -fi - +echo "====== Build components =====" +npm run build-lib || exit 1 diff --git a/scripts/npm-publish.sh b/scripts/npm-publish.sh deleted file mode 100755 index 6b9f244e48..0000000000 --- a/scripts/npm-publish.sh +++ /dev/null @@ -1,182 +0,0 @@ -#!/usr/bin/env bash -set -e - -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - -eval FORCE_PUBLISH=false -eval EXEC_CHANGE_REGISTRY=false -eval NPM_REGISTRY=false -eval TOKEN_REGISTRY="" -eval OPTIONS="" -eval EXEC_GIT_NPM_INSTALL_JSAPI=false -eval GIT_ISH="" -eval EXEC_SLEEP=false -eval SLEEP_TIME="0" -eval EXEC_VERSION_JSAPI=false -eval JSAPI_VERSION="" -eval EXEC_BUILD=true - -eval projects=( - "cli" - "core" - "insights" - "testing" - "content-services" - "process-services" - "process-services-cloud" - "extensions" ) - -cd "$DIR/../" - -show_help() { - echo "Usage: npm-publish.sh" - echo "" - echo "-f or --force publish the package with force" - echo "-r or --registry to publish in an alternative npm registry -registry 'http://npm.local.me:8080/' " - echo "-token auth token for publish in the npm registry" - echo "-t or --tag to add a tag when publish a package" - echo "-sb skip build" - echo "--sleep add a sleep before any publish" - echo "-gitjsapi to build all the components against a commit-ish version of the JS-API" - echo "-vjsapi Install different version from npm of JS-API defined in the package.json" -} - -enable_force(){ - OPTIONS="$OPTIONS -force" -} - -enable_change_registry(){ - NPM_REGISTRY=$1 - EXEC_CHANGE_REGISTRY=true -} - -set_sleep(){ - SLEEP_TIME=$1 - EXEC_SLEEP=true -} - -skip_build(){ - EXEC_BUILD=false -} - -get_token_registry(){ - TOKEN_REGISTRY=$1 - - if [[ "${TOKEN_REGISTRY}" == "" ]] - then - echo "token missing -token" - exit 0 - fi -} - -enable_js_api_git_link() { - GIT_ISH='git://github.com/Alfresco/alfresco-js-api.git#'$1 - EXEC_GIT_NPM_INSTALL_JSAPI=true -} - -add_tag(){ - eval TAG=$1 - - if [[ "${TAG}" == "" ]] - then - echo "tag missing -t | -tag" - exit 0 - fi - - echo "====== TAG WILL BE ADDED DURING THE PUBLISH: ${TAG} =====" - OPTIONS="$OPTIONS --tag $1" -} - -version_js_api() { - JSAPI_VERSION=$1 - - if [[ "${JSAPI_VERSION}" == "" ]] - then - echo "JSAPI version required with -vJSApi" - exit 0 - fi - - EXEC_VERSION_JSAPI=true -} - -change_registry(){ - if [[ "${NPM_REGISTRY}" == "" ]] - then - echo "NPM registry required WITH OPTION -r | -registry" - exit 0 - fi - - echo "====== CHANGE REGISTRY: ${NPM_REGISTRY} =====" - touch .npmrc - echo 'strict-ssl=false' >> .npmrc - echo 'registry=http://'${NPM_REGISTRY} >> .npmrc - echo '//'${NPM_REGISTRY}'/:_authToken="'${TOKEN_REGISTRY}'"' >> .npmrc -} - -while [[ $1 == -* ]]; do - case "$1" in - -h|--help|-\?) show_help; exit 0;; - -t|--tag) add_tag $2; shift 2;; - -f|--force) enable_force; shift;; - -token) get_token_registry $2; shift 2;; - --sleep) set_sleep $2; shift 2;; - -sb) skip_build; shift;; - -r|--registry) enable_change_registry $2; shift 2;; - -gitjsapi) enable_js_api_git_link $2; shift 2;; - -vjsapi) version_js_api $2; shift 2;; - -*) echo "invalid option: $1" 1>&2; show_help; exit 0;; - esac -done - -node ./scripts/pre-publish.js - -if $EXEC_BUILD == true; then -echo "====== INSTALL AND CLEAN ${PACKAGE} ===== " - npm install rimraf - npm run clean - npm install -fi - -if $EXEC_GIT_NPM_INSTALL_JSAPI == true; then - echo "====== Use the alfresco JS-API '$GIT_ISH'=====" - npm install $GIT_ISH - cd "${DESTDIR}/node_modules/alfresco-js-api" - npm install - cd ${DESTDIR} -fi - -if $EXEC_VERSION_JSAPI == true; then - echo "====== Use the alfresco JS-API '$JSAPI_VERSION'=====" - npm install alfresco-js-api@${JSAPI_VERSION} --no-save -fi - -if $EXEC_BUILD == true; then - echo "====== Build ADF ===== " - npm run build-lib -fi - -for PACKAGE in ${projects[@]} -do - - DESTDIR="$DIR/../lib/dist/${PACKAGE}" - echo "====== MOVE DIR: ${DESTDIR} ===== " - cd ${DESTDIR} - - if $EXEC_CHANGE_REGISTRY == true; then - change_registry - fi - - echo "====== PUBLISHING: ${DESTDIR} ===== npm publish ${OPTIONS}" - npm publish ${OPTIONS} --access=public || exit 1 - - if $EXEC_CHANGE_REGISTRY == true; then - rm .npmrc - fi - - if $EXEC_SLEEP == true; then - echo "====== SLEEP ${SLEEP_TIME}" - sleep ${SLEEP_TIME} - fi - - cd ${DIR} -done diff --git a/scripts/remove-alfresco-dependencies.sh b/scripts/remove-alfresco-dependencies.sh deleted file mode 100755 index 10184b1c1e..0000000000 --- a/scripts/remove-alfresco-dependencies.sh +++ /dev/null @@ -1,9 +0,0 @@ -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - -echo "====== Removing Alfresco dependencies from package.json =====" - -grep -wirn '@alfresco\/adf*' $DIR/../package.json -sed -i 's/"@alfresco\/adf-[^,]*,//' $DIR/../package.json -sed -i '/^[[:space:]]*$/d' $DIR/../package.json - -echo "====== Alfresco dependencies removed from package.json =====" diff --git a/scripts/travis/build/build.sh b/scripts/travis/build/build.sh index 7ce253bfe9..adc459b16d 100755 --- a/scripts/travis/build/build.sh +++ b/scripts/travis/build/build.sh @@ -6,26 +6,28 @@ cd $DIR/../../../ rm -rf tmp && mkdir tmp; -./scripts/update-version.sh -gnu -alpha || exit 1; if [[ $TRAVIS_PULL_REQUEST == "false" ]]; then if [[ $TRAVIS_BRANCH == "development" ]]; then - ./scripts/update-version.sh -gnu -alpha || exit 1; + #TODO remove when we are going to use the new about + ./scripts/update-version.sh -gnu -nextalpha || exit 1; fi + node ./scripts/pre-publish.js + + npm install + ./scripts/npm-build-all.sh || exit 1; else - ./scripts/update-version.sh -gnu -alpha || exit 1; + npm install @alfresco/adf-cli@alpha + ./node_modules/@alfresco/adf-cli/bin/adf-cli update-version --alpha --pathPackage "$(pwd)" + npm install; - ./scripts/lint.sh || exit 1; ./scripts/smart-build.sh -b $TRAVIS_BRANCH -gnu || exit 1; fi; echo "====== Build Demo shell dist =====" npm run build:dist || exit 1; - -echo "====== License Check =====" -npm run license-checker diff --git a/scripts/travis/deploy/deploy.sh b/scripts/travis/deploy/deploy.sh index 7dbea6186f..01bca64fba 100755 --- a/scripts/travis/deploy/deploy.sh +++ b/scripts/travis/deploy/deploy.sh @@ -4,12 +4,6 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $DIR/../../../ -#if [ "$TRAVIS_PULL_REQUEST" != "false" ]; -#then node ./scripts/travis/deploy/move-dist-folder.js --base-href $TRAVIS_BUILD_NUMBER && (./scripts/travis/deploy/pr-publish.sh -n $TRAVIS_BUILD_NUMBER -r $REPO_DOCKER -u $USERNAME_DOCKER -p $PASSWORD_DOCKER || exit 1); -#fi; -#if [ "$TRAVIS_PULL_REQUEST" != "false" ]; -#then (node --no-deprecation ./scripts/travis/deploy/pr-deploy.js -n $TRAVIS_BUILD_NUMBER -u $RANCHER_TOKEN -p $RANCHER_SECRET -s $REPO_RANCHER --image "docker:$REPO_DOCKER/adf/demo-shell:$TRAVIS_BUILD_NUMBER" --env $ENVIRONMENT_NAME -r $ENVIRONMENT_URL || exit 1); -#fi; diff --git a/scripts/travis/release/release.sh b/scripts/travis/release/release.sh index 74ba1b5795..28d478f9d9 100755 --- a/scripts/travis/release/release.sh +++ b/scripts/travis/release/release.sh @@ -4,9 +4,4 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $DIR/../../../ -if [[ $TRAVIS_BRANCH == "development" ]]; -then - ./scripts/update-version.sh -gnu -nextalpha || exit 1; -fi - ./lib/dist/cli/bin/adf-cli npm-publish --npmRegistry $NPM_REGISTRY_ADDRESS --tokenRegistry $NPM_REGISTRY_TOKEN --tag $TAG_NPM --pathProject "$(pwd)"