diff --git a/.travis.yml b/.travis.yml index 7835f4264..76ac4577c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,12 @@ -# Created with package:mono_repo v2.5.0 +# Created with package:mono_repo v3.0.0 language: dart jobs: include: - - stage: mono_repo_self_validate + - stage: analyze_and_format name: mono_repo self validate os: linux - script: tool/mono_repo_self_validate.sh + script: "pub global activate mono_repo 3.0.0 && pub global run mono_repo travis --validate" - stage: analyze_and_format name: "SDK: 2.9.3; PKGS: angular_components, angular_gallery, angular_gallery_section, examples/app_layout_example, examples/material_button_example, examples/material_card_example, examples/material_checkbox_example, examples/material_chips_example, examples/material_datepicker_example, examples/material_dialog_example, examples/material_expansionpanel_example, examples/material_icon_example, examples/material_list_example, examples/material_menu_example, examples/material_popup_example, examples/material_progress_example, examples/material_radio_example, examples/material_slider_example, examples/material_spinner_example, examples/material_stepper_example, examples/material_tab_example, examples/material_toggle_example, examples/material_tooltip_example, examples/material_yes_no_buttons_example, examples/scorecard_example, examples/simple_html_example; TASKS: `dartanalyzer --fatal-warnings .`" dart: "2.9.3" @@ -57,7 +57,6 @@ jobs: script: tool/travis.sh command_1 command_2 stages: - - mono_repo_self_validate - analyze_and_format - unit_test - build diff --git a/mono_repo.yaml b/mono_repo.yaml index daf9ccad5..451b70667 100644 --- a/mono_repo.yaml +++ b/mono_repo.yaml @@ -1,6 +1,6 @@ # See with https://github.com/google/mono_repo.dart for details on this file -self_validate: true +self_validate: analyze_and_format travis: stages: - analyze_and_format diff --git a/tool/travis.sh b/tool/travis.sh index f959a786a..c0036661e 100755 --- a/tool/travis.sh +++ b/tool/travis.sh @@ -1,22 +1,22 @@ #!/bin/bash -# Created with package:mono_repo v2.5.0 +# Created with package:mono_repo v3.0.0 # Support built in commands on windows out of the box. -function pub { +function pub() { if [[ $TRAVIS_OS_NAME == "windows" ]]; then command pub.bat "$@" else command pub "$@" fi } -function dartfmt { +function dartfmt() { if [[ $TRAVIS_OS_NAME == "windows" ]]; then command dartfmt.bat "$@" else command dartfmt "$@" fi } -function dartanalyzer { +function dartanalyzer() { if [[ $TRAVIS_OS_NAME == "windows" ]]; then command dartanalyzer.bat "$@" else @@ -25,71 +25,98 @@ function dartanalyzer { } if [[ -z ${PKGS} ]]; then - echo -e '\033[31mPKGS environment variable must be set!\033[0m' - exit 1 + echo -e '\033[31mPKGS environment variable must be set! - TERMINATING JOB\033[0m' + exit 64 fi if [[ "$#" == "0" ]]; then - echo -e '\033[31mAt least one task argument must be provided!\033[0m' - exit 1 + echo -e '\033[31mAt least one task argument must be provided! - TERMINATING JOB\033[0m' + exit 64 fi -EXIT_CODE=0 +SUCCESS_COUNT=0 +declare -a FAILURES for PKG in ${PKGS}; do echo -e "\033[1mPKG: ${PKG}\033[22m" - pushd "${PKG}" || exit $? + EXIT_CODE=0 + pushd "${PKG}" >/dev/null || EXIT_CODE=$? + + if [[ ${EXIT_CODE} -ne 0 ]]; then + echo -e "\033[31mPKG: '${PKG}' does not exist - TERMINATING JOB\033[0m" + exit 64 + fi + + pub upgrade --no-precompile || EXIT_CODE=$? - PUB_EXIT_CODE=0 - pub upgrade --no-precompile || PUB_EXIT_CODE=$? + if [[ ${EXIT_CODE} -ne 0 ]]; then + echo -e "\033[31mPKG: ${PKG}; 'pub upgrade' - FAILED (${EXIT_CODE})\033[0m" + FAILURES+=("${PKG}; 'pub upgrade'") + else + for TASK in "$@"; do + EXIT_CODE=0 + echo + echo -e "\033[1mPKG: ${PKG}; TASK: ${TASK}\033[22m" + case ${TASK} in + command_0) + echo './tool/travis/install_protoc.sh' + ./tool/travis/install_protoc.sh || EXIT_CODE=$? + ;; + command_1) + echo 'pub run build_runner build web' + pub run build_runner build web || EXIT_CODE=$? + ;; + command_2) + echo 'pub run build_runner build web --release' + pub run build_runner build web --release || EXIT_CODE=$? + ;; + dartanalyzer_0) + echo 'dartanalyzer --fatal-warnings .' + dartanalyzer --fatal-warnings . || EXIT_CODE=$? + ;; + dartanalyzer_1) + echo 'dartanalyzer --fatal-warnings --fatal-infos .' + dartanalyzer --fatal-warnings --fatal-infos . || EXIT_CODE=$? + ;; + dartfmt) + echo 'dartfmt -n --set-exit-if-changed .' + dartfmt -n --set-exit-if-changed . || EXIT_CODE=$? + ;; + test) + echo 'pub run test --run-skipped' + pub run test --run-skipped || EXIT_CODE=$? + ;; + *) + echo -e "\033[31mUnknown TASK '${TASK}' - TERMINATING JOB\033[0m" + exit 64 + ;; + esac - if [[ ${PUB_EXIT_CODE} -ne 0 ]]; then - EXIT_CODE=1 - echo -e '\033[31mpub upgrade failed\033[0m' - popd - continue + if [[ ${EXIT_CODE} -ne 0 ]]; then + echo -e "\033[31mPKG: ${PKG}; TASK: ${TASK} - FAILED (${EXIT_CODE})\033[0m" + FAILURES+=("${PKG}; TASK: ${TASK}") + else + echo -e "\033[32mPKG: ${PKG}; TASK: ${TASK} - SUCCEEDED\033[0m" + SUCCESS_COUNT=$((SUCCESS_COUNT + 1)) + fi + + done fi - for TASK in "$@"; do - echo - echo -e "\033[1mPKG: ${PKG}; TASK: ${TASK}\033[22m" - case ${TASK} in - command_0) - echo './tool/travis/install_protoc.sh' - ./tool/travis/install_protoc.sh || EXIT_CODE=$? - ;; - command_1) - echo 'pub run build_runner build web' - pub run build_runner build web || EXIT_CODE=$? - ;; - command_2) - echo 'pub run build_runner build web --release' - pub run build_runner build web --release || EXIT_CODE=$? - ;; - dartanalyzer_0) - echo 'dartanalyzer --fatal-warnings .' - dartanalyzer --fatal-warnings . || EXIT_CODE=$? - ;; - dartanalyzer_1) - echo 'dartanalyzer --fatal-warnings --fatal-infos .' - dartanalyzer --fatal-warnings --fatal-infos . || EXIT_CODE=$? - ;; - dartfmt) - echo 'dartfmt -n --set-exit-if-changed .' - dartfmt -n --set-exit-if-changed . || EXIT_CODE=$? - ;; - test) - echo 'pub run test --run-skipped' - pub run test --run-skipped || EXIT_CODE=$? - ;; - *) - echo -e "\033[31mNot expecting TASK '${TASK}'. Error!\033[0m" - EXIT_CODE=1 - ;; - esac - done + echo + echo -e "\033[32mSUCCESS COUNT: ${SUCCESS_COUNT}\033[0m" + + if [ ${#FAILURES[@]} -ne 0 ]; then + echo -e "\033[31mFAILURES: ${#FAILURES[@]}\033[0m" + for i in "${FAILURES[@]}"; do + echo -e "\033[31m $i\033[0m" + done + fi - popd + popd >/dev/null || exit 70 + echo done -exit ${EXIT_CODE} +if [ ${#FAILURES[@]} -ne 0 ]; then + exit 1 +fi