Skip to content

Commit

Permalink
Merge pull request #6605 from ckeditor/i/6478
Browse files Browse the repository at this point in the history
Internal: Added monorepo CI/CC script. Closes #6478. Closes #6477.
  • Loading branch information
mlewand authored May 1, 2020
2 parents caccac3 + b7e9d66 commit 23e5152
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 6 deletions.
7 changes: 1 addition & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,11 @@ node_js:
cache:
- node_modules
before_install:
- export START_TIME=$( date +%s )

This comment has been minimized.

Copy link
@pomek

pomek May 3, 2020

Member

This line is required for ckeditor5-dev-tests-notify-travis-status script.

- npm i -g yarn
install:
- yarn add mrgit --ignore-workspace-root-check
- mrgit sync --resolver-url-template="https://github.com/\${ path }.git"
- git checkout package.json yarn.lock
- rm -rf node_modules
- yarn install
script:
- yarn run test --reporter=dots --production
- ./scripts/codecov-run-tests.sh
- yarn run docs:api --validate-only
- 'if [ $TRAVIS_TEST_RESULT -eq 0 ]; then
travis_wait 30 yarn run docs:build-and-publish-nightly;
Expand Down
95 changes: 95 additions & 0 deletions scripts/continuous-integration-run-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#!/bin/bash

# @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
# For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license

packages=$(ls packages -1 | sed -e 's#^ckeditor5\?-\(.\+\)$#\1#')

errorOccured=0

failedTestsPackages=""
failedCoveragePackages=""

RED='\033[0;31m'
NC='\033[0m'

# Travis functions inspired by https://github.com/travis-ci/travis-rubies/blob/a10ba31e3f508650204017332a608ef9bce2c733/build.sh.
function travis_nanoseconds() {
local cmd="date"
local format="+%s%N"
local os=$(uname)

if hash gdate > /dev/null 2>&1; then
cmd="gdate" # use gdate if available
elif [[ "$os" = Darwin ]]; then
format="+%s000000000" # fallback to second precision on darwin (does not support %N)
fi

$cmd -u $format
}

travis_time_start() {
travis_timer_id=$(printf %08x $(( RANDOM * RANDOM )))
travis_start_time=$(travis_nanoseconds)
echo -en "travis_time:start:$travis_timer_id\r${ANSI_CLEAR}"
}

travis_time_finish() {
local result=$?
travis_end_time=$(travis_nanoseconds)
local duration=$(($travis_end_time-$travis_start_time))
echo -en "\ntravis_time:end:$travis_timer_id:start=$travis_start_time,finish=$travis_end_time,duration=$duration\r${ANSI_CLEAR}"
return $result
}


fold_start() {
echo -e "travis_fold:start:$1\033[33;1m$2\033[0m"
travis_time_start
}

fold_end() {
travis_time_finish
echo -e "\ntravis_fold:end:$1\n"

}

for package in $packages; do

fold_start "pkg-$package" "Testing $package${NC}"

yarn run test -f $package --reporter=dots --production --coverage

if [ "$?" -ne "0" ]; then
echo

echo -e "💥 ${RED}$package${NC} failed to pass unit tests 💥"
failedTestsPackages="$failedTestsPackages $package"
errorOccured=1
fi

if [ "$?" -ne "0" ]; then
echo -e "💥 ${RED}$package${NC} doesn't have required code coverage 💥"
failedCoveragePackages="$failedCoveragePackages $package"
errorOccured=1
fi

fold_end "pkg-$package"
done;

if [ "$errorOccured" -eq "1" ]; then
echo
echo "---"
echo

if ! [[ -z $failedTestsPackages ]]; then
echo -e "Following packages did not pass unit tests:${RED}$failedTestsPackages${NC}"
fi

if ! [[ -z $failedCoveragePackages ]]; then
echo -e "Following packages did not provide required code coverage:${RED}$failedCoveragePackages${NC}"
fi

echo
exit 1 # Will break the CI build
fi

0 comments on commit 23e5152

Please sign in to comment.