Skip to content

Commit

Permalink
Short circuit e2e in case lib not affected (#7801)
Browse files Browse the repository at this point in the history
* Short circuit e2e in case lib not affected

* Use base and head

* Remove useless schema

* Run everything on cron
  • Loading branch information
mauriziovitale committed Aug 30, 2022
1 parent b90b129 commit 109e997
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 54 deletions.
34 changes: 17 additions & 17 deletions .travis.yml
Expand Up @@ -183,7 +183,7 @@ jobs:
- stage: "e2e Test"
name: "Process Cloud: Storybook Playwright"
before_script: ./scripts/ci/jobs/dbpci-before-playwright
script: ./scripts/travis/affected-contains.sh "process-services-cloud" && ./scripts/travis/storybook-testing/storybook-test.sh
script: ./scripts/travis/storybook-testing/storybook-test.sh
workspaces:
use:
- built_libs_cache
Expand All @@ -195,7 +195,7 @@ jobs:
- ./scripts/ci/job_hooks/before_e2e.sh
- ./scripts/ci/check-env/check-cs-env.sh || travis_terminate 1
- ./scripts/ci/check-env/check-ps-env.sh || travis_terminate 1
script: ./scripts/travis/affected-contains.sh "core" && ./scripts/travis/e2e/e2e.sh
script: ./scripts/travis/e2e/e2e.sh "core"
after_script: ./scripts/ci/job_hooks/after_e2e.sh
workspaces:
create:
Expand All @@ -216,7 +216,7 @@ jobs:
before_script:
- ./scripts/ci/job_hooks/before_e2e.sh
- ./scripts/ci/check-env/check-cs-env.sh || travis_terminate 1
script: ./scripts/travis/affected-contains.sh "content-services" && ./scripts/travis/e2e/e2e.sh
script: ./scripts/travis/e2e/e2e.sh "content-services"
after_script: ./scripts/ci/job_hooks/after_e2e.sh
workspaces:
create:
Expand All @@ -237,7 +237,7 @@ jobs:
before_script:
- ./scripts/ci/job_hooks/before_e2e.sh
- ./scripts/ci/check-env/check-cs-env.sh || travis_terminate 1
script: ./scripts/travis/affected-contains.sh "content-services" && ./scripts/travis/e2e/e2e.sh
script: ./scripts/travis/e2e/e2e.sh "content-services"
after_script: ./scripts/ci/job_hooks/after_e2e.sh
workspaces:
create:
Expand All @@ -258,7 +258,7 @@ jobs:
before_script:
- ./scripts/ci/job_hooks/before_e2e.sh
- ./scripts/ci/check-env/check-cs-env.sh || travis_terminate 1
script: ./scripts/travis/affected-contains.sh "content-services" && ./scripts/travis/e2e/e2e.sh
script: ./scripts/travis/e2e/e2e.sh "content-services"
after_script: ./scripts/ci/job_hooks/after_e2e.sh
workspaces:
create:
Expand All @@ -279,7 +279,7 @@ jobs:
before_script:
- ./scripts/ci/job_hooks/before_e2e.sh
- ./scripts/ci/check-env/check-cs-env.sh || travis_terminate 1
script: ./scripts/travis/affected-contains.sh "content-services" && ./scripts/travis/e2e/e2e.sh
script: ./scripts/travis/e2e/e2e.sh "content-services"
after_script: ./scripts/ci/job_hooks/after_e2e.sh
workspaces:
create:
Expand All @@ -300,7 +300,7 @@ jobs:
before_script:
- ./scripts/ci/job_hooks/before_e2e.sh
- ./scripts/ci/check-env/check-cs-env.sh || travis_terminate 1
script: ./scripts/travis/affected-contains.sh "content-services" && ./scripts/travis/e2e/e2e.sh
script: ./scripts/travis/e2e/e2e.sh "content-services"
after_script: ./scripts/ci/job_hooks/after_e2e.sh
workspaces:
create:
Expand All @@ -321,7 +321,7 @@ jobs:
before_script:
- ./scripts/ci/job_hooks/before_e2e.sh
- ./scripts/ci/check-env/check-cs-env.sh || travis_terminate 1
script: ./scripts/travis/affected-contains.sh "content-services" && ./scripts/travis/e2e/e2e.sh
script: ./scripts/travis/e2e/e2e.sh "content-services"
after_script: ./scripts/ci/job_hooks/after_e2e.sh
workspaces:
create:
Expand All @@ -343,7 +343,7 @@ jobs:
- ./scripts/ci/job_hooks/before_e2e.sh
- ./scripts/ci/check-env/check-ps-env.sh || travis_terminate 1
- ./scripts/ci/check-env/check-external-cs-env.sh || travis_terminate 1
script: ./scripts/travis/affected-contains.sh "process-services" && ./scripts/travis/e2e/e2e.sh
script: ./scripts/travis/e2e/e2e.sh "process-services"
after_script: ./scripts/ci/job_hooks/after_e2e.sh
workspaces:
create:
Expand All @@ -365,7 +365,7 @@ jobs:
- ./scripts/ci/job_hooks/before_e2e.sh
- ./scripts/ci/check-env/check-ps-env.sh || travis_terminate 1
- ./scripts/ci/check-env/check-external-cs-env.sh || travis_terminate 1
script: ./scripts/travis/affected-contains.sh "process-services" && ./scripts/travis/e2e/e2e.sh
script: ./scripts/travis/e2e/e2e.sh "process-services"
after_script: ./scripts/ci/job_hooks/after_e2e.sh
workspaces:
create:
Expand All @@ -387,7 +387,7 @@ jobs:
- ./scripts/ci/job_hooks/before_e2e.sh
- ./scripts/ci/check-env/check-ps-env.sh || travis_terminate 1
- ./scripts/ci/check-env/check-external-cs-env.sh || travis_terminate 1
script: ./scripts/travis/affected-contains.sh "process-services" && ./scripts/travis/e2e/e2e.sh
script: ./scripts/travis/e2e/e2e.sh "process-services"
after_script: ./scripts/ci/job_hooks/after_e2e.sh
workspaces:
create:
Expand All @@ -409,7 +409,7 @@ jobs:
- ./scripts/ci/job_hooks/before_e2e.sh
- ./scripts/ci/check-env/check-ps-env.sh || travis_terminate 1
- ./scripts/ci/check-env/check-external-cs-env.sh || travis_terminate 1
script: ./scripts/travis/affected-contains.sh "process-services" && ./scripts/travis/e2e/e2e.sh
script: ./scripts/travis/e2e/e2e.sh "process-services"
after_script: ./scripts/ci/job_hooks/after_e2e.sh
workspaces:
create:
Expand All @@ -431,7 +431,7 @@ jobs:
- ./scripts/ci/job_hooks/before_e2e.sh
- ./scripts/ci/check-env/check-cs-env.sh || travis_terminate 1
- ./scripts/ci/check-env/check-ps-cloud-env.sh || travis_terminate 1
script: ./scripts/travis/affected-contains.sh "process-services-cloud" && ./scripts/travis/e2e/e2e.sh
script: ./scripts/travis/e2e/e2e.sh "process-services-cloud"
after_script: ./scripts/ci/job_hooks/after_e2e.sh
workspaces:
create:
Expand All @@ -454,7 +454,7 @@ jobs:
- ./scripts/ci/job_hooks/before_e2e.sh
- ./scripts/ci/check-env/check-cs-env.sh || travis_terminate 1
- ./scripts/ci/check-env/check-ps-cloud-env.sh || travis_terminate 1
script: ./scripts/travis/affected-contains.sh "process-services-cloud" && ./scripts/travis/e2e/e2e.sh
script: ./scripts/travis/e2e/e2e.sh "process-services-cloud"
after_script: ./scripts/ci/job_hooks/after_e2e.sh
workspaces:
create:
Expand All @@ -477,7 +477,7 @@ jobs:
- ./scripts/ci/job_hooks/before_e2e.sh
- ./scripts/ci/check-env/check-cs-env.sh || travis_terminate 1
- ./scripts/ci/check-env/check-ps-cloud-env.sh || travis_terminate 1
script: ./scripts/travis/affected-contains.sh "process-services-cloud" && ./scripts/travis/e2e/e2e.sh
script: ./scripts/travis/e2e/e2e.sh "process-services-cloud"
after_script: ./scripts/ci/job_hooks/after_e2e.sh
workspaces:
create:
Expand All @@ -500,7 +500,7 @@ jobs:
- ./scripts/ci/job_hooks/before_e2e.sh
- ./scripts/ci/check-env/check-cs-env.sh || travis_terminate 1
- ./scripts/ci/check-env/check-ps-cloud-env.sh || travis_terminate 1
script: ./scripts/travis/affected-contains.sh "process-services-cloud" && ./scripts/travis/e2e/e2e.sh
script: ./scripts/travis/e2e/e2e.sh "process-services-cloud"
after_script: ./scripts/ci/job_hooks/after_e2e.sh
workspaces:
create:
Expand All @@ -523,7 +523,7 @@ jobs:
- ./scripts/ci/job_hooks/before_e2e.sh
- ./scripts/ci/check-env/check-cs-env.sh || travis_terminate 1
- ./scripts/ci/check-env/check-ps-cloud-env.sh || travis_terminate 1
script: ./scripts/travis/affected-contains.sh "process-services-cloud" && ./scripts/travis/e2e/e2e.sh
script: ./scripts/travis/e2e/e2e.sh "process-services-cloud"
after_script: ./scripts/ci/job_hooks/after_e2e.sh
workspaces:
create:
Expand Down
3 changes: 0 additions & 3 deletions scripts/build/build-all-lib.sh
Expand Up @@ -23,7 +23,4 @@ echo "====== Run testing ====="
echo "====== Run Cli ====="
./scripts/build/build-cli.sh || exit 1

echo "====== Copy schema ====="
cp lib/core/src/lib/app-config/schema.json dist/libs/core/app.config.schema.json


18 changes: 9 additions & 9 deletions scripts/travis/affected-contains.sh
Expand Up @@ -5,18 +5,18 @@ verifyLib=$1;
cd $DIR/../../

if [ "${TRAVIS_EVENT_TYPE}" == "cron" ]; then
echo "Affected not check in case of cron"
exit 0
#echo "Affected not check in case of cron"
echo true
fi
AFFECTED_LIBS="$(nx print-affected --type=lib --select=projects --base=$BASE_HASH --head=$HEAD_HASH --plain || exit 1)"
echo "Verify if affected build contains $1"
AFFECTED_LIBS="$(nx print-affected --type=lib --select=projects --base=$BASE_HASH --head=$HEAD_HASH --plain)"
#echo "Verify if affected build contains $1"


echo "Affected libs:$AFFECTED_LIBS"
#echo "Affected libs:$AFFECTED_LIBS"
if [[ $AFFECTED_LIBS =~ $verifyLib ]]; then
echo "Yep project:$verifyLib is affected carry on"
exit 0
#echo "Yep project:$verifyLib is affected carry on"
echo true
else
echo "Nope project NOT affected save time"
exit 1
#echo "Nope project NOT affected save time"
echo false
fi;
61 changes: 36 additions & 25 deletions scripts/travis/e2e/e2e.sh
Expand Up @@ -7,29 +7,40 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR/../../../

BASE_DIRECTORY=$(echo "$FOLDER" | cut -d "/" -f1)

if [ "${TRAVIS_EVENT_TYPE}" == "pull_request" ]; then
echo "Calculate affected e2e $BASE_HASH $HEAD_HASH"
echo "nx affected:libs --base=$BASE_HASH --head=$HEAD_HASH --plain"
AFFECTED_LIBS="$(nx affected:libs --base=$BASE_HASH --head=$HEAD_HASH --plain || exit 1)"
echo "Affected libs ${AFFECTED_LIBS}"
AFFECTED_E2E="$(./scripts/git-util/affected-folder.sh -b $TRAVIS_BRANCH -f "e2e/$FOLDER")";
echo "Affected e2e ${AFFECTED_E2E}"
fi;

if [[ $AFFECTED_LIBS =~ "testing" || $AFFECTED_LIBS =~ "$BASE_DIRECTORY" || "${TRAVIS_EVENT_TYPE}" == "push" || "${TRAVIS_EVENT_TYPE}" == "api" || "${TRAVIS_EVENT_TYPE}" == "cron" ]]; then
echo "Run all e2e $FOLDER"
./scripts/test-e2e-lib.sh --use-dist
else if [[ $AFFECTED_E2E == "e2e/$FOLDER" ]]; then
echo "Run affected e2e"

HEAD_SHA_BRANCH="$(git merge-base origin/$TRAVIS_BRANCH HEAD)"
LIST_SPECS="$(git diff --name-only $HEAD_SHA_BRANCH HEAD | grep "^e2e/$FOLDER" | paste -sd , -)"

echo "Run $FOLDER e2e based on the sha $HEAD_SHA_BRANCH with the specs: "$LIST_SPECS

if [[ $LIST_SPECS != "" ]]; then
./scripts/test-e2e-lib.sh --use-dist
verifyLib=$1;
echo "Step1 - Verify if affected libs contains $verifyLib"

AFFECTED_LIB="$(./scripts/travis/affected-contains.sh $verifyLib )";
if [ ${AFFECTED_LIB} == true ]; then
echo "Step2 - $verifyLib affected... will execute e2e"

if [ "${TRAVIS_EVENT_TYPE}" == "pull_request" ]; then
echo "Calculate affected e2e $BASE_HASH $HEAD_HASH"
echo "nx affected:libs --base=$BASE_HASH --head=$HEAD_HASH --plain"
AFFECTED_LIBS="$(nx affected:libs --base=$BASE_HASH --head=$HEAD_HASH --plain || exit 1)"
echo "Affected libs ${AFFECTED_LIBS}"
AFFECTED_E2E="$(./scripts/git-util/affected-folder.sh -b $TRAVIS_BRANCH -f "e2e/$FOLDER")";
echo "Affected e2e ${AFFECTED_E2E}"
fi;

if [[ $AFFECTED_LIBS =~ "testing" || $AFFECTED_LIBS =~ "$BASE_DIRECTORY" || "${TRAVIS_EVENT_TYPE}" == "push" || "${TRAVIS_EVENT_TYPE}" == "api" || "${TRAVIS_EVENT_TYPE}" == "cron" ]]; then
echo "Run all e2e $FOLDER"
./scripts/test-e2e-lib.sh --use-dist
else if [[ $AFFECTED_E2E == "e2e/$FOLDER" ]]; then
echo "Run affected e2e"

HEAD_SHA_BRANCH="$(git merge-base origin/$TRAVIS_BRANCH HEAD)"
LIST_SPECS="$(git diff --name-only $HEAD_SHA_BRANCH HEAD | grep "^e2e/$FOLDER" | paste -sd , -)"

echo "Run $FOLDER e2e based on the sha $HEAD_SHA_BRANCH with the specs: "$LIST_SPECS

if [[ $LIST_SPECS != "" ]]; then
./scripts/test-e2e-lib.sh --use-dist
fi
fi
fi
fi;
fi;

else
echo "Step2 - Lib $verifyLib NOT affected. No need to run e2e"
fi
exit 0

0 comments on commit 109e997

Please sign in to comment.