Travis cache (#3972)

* Use name instead of env

* Enable cache dist

* enable only master and dev

* rename e2e lib

* add nx and smart build

* disable packaging and create demo shell stages

* use same name

* Enable affected e2e for core and process

* Enable affected libs check on all the e2e

* fix e2e condition

* Enable unit tests

* Manage case deps not present

* add name typo

* add affected folder to check e2e

* change an e2e test

* remove branch typo

* Update .travis.yml
This commit is contained in:
Maurizio Vitale
2018-11-19 13:28:02 +00:00
committed by Eugenio Romano
parent 2fcec4f235
commit f0dff4d011
21 changed files with 864 additions and 204 deletions

1
.gitignore vendored
View File

@@ -4,6 +4,7 @@ bundles
workspace.xml workspace.xml
.idea/ .idea/
dist/ dist/
tmp
e2e-output/ e2e-output/
e2e/downloads/ e2e/downloads/
ng2-components/coverage/ ng2-components/coverage/

View File

@@ -5,6 +5,21 @@ node_js:
# Use the explicit NodeJS LTS version 8.9.4 to avoid any automatic upgrade of the version. # Use the explicit NodeJS LTS version 8.9.4 to avoid any automatic upgrade of the version.
- '8.9.4' - '8.9.4'
branches:
only:
- master
- development
stages:
- name: Warm Up Cache
if: branch = master
- name: Warm Up Cache & Lint & Build Dist
if: branch != master
- name: Unit test
- name: e2e Test
- name: Create Docker PR
- name: Deploy Docker PR
addons: addons:
chrome: stable chrome: stable
before_script: before_script:
@@ -25,42 +40,71 @@ branches:
jobs: jobs:
include: include:
- stage: Warm Up Cache - stage: Warm Up Cache
script: if ([ "$TRAVIS_BRANCH" = "master" ]); then
(./scripts/npm-build-all.sh || exit 1;);
else
(./scripts/update-version.sh -gnu -alpha && ././scripts/npm-build-all.sh -sb --skip-lint || exit 1;);
fi
- stage: Lint
script: script:
- ./scripts/lint.sh - ./scripts/npm-build-all.sh || exit 1
- npm run spellcheck - stage: Warm Up Cache & Lint & Build Dist
script:
- ./scripts/update-version.sh -gnu -alpha || exit 1
- npm install
- ./scripts/lint.sh || exit 1
- npm run spellcheck || exit 1
- rm -rf tmp && (./scripts/smart-build.sh || exit 1;);
- npm run build:dist || exit 1
- stage: Unit test - stage: Unit test
env: STAGE=core name: core
script: (./scripts/npm-build-all.sh -si -sb -t "core" --skip-lint || exit 1;); script:
AFFECTED_LIBS="$(./scripts/affected-libs.sh -b $TRAVIS_BRANCH)";
if [[ $AFFECTED_LIBS =~ "core$" ]];
then
ng test core --watch=false || exit 1;
fi
- stage: Unit test - stage: Unit test
env: STAGE=extensions name: extensions
script: (./scripts/npm-build-all.sh -si -sb -t "extensions" --skip-lint || exit 1;); script:
AFFECTED_LIBS="$(./scripts/affected-libs.sh -b $TRAVIS_BRANCH)";
if [[ $AFFECTED_LIBS =~ "extensions$" ]];
then
ng test extensions --watch=false || exit 1;
fi
- stage: Unit test - stage: Unit test
env: STAGE=process-services name: process-services
script: (./scripts/npm-build-all.sh -si -sb -t "process-services" --skip-lint|| exit 1;); script:
AFFECTED_LIBS="$(./scripts/affected-libs.sh -b $TRAVIS_BRANCH)";
if [[ $AFFECTED_LIBS =~ "process-services$" ]];
then
ng test process-services --watch=false || exit 1;
fi
- stage: Unit test - stage: Unit test
env: STAGE=insights name: insights
script: (./scripts/npm-build-all.sh -si -sb -t "insights" --skip-lint || exit 1;); script:
AFFECTED_LIBS="$(./scripts/affected-libs.sh -b $TRAVIS_BRANCH)";
if [[ $AFFECTED_LIBS =~ "insights$" ]];
then
ng test insights --watch=false || exit 1;
fi
- stage: Unit test - stage: Unit test
env: STAGE=content-services name: content-services
script: (./scripts/npm-build-all.sh -si -sb -t "content-services" --skip-lint|| exit 1;); script:
AFFECTED_LIBS="$(./scripts/affected-libs.sh -b $TRAVIS_BRANCH)";
if [[ $AFFECTED_LIBS =~ "content-services$" ]];
then
ng test content-services --watch=false || exit 1;
fi
- stage: Unit test - stage: Unit test
env: STAGE=process-services-cloud name: process-services-cloud
script: (./scripts/npm-build-all.sh -si -sb -t "process-services-cloud" --skip-lint|| exit 1;); script:
AFFECTED_LIBS="$(./scripts/affected-libs.sh -b $TRAVIS_BRANCH)";
if [[ $AFFECTED_LIBS =~ "process-services-cloud$" ]];
then
ng test process-services-cloud --watch=false || exit 1;
fi
- stage: Unit test - stage: Unit test
env: STAGE=demo-shell name: demo-shell
script: if ([ "$TRAVIS_BRANCH" = "master" ]); then script: if ([ "$TRAVIS_BRANCH" = "master" ]); then
(./scripts/start.sh -t -ss || exit 1;); (./scripts/start.sh -t -ss || exit 1;);
else else
(./scripts/start.sh -dev -t -ss -vjsapi alpha || exit 1;); (./scripts/start.sh -dev -t -ss -vjsapi alpha || exit 1;);
fi fi
- stage: Packaging test
script: (npm run build-lib || exit 1;) && node ./scripts/upload-build-lib-in-cs.js -u "$E2E_USERNAME" -p "$E2E_PASSWORD" --host "$E2E_HOST" -f $TRAVIS_BUILD_NUMBER
- stage: Update children projects dependency #Update generator-ng2-alfresco-app - stage: Update children projects dependency #Update generator-ng2-alfresco-app
if: tag =~ .*beta.* if: tag =~ .*beta.*
script: ./scripts/update-project.sh -gnu -t $GITHUB_TOKEN -n generator-ng2-alfresco-app script: ./scripts/update-project.sh -gnu -t $GITHUB_TOKEN -n generator-ng2-alfresco-app
@@ -76,59 +120,56 @@ jobs:
- stage: Update children projects dependency # Test Update alfresco-modeler-app - stage: Update children projects dependency # Test Update alfresco-modeler-app
if: tag =~ .*beta.* if: tag =~ .*beta.*
script: ./scripts/update-project.sh -gnu -t $GITHUB_TOKEN -n alfresco-modeler-app script: ./scripts/update-project.sh -gnu -t $GITHUB_TOKEN -n alfresco-modeler-app
- stage: Create Shell dist
script: rm -rf ./node_modules/@alfresco; node ./scripts/download-build-lib-in-cs.js -u "$E2E_USERNAME" -p "$E2E_PASSWORD" --host "$E2E_HOST" -f $TRAVIS_BUILD_NUMBER || exit 1; npm run build:dist || exit 1; node ./scripts/upload-build-in-cs.js -u "$E2E_USERNAME" -p "$E2E_PASSWORD" --host "$E2E_HOST" -f $TRAVIS_BUILD_NUMBER || exit 1
- stage: e2e Test # Test core - stage: e2e Test # Test core
env: STAGE=core name: core
script: node ./scripts/download-build-in-cs.js --username "$E2E_USERNAME" --password "$E2E_PASSWORD" --host "$E2E_HOST" --folder $TRAVIS_BUILD_NUMBER; ./scripts/test-e2e-lib.sh -host localhost:4200 --host_sso "$E2E_HOST_SSO" -proxy "$E2E_HOST" -u "$E2E_USERNAME" -p "$E2E_PASSWORD" -e $E2E_EMAIL -b -save --folder core --skip-lint --use-dist --timeout 7000 script:
AFFECTED_E2E="$(./scripts/affected-folder.sh -b $TRAVIS_BRANCH -f "e2e")";
AFFECTED_LIBS="$(./scripts/affected-libs.sh -b $TRAVIS_BRANCH)";
if [[ $AFFECTED_LIBS =~ "core$" || $AFFECTED_E2E = "e2e" ]];
then
(./scripts/test-e2e-lib.sh -host localhost:4200 --host_sso "$E2E_HOST_SSO" -proxy "$E2E_HOST" -u "$E2E_USERNAME" -p "$E2E_PASSWORD" -e $E2E_EMAIL -b -save --folder core --skip-lint --use-dist --timeout 7000 || exit 1;);
fi
- stage: e2e Test # Test process-services - stage: e2e Test # Test process-services
env: STAGE=process-services name: process-services
script: node ./scripts/download-build-in-cs.js --username "$E2E_USERNAME" --password "$E2E_PASSWORD" --host "$E2E_HOST" --folder $TRAVIS_BUILD_NUMBER; ./scripts/test-e2e-lib.sh -host localhost:4200 -proxy "$E2E_HOST" -u "$E2E_USERNAME" -p "$E2E_PASSWORD" -e $E2E_EMAIL -b -save --folder process-services --skip-lint --use-dist --timeout 7000 script:
AFFECTED_E2E="$(./scripts/affected-folder.sh -b $TRAVIS_BRANCH -f "e2e")";
AFFECTED_LIBS="$(./scripts/affected-libs.sh -b $TRAVIS_BRANCH)";
if [[ $AFFECTED_LIBS =~ "process-services$" || $AFFECTED_E2E = "e2e" ]];
then
(./scripts/test-e2e-lib.sh -host localhost:4200 -proxy "$E2E_HOST" -u "$E2E_USERNAME" -p "$E2E_PASSWORD" -e $E2E_EMAIL -b -save --folder process-services --skip-lint --use-dist --timeout 7000 || exit 1;);
fi
- stage: e2e Test # Test content-services - stage: e2e Test # Test content-services
env: STAGE=content-services name: content-services
script: node ./scripts/download-build-in-cs.js --username "$E2E_USERNAME" --password "$E2E_PASSWORD" --host "$E2E_HOST" --folder $TRAVIS_BUILD_NUMBER; ./scripts/test-e2e-lib.sh -host localhost:4200 -proxy "$E2E_HOST" -u "$E2E_USERNAME" -p "$E2E_PASSWORD" -e $E2E_EMAIL -b -save --folder content-services --skip-lint --use-dist --timeout 7000 script:
- stage: e2e Test # Test process-services AFFECTED_E2E="$(./scripts/affected-folder.sh -b $TRAVIS_BRANCH -f "e2e")";
env: STAGE=process-services-cloud AFFECTED_LIBS="$(./scripts/affected-libs.sh -b $TRAVIS_BRANCH)";
script: node ./scripts/download-build-in-cs.js --username "$E2E_USERNAME" --password "$E2E_PASSWORD" --host "$E2E_HOST" --folder $TRAVIS_BUILD_NUMBER; ./scripts/test-e2e-lib.sh -host localhost:4200 -proxy "$E2E_HOST" -u "$E2E_USERNAME" -p "$E2E_PASSWORD" -e $E2E_EMAIL -b -save --folder process-services-cloud --skip-lint --use-dist --timeout 7000 if [[ $AFFECTED_LIBS =~ "content-services$" || $AFFECTED_E2E = "e2e" ]];
then
(./scripts/test-e2e-lib.sh -host localhost:4200 -proxy "$E2E_HOST" -u "$E2E_USERNAME" -p "$E2E_PASSWORD" -e $E2E_EMAIL -b -save --folder content-services --skip-lint --use-dist --timeout 7000 || exit 1;);
fi
- stage: e2e Test # Test process-services-cloud
name: process-services-cloud
script:
AFFECTED_E2E="$(./scripts/affected-folder.sh -b $TRAVIS_BRANCH -f "e2e")";
AFFECTED_LIBS="$(./scripts/affected-libs.sh -b $TRAVIS_BRANCH)";
if [[ $AFFECTED_LIBS =~ "process-services-cloud$" || $AFFECTED_E2E = "e2e" ]];
then
(./scripts/test-e2e-lib.sh -host localhost:4200 -proxy "$E2E_HOST" -u "$E2E_USERNAME" -p "$E2E_PASSWORD" -e $E2E_EMAIL -b -save --folder process-services-cloud --skip-lint --use-dist --timeout 7000 || exit 1;);
fi
- stage: e2e Test # Test insights - stage: e2e Test # Test insights
env: STAGE=insights name: insights
script: node ./scripts/download-build-in-cs.js --username "$E2E_USERNAME" --password "$E2E_PASSWORD" --host "$E2E_HOST" --folder $TRAVIS_BUILD_NUMBER; ./scripts/test-e2e-lib.sh -host localhost:4200 -proxy "$E2E_HOST" -u "$E2E_USERNAME" -p "$E2E_PASSWORD" -e $E2E_EMAIL -b -save --folder insights --skip-lint --use-dist --timeout 7000 script:
# - stage: Test Update version 2.0.0 AFFECTED_E2E="$(./scripts/affected-folder.sh -b $TRAVIS_BRANCH -f "e2e")";
# if: branch = development AFFECTED_LIBS="$(./scripts/affected-libs.sh -b $TRAVIS_BRANCH)";
# env: STAGE=test-BC if [[ $AFFECTED_LIBS =~ "process-services-cloud$" || $AFFECTED_E2E = "e2e" ]];
# script: ./scripts/test-e2e-bc.sh -b $TRAVIS_BUILD_NUMBER then
# - stage: Test Update version 2.0.0 (./scripts/test-e2e-lib.sh -host localhost:4200 -proxy "$E2E_HOST" -u "$E2E_USERNAME" -p "$E2E_PASSWORD" -e $E2E_EMAIL -b -save --folder insights --skip-lint --use-dist --timeout 7000 || exit 1;);
# env: STAGE=test-export fi
# script: npm run test-export
- stage: Create Docker PR - stage: Create Docker PR
script: node ./scripts/download-build-in-cs.js --username "$E2E_USERNAME" --password "$E2E_PASSWORD" --host "$E2E_HOST" --folder $TRAVIS_BUILD_NUMBER --base-href $TRAVIS_BUILD_NUMBER && (./scripts/pr-publish.sh -n $TRAVIS_BUILD_NUMBER -r $REPO_DOCKER -u $USERNAME_DOCKER -p $PASSWORD_DOCKER || exit 1) script: (./scripts/pr-publish.sh -n $TRAVIS_BUILD_NUMBER -r $REPO_DOCKER -u $USERNAME_DOCKER -p $PASSWORD_DOCKER || exit 1)
- stage: Deploy Docker PR - stage: Deploy Docker PR
script: node --no-deprecation ./scripts/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 script: node --no-deprecation ./scripts/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
# jobs:
# include:
# - stage: Publish alpha to NPM
# before_install: skip
# install: skip
# script: skip
# deploy:
# provider: script
# script: (./scripts/update-version.sh -v $(./scripts/next_version.sh)-$(git rev-parse HEAD) -vj $(npm view alfresco-js-api@alpha version) -gnu) && (./scripts/npm-publish.sh -r $NPM_REGISTRY_ADDRESS -token $NPM_REGISTRY_TOKEN -t alpha --sleep 20 || exit 1;);
# on:
# branch: development
# skip_cleanup: true
# - stage: Publish beta to NPM
# before_install: skip
# install: skip
# script: skip
# deploy:
# provider: script
# script: (./scripts/update-version.sh -v $TRAVIS_TAG -gnu) && (./scripts/npm-publish.sh -r $NPM_REGISTRY_ADDRESS -token $NPM_REGISTRY_TOKEN -t beta --sleep 20 || exit 1;);
# on:
# tags: true
# skip_cleanup: true
# Send coverage data to codecov # Send coverage data to codecov
after_success: after_success:
bash <(curl -s https://codecov.io/bash) -X gcov bash <(curl -s https://codecov.io/bash) -X gcov
@@ -137,3 +178,5 @@ after_success:
cache: cache:
directories: directories:
- node_modules - node_modules
- demo-shell/dist
- tmp

View File

@@ -495,7 +495,7 @@
} }
} }
}, },
"lib-e2e": { "lib-e2e-test": {
"root": "demo-shell", "root": "demo-shell",
"sourceRoot": "./demo-shell", "sourceRoot": "./demo-shell",
"projectType": "application", "projectType": "application",
@@ -517,7 +517,7 @@
"builder": "@angular-devkit/build-angular:protractor", "builder": "@angular-devkit/build-angular:protractor",
"options": { "options": {
"protractorConfig": "./protractor.conf.js", "protractorConfig": "./protractor.conf.js",
"devServerTarget": "lib-e2e:serve" "devServerTarget": "lib-e2e-test:serve"
} }
}, },
"lint": { "lint": {

View File

@@ -44,7 +44,7 @@ describe('Error Component', () => {
}); });
it('[C277302] Should display the error 403 when access to unauthorized page', () => { it('[C277302] Should display the error 403 when access to unauthorized page - My Change', () => {
browser.get(TestConfig.adf.url + '/error/403'); browser.get(TestConfig.adf.url + '/error/403');
expect(errorPage.getErrorCode()).toBe('403'); expect(errorPage.getErrorCode()).toBe('403');
expect(errorPage.getErrorTitle()).toBe('You don\'t have permission to access this server.'); expect(errorPage.getErrorTitle()).toBe('You don\'t have permission to access this server.');

View File

@@ -0,0 +1,6 @@
var Bundler = require('scss-bundle').Bundler;
var writeFileSync = require('fs-extra').writeFileSync;
new Bundler().Bundle('./lib/content-services/styles/_index.scss', '**/*.scss').then(result => {
writeFileSync('./lib/dist/content-services/_theming.scss', result.bundledContent);
});

View File

@@ -0,0 +1,6 @@
var Bundler = require('scss-bundle').Bundler;
var writeFileSync = require('fs-extra').writeFileSync;
new Bundler().Bundle('./lib/core/styles/_index.scss', '**/*.scss').then(result => {
writeFileSync('./lib/dist/core/_theming.scss', result.bundledContent);
});

View File

@@ -0,0 +1,6 @@
var Bundler = require('scss-bundle').Bundler;
var writeFileSync = require('fs-extra').writeFileSync;
new Bundler().Bundle('./lib/insights/styles/_index.scss', '**/*.scss').then(result => {
writeFileSync('./lib/dist/insights/_theming.scss', result.bundledContent);
});

View File

@@ -0,0 +1,7 @@
var Bundler = require('scss-bundle').Bundler;
var writeFileSync = require('fs-extra').writeFileSync;
var mkdirpSync = require('fs-extra').mkdirpSync;
new Bundler().Bundle('./lib/process-services-cloud/src/lib/styles/_index.scss', '**/*.scss').then(result => {
writeFileSync('./lib/dist/process-services-cloud/_theming.scss', result.bundledContent);
});

View File

@@ -0,0 +1,6 @@
var Bundler = require('scss-bundle').Bundler;
var writeFileSync = require('fs-extra').writeFileSync;
new Bundler().Bundle('./lib/process-services/styles/_index.scss', '**/*.scss').then(result => {
writeFileSync('./lib/dist/process-services/_theming.scss', result.bundledContent);
});

39
nx.json Normal file
View File

@@ -0,0 +1,39 @@
{
"npmScope": "my-company",
"implicitDependencies": {
"angular.json": "*",
"package.json": "*",
"tsconfig.json": "*",
"tslint.json": "*",
"nx.json": "*"
},
"projects": {
"dev": {
"tags": []
},
"dist": {
"tags": []
},
"core": {
"tags": []
},
"content-services": {
"tags": []
},
"process-services": {
"tags": []
},
"process-services-cloud": {
"tags": []
},
"insights": {
"tags": []
},
"lib-e2e-test": {
"tags": []
},
"extensions": {
"tags": []
}
}
}

459
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -14,6 +14,7 @@
"lint-e2e": "./node_modules/.bin/tslint -p ./e2e/tsconfig.e2e.json -c ./tslint.json", "lint-e2e": "./node_modules/.bin/tslint -p ./e2e/tsconfig.e2e.json -c ./tslint.json",
"test-export": "ts-node ./tools/export-check/exportCheck.ts ./lib/core/public-api.ts ./lib/process-services/public-api.ts ./lib/content-services/public-api.ts ./lib/insights/public-api.ts ./lib/process-services-cloud/public-api.ts", "test-export": "ts-node ./tools/export-check/exportCheck.ts ./lib/core/public-api.ts ./lib/process-services/public-api.ts ./lib/content-services/public-api.ts ./lib/insights/public-api.ts ./lib/process-services-cloud/public-api.ts",
"ng": "ng", "ng": "ng",
"affected:libs": "./node_modules/.bin/nx affected:libs",
"validate-config": "ajv validate -s ./lib/core/app-config/schema.json -d ./demo-shell/src/app.config.json --errors=text --verbose", "validate-config": "ajv validate -s ./lib/core/app-config/schema.json -d ./demo-shell/src/app.config.json --errors=text --verbose",
"start": "ng lint dist && npm run validate-config && npm run server-versions && ng serve dist --host 0.0.0.0 --proxy-config ./demo-shell/proxy.conf.js --open", "start": "ng lint dist && npm run validate-config && npm run server-versions && ng serve dist --host 0.0.0.0 --proxy-config ./demo-shell/proxy.conf.js --open",
"start:dev": "ng lint dev && npm run validate-config && npm run server-versions && concurrently \"ng serve dev --host 0.0.0.0 --disable-host-check --proxy-config ./demo-shell/proxy.conf.js --open\" \"npm run style:dev --watch\" ", "start:dev": "ng lint dev && npm run validate-config && npm run server-versions && concurrently \"ng serve dev --host 0.0.0.0 --disable-host-check --proxy-config ./demo-shell/proxy.conf.js --open\" \"npm run style:dev --watch\" ",
@@ -25,7 +26,7 @@
"webpack-bundle-analyzer": "webpack-bundle-analyzer demo-shell/dist/stats.json", "webpack-bundle-analyzer": "webpack-bundle-analyzer demo-shell/dist/stats.json",
"test": "npm run validate-config && ng test dev --watch=false", "test": "npm run validate-config && ng test dev --watch=false",
"e2e": "./scripts/test-e2e-lib.sh -host 'localhost:4200' -dev --folder demo-shell", "e2e": "./scripts/test-e2e-lib.sh -host 'localhost:4200' -dev --folder demo-shell",
"e2e-lib": "ng e2e lib-e2e --port=4200", "e2e-lib": "ng e2e lib-e2e-test --port=4200",
"server-versions": "rimraf ./demo-shell/src/versions.json && npm list --depth=0 --json=true --prod=true > ./demo-shell/src/versions.json || exit 0", "server-versions": "rimraf ./demo-shell/src/versions.json && npm list --depth=0 --json=true --prod=true > ./demo-shell/src/versions.json || exit 0",
"clean": "rimraf dist ./node_modules typings", "clean": "rimraf dist ./node_modules typings",
"clean-lock": "rimraf package-lock.json", "clean-lock": "rimraf package-lock.json",
@@ -81,6 +82,8 @@
"adf-tslint-rules": "0.0.4", "adf-tslint-rules": "0.0.4",
"alfresco-js-api": "2.7.0-beta5", "alfresco-js-api": "2.7.0-beta5",
"alfresco-js-api-node": "2.7.0-beta5", "alfresco-js-api-node": "2.7.0-beta5",
"@nrwl/schematics": "6.3.1",
"@nrwl/nx": "6.3.1",
"chart.js": "2.5.0", "chart.js": "2.5.0",
"classlist.js": "1.1.20150312", "classlist.js": "1.1.20150312",
"core-js": "^2.5.4", "core-js": "^2.5.4",

49
scripts/affected-folder.sh Executable file
View File

@@ -0,0 +1,49 @@
#!/usr/bin/env bash
eval BRANCH_NAME=""
eval HEAD_SHA_BRANCH=""
eval SHA_2="HEAD"
show_help() {
echo "Usage: affected-folder.sh"
echo ""
echo "-b branch name"
echo "-folder"
}
branch_name(){
BRANCH_NAME=$1
}
folder_name(){
FOLDER_NAME=$1
}
while [[ $1 == -* ]]; do
case "$1" in
-b) branch_name $2; shift 2;;
-f) folder_name $2; shift 2;;
-*) echo "invalid option: $1" 1>&2; show_help; exit 0;;
esac
done
if [[ "$BRANCH_NAME" == "" ]]
then
echo "The branch name is mandatory"
exit 0
fi
if [[ "$FOLDER_NAME" == "" ]]
then
echo "The folder name is mandatory"
exit 0
fi
HEAD_SHA_BRANCH="$(git merge-base origin/$BRANCH_NAME HEAD)"
#echo "Branch name $BRANCH_NAME HEAD sha " $HEAD_SHA_BRANCH
if git diff --name-only $HEAD_SHA_BRANCH HEAD | grep "^${FOLDER_NAME}" &> /dev/null
then
echo ${FOLDER_NAME}
fi

113
scripts/affected-libs.sh Executable file
View File

@@ -0,0 +1,113 @@
#!/usr/bin/env bash
eval BRANCH_NAME=""
eval HEAD_SHA_BRANCH=""
eval SHA_2="HEAD"
eval DIRECTORY="tmp"
show_help() {
echo "Usage: smart-build.sh"
echo ""
echo "-b branch name"
}
branch_name(){
BRANCH_NAME=$1
}
while [[ $1 == -* ]]; do
case "$1" in
-b) branch_name $2; shift 2;;
-*) echo "invalid option: $1" 1>&2; show_help; exit 0;;
esac
done
if [[ "$BRANCH_NAME" == "" ]]
then
echo "The branch name is mandatory"
exit 0
fi
#HEAD_SHA_BRANCH=(`git merge-base origin/$BRANCH_NAME HEAD`)
HEAD_SHA_BRANCH="$(git merge-base origin/$BRANCH_NAME HEAD)"
echo "Branch name $BRANCH_NAME HEAD sha " $HEAD_SHA_BRANCH
# tmp folder doesn't exist.
if [ ! -d "$DIRECTORY" ]; then
#find affected libs
echo "Directory tmp created";
mkdir $DIRECTORY;
fi
if [ ! -f $DIRECTORY/deps.txt ]; then
npm run affected:libs -- $HEAD_SHA_BRANCH "HEAD" > $DIRECTORY/deps.txt
fi
#echo "extensions" > deps.txt
#clean file
sed -i '/^$/d' ./$DIRECTORY/deps.txt
sed -i '/alfresco-components/d' ./$DIRECTORY/deps.txt
sed -i '/nx affected:libs/d' ./$DIRECTORY/deps.txt
sed -i '/^$/d' ./$DIRECTORY/deps.txt
#read result from file
while IFS= read -r var
do
fileLine=$var
done < "./$DIRECTORY/deps.txt"
#transform string to array
libs=(`echo $fileLine | sed 's/^$/\n/g'`)
#core
for i in "${libs[@]}"
do
if [ "$i" == "core" ] ; then
AFFECTED_LIBS="core$ content-services$ process-services$ process-services-cloud$ insights$ extensions$ "
echo "${AFFECTED_LIBS}"
exit 0
fi
done
#process-services
for i in "${libs[@]}"
do
if [ "$i" == "process-services" ] ; then
AFFECTED_LIBS=$AFFECTED_LIBS" process-services$"
fi
done
#content-services
for i in "${libs[@]}"
do
if [ "$i" == "content-services" ] ; then
AFFECTED_LIBS=$AFFECTED_LIBS" content-services$"
fi
done
#insights
for i in "${libs[@]}"
do
if [ "$i" == "insights" ] ; then
AFFECTED_LIBS=$AFFECTED_LIBS" insights$"
fi
done
#extensions
for i in "${libs[@]}"
do
if [ "$i" == "extensions" ] ; then
AFFECTED_LIBS=$AFFECTED_LIBS" extensions$"
fi
done
#process-services-cloud
for i in "${libs[@]}"
do
if [ "$i" == "process-services-cloud" ] ; then
AFFECTED_LIBS=$AFFECTED_LIBS" process-services-cloud$"
fi
done
echo "${AFFECTED_LIBS}"

View File

@@ -0,0 +1,24 @@
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR/..
echo "====== Content Services ======"
echo "====== Build ======"
npm run ng-packagr -- -p ./lib/content-services/ || exit 1
echo "====== Build style ======"
node ./lib/config/bundle-content-services-scss.js || exit 1
echo "====== Copy i18n ======"
mkdir -p ./lib/dist/content-services/bundles/assets/adf-content-services/i18n
cp -R ./lib/content-services/i18n/* ./lib/dist/content-services/bundles/assets/adf-content-services/i18n
echo "====== Copy assets ======"
cp -R ./lib/content-services/assets/* ./lib/dist/content-services/bundles/assets
echo "====== Move to node_modules ======"
rm -rf ./node_modules/@alfresco/adf-content-services/ && \
mkdir -p ./node_modules/@alfresco/adf-content-services/ && \
cp -R ./lib/dist/content-services/* ./node_modules/@alfresco/adf-content-services/

24
scripts/build-core.sh Executable file
View File

@@ -0,0 +1,24 @@
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR/..
echo "====== Core ======"
echo "====== Build ======"
npm run ng-packagr -- -p ./lib/core/ || exit 1
echo "====== Build style ======"
node ./lib/config/bundle-core-scss.js || exit 1
echo "====== Copy i18n ======"
mkdir -p ./lib/dist/core/bundles/assets/adf-core/i18n
cp -R ./lib/core/i18n/* ./lib/dist/core/bundles/assets/adf-core/i18n
echo "====== Copy assets ======"
cp -R ./lib/core/assets/* ./lib/dist/core/bundles/assets
echo "====== Move to node_modules ======"
rm -rf ./node_modules/@alfresco/adf-core/ && \
mkdir -p ./node_modules/@alfresco/adf-core/ && \
cp -R ./lib/dist/core/* ./node_modules/@alfresco/adf-core/

14
scripts/build-extensions.sh Executable file
View File

@@ -0,0 +1,14 @@
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR/..
echo "====== Extensions ======"
echo "====== Build ======"
ng build extensions || exit 1
echo "====== Move to node_modules ======"
rm -rf ./node_modules/@alfresco/adf-extensions/ && \
mkdir -p ./node_modules/@alfresco/adf-extensions/ && \
cp -R ./lib/dist/extensions/* ./node_modules/@alfresco/adf-extensions/

24
scripts/build-insights.sh Executable file
View File

@@ -0,0 +1,24 @@
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR/..
echo "====== Insights ======"
echo "====== Build ======"
npm run ng-packagr -- -p ./lib/insights/ || exit 1
echo "====== Build style ======"
node ./lib/config/bundle-insights-scss.js || exit 1
echo "====== Copy i18n ======"
mkdir -p ./lib/dist/insights/bundles/assets/adf-insights/i18n
cp -R ./lib/insights/i18n/* ./lib/dist/insights/bundles/assets/adf-insights/i18n
echo "====== Copy assets ======"
cp -R ./lib/insights/assets/* ./lib/dist/insights/bundles/assets
echo "====== Move to node_modules ======"
rm -rf ./node_modules/@alfresco/adf-insights/ && \
mkdir -p ./node_modules/@alfresco/adf-insights/ && \
cp -R ./lib/dist/insights/* ./node_modules/@alfresco/adf-insights/

View File

@@ -0,0 +1,24 @@
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR/..
echo "====== Process Services Cloud ======"
echo "====== Build ======"
ng build process-services-cloud || exit 1
echo "====== Build style ======"
node ./lib/config/bundle-process-services-cloud-scss.js || exit 1
echo "====== Copy i18n ======"
mkdir -p ./lib/dist/process-services-cloud/bundles/assets/adf-process-services-cloud/i18n
cp -R ./lib/process-services-cloud/src/lib/i18n/* ./lib/dist/process-services-cloud/bundles/assets/adf-process-services-cloud/i18n
echo "====== Copy assets ======"
cp -R ./lib/process-services-cloud/src/lib/assets/* ./lib/dist/process-services-cloud/bundles/assets
echo "====== Move to node_modules ======"
rm -rf ./node_modules/@alfresco/adf-process-services-cloud/ && \
mkdir -p ./node_modules/@alfresco/adf-process-services-cloud/ && \
cp -R ./lib/dist/process-services-cloud/* ./node_modules/@alfresco/adf-process-services-cloud/

View File

@@ -0,0 +1,24 @@
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR/..
echo "====== Process Services ======"
echo "====== Build ======"
npm run ng-packagr -- -p ./lib/process-services/ || exit 1
echo "====== Build style ======"
node ./lib/config/bundle-process-services-scss.js || exit 1
echo "====== Copy i18n ======"
mkdir -p ./lib/dist/process-services/bundles/assets/adf-process-services/i18n
cp -R ./lib/process-services/i18n/* ./lib/dist/process-services/bundles/assets/adf-process-services/i18n
echo "====== Copy assets ======"
cp -R ./lib/process-services/assets/* ./lib/dist/process-services/bundles/assets
echo "====== Move to node_modules ======"
rm -rf ./node_modules/@alfresco/adf-process-services/ && \
mkdir -p ./node_modules/@alfresco/adf-process-services/ && \
cp -R ./lib/dist/process-services/* ./node_modules/@alfresco/adf-process-services/

52
scripts/smart-build.sh Executable file
View File

@@ -0,0 +1,52 @@
#!/usr/bin/env bash
affected="$(./scripts/affected-libs.sh -b "$TRAVIS_BRANCH")"
libs=(`echo $affected | sed 's/^$/\n/g'`)
#core
for i in "${libs[@]}"
do
if [ "$i" == "core$" ] ; then
./scripts/build-core.sh
fi
done
#content-services
for i in "${libs[@]}"
do
if [ "$i" == "content-services$" ] ; then
./scripts/build-content-services.sh
fi
done
#process-services
for i in "${libs[@]}"
do
if [ "$i" == "process-services$" ] ; then
./scripts/build-process-services.sh
fi
done
#process-services-cloud
for i in "${libs[@]}"
do
if [ "$i" == "process-services-cloud$" ] ; then
./scripts/build-process-services-cloud.sh
fi
done
#insights
for i in "${libs[@]}"
do
if [ "$i" == "insights$" ] ; then
./scripts/build-insights.sh
fi
done
#extensions
for i in "${libs[@]}"
do
if [ "$i" == "extensions$" ] ; then
./scripts/build-extensions.sh
fi
done