diff --git a/.travis.yml b/.travis.yml index e2ccc901fa..60617b9dc1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -135,7 +135,7 @@ script: # as long as PR builds - if [ "${TRAVIS_PULL_REQUEST}" = "false" ] && [ "${IS_NIGHTLY_BUILD}" = "no" ]; then COMMAND_THRESHOLD=$(expr ${COMMAND_THRESHOLD} \* 2); fi; ./scripts/travis/time-command.sh "make ${TASK}" ${COMMAND_THRESHOLD} # Run any additional nightly checks only as part of a nightly (cron) build - - if [ "${IS_NIGHTLY_BUILD}" = "yes" ] && [ "${TASK}" = "ci-checks ci-packs-tests" ]; then make ci-checks-nightly; fi + - if [ "${IS_NIGHTLY_BUILD}" = "yes" ]; then ./scripts/travis/run-nightly-make-task-if-exists.sh "${TASK}"; fi # NOTE: We only generate and submit coverage report for master and version branches # NOTE: We put this here and not after_success so build is marked as failed if this step fails # See https://docs.travis-ci.com/user/customizing-the-build/#breaking-the-build @@ -147,3 +147,13 @@ script: # Alternative: use strict pip pinning, including git-based pip packages before_cache: - if [ ${TRAVIS_PULL_REQUEST} = 'false' ] && [ "${IS_NIGHTLY_BUILD}" = "no" ]; then rm -rf virtualenv/; fi + +# We want to be notified when a master or nightly build fails +notifications: + # Post build failures to '#stackstorm' channel in 'stackstorm' Slack + slack: + rooms: + - secure: "rPA22aDgvNe0/S/2e+cp1rSDdDUPufLXnCbfnRzMPVDSQ2UPdLmEl9IeOoEHZmq92AZtzY8UnQaPFuoM0HAPrYDgKopn4n4KpOo+xUlJ92qdNj5qk3Z1TmQHwUYFvCkMvaR/CpX2liRr/YB3qM+1vFAMsYgmqrBX8vcEqNJQy/M=" + on_pull_requests: false + on_success: change # default: always + on_failure: always # default: always diff --git a/Makefile b/Makefile index b7f4a3780a..bc53018418 100644 --- a/Makefile +++ b/Makefile @@ -25,6 +25,7 @@ COMPONENTS_RUNNERS := $(wildcard contrib/runners/*) COMPONENTS_WITHOUT_ST2TESTS := $(shell ls -a | grep ^st2 | grep -v .egg-info | grep -v st2tests | grep -v st2exporter) COMPONENTS_WITH_RUNNERS := $(COMPONENTS) $(COMPONENTS_RUNNERS) +COMPONENTS_WITH_RUNNERS_WITHOUT_MISTRAL_RUNNER := $(foreach component,$(filter-out contrib/runners/mistral_v2,$(COMPONENTS_WITH_RUNNERS)),$(component)) COMPONENTS_TEST_DIRS := $(wildcard st2*/tests) $(wildcard contrib/runners/*/tests) @@ -42,6 +43,7 @@ space_char := space_char += COMPONENT_PYTHONPATH = $(subst $(space_char),:,$(realpath $(COMPONENTS_WITH_RUNNERS))) COMPONENTS_TEST := $(foreach component,$(filter-out $(COMPONENT_SPECIFIC_TESTS),$(COMPONENTS_WITH_RUNNERS)),$(component)) +COMPONENTS_TEST_WITHOUT_MISTRAL_RUNNER := $(foreach component,$(filter-out $(COMPONENT_SPECIFIC_TESTS),$(COMPONENTS_WITH_RUNNERS_WITHOUT_MISTRAL_RUNNER)),$(component)) COMPONENTS_TEST_COMMA := $(subst $(slash),$(dot),$(subst $(space_char),$(comma),$(COMPONENTS_TEST))) COMPONENTS_TEST_MODULES := $(subst $(slash),$(dot),$(COMPONENTS_TEST_DIRS)) COMPONENTS_TEST_MODULES_COMMA := $(subst $(space_char),$(comma),$(COMPONENTS_TEST_MODULES)) @@ -109,6 +111,8 @@ play: @echo @echo COMPONENTS_WITH_RUNNERS=$(COMPONENTS_WITH_RUNNERS) @echo + @echo COMPONENTS_WITH_RUNNERS_WITHOUT_MISTRAL_RUNNER=$(COMPONENTS_WITH_RUNNERS_WITHOUT_MISTRAL_RUNNER) + @echo @echo COMPONENTS_TEST=$(COMPONENTS_TEST) @echo @echo COMPONENTS_TEST_COMMA=$(COMPONENTS_TEST_COMMA) @@ -119,6 +123,8 @@ play: @echo @echo COMPONENTS_TEST_MODULES_COMMA=$(COMPONENTS_TEST_MODULES_COMMA) @echo + @echo COMPONENTS_TEST_WITHOUT_MISTRAL_RUNNER=$(COMPONENTS_TEST_WITHOUT_MISTRAL_RUNNER) + @echo @echo COMPONENT_PYTHONPATH=$(COMPONENT_PYTHONPATH) @echo @echo TRAVIS_PULL_REQUEST=$(TRAVIS_PULL_REQUEST) @@ -573,7 +579,7 @@ endif @echo @echo "----- Dropping st2-test db -----" @mongo st2-test --eval "db.dropDatabase();" - for component in $(COMPONENTS_TEST); do\ + for component in $(COMPONENTS_TEST_WITHOUT_MISTRAL_RUNNER); do\ echo "==========================================================="; \ echo "Running tests in" $$component; \ echo "-----------------------------------------------------------"; \ @@ -939,6 +945,13 @@ ci-py3-unit: NOSE_WITH_TIMER=$(NOSE_WITH_TIMER) tox -e py36-unit -vv NOSE_WITH_TIMER=$(NOSE_WITH_TIMER) tox -e py36-packs -vv +.PHONY: ci-py3-unit-nightly +ci-py3-unit-nightly: + @echo + @echo "==================== ci-py3-unit ====================" + @echo + NOSE_WITH_TIMER=$(NOSE_WITH_TIMER) tox -e py36-unit-nightly -vv + .PHONY: ci-py3-integration ci-py3-integration: requirements .ci-prepare-integration .ci-py3-integration @@ -977,6 +990,15 @@ ci-py3-integration: requirements .ci-prepare-integration .ci-py3-integration .PHONY: ci-unit ci-unit: .unit-tests-coverage-html +.PHONY: ci-unit-nightly +ci-unit-nightly: + # NOTE: We run mistral runner checks only as part of a nightly build to speed up + # non nightly builds (Mistral will be deprecated in the future) + @echo + @echo "============== ci-unit-nightly ==============" + @echo + nosetests $(NOSE_OPTS) -s -v contrib/runners/mistral_v2/tests/unit + .PHONY: .ci-prepare-integration .ci-prepare-integration: sudo -E ./scripts/travis/prepare-integration.sh diff --git a/scripts/travis/run-nightly-make-task-if-exists.sh b/scripts/travis/run-nightly-make-task-if-exists.sh new file mode 100755 index 0000000000..35e0ad9f21 --- /dev/null +++ b/scripts/travis/run-nightly-make-task-if-exists.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +# Script which runs a corresponding make nightly tasks if it exists. If a task corresponding +# nightly task doesn't exist, it's ignored. +# +# For example, let's say we have TASK="ci-checks ci-unit ci-pack-tests" and only +# "ci-checks-nightly" make task exists. +# In this scenario, only "ci-check-nightly" tasks would run and other would be ignored. + +TASK=$1 + +if [ ! "${TASK}" ]; then + echo "Missing TASK argument" + echo "Usage: $0 " + exit 2 +fi + +# Note: TASK could contain a list of multiple tasks +TASKS=($TASK) + +EXISTING_TASKS=() +for TASK_NAME in ${TASKS[@]}; do + $(make -n ${TASK_NAME}-nightly &> /dev/null) + + if [ $? -eq 0 ]; then + # Task {TASK}-nightly exists + EXISTING_TASKS+=("$TASK_NAME-nightly") + fi +done + +# Run only tasks which exist +if [ ${#EXISTING_TASKS[@]} -eq 0 ]; then + echo "No existing nightly tasks found..." + exit 0 +fi + +echo "Running the following nightly tasks: ${EXISTING_TASKS[@]}" +exec make ${EXISTING_TASKS[@]} diff --git a/tox.ini b/tox.ini index fb193b3449..3832b40c02 100644 --- a/tox.ini +++ b/tox.ini @@ -46,12 +46,23 @@ commands = nosetests --rednose --immediate -sv contrib/runners/http_runner/tests/unit/ nosetests --rednose --immediate -sv contrib/runners/noop_runner/tests/unit/ nosetests --rednose --immediate -sv contrib/runners/local_runner/tests/unit/ - nosetests --rednose --immediate -sv contrib/runners/mistral_v2/tests/unit/ nosetests --rednose --immediate -sv contrib/runners/orquesta_runner/tests/unit/ nosetests --rednose --immediate -sv contrib/runners/python_runner/tests/unit/ nosetests --rednose --immediate -sv contrib/runners/winrm_runner/tests/unit/ -# Python 3 tasks +[testenv:py36-unit-nightly] +basepython = python3.6 +setenv = PYTHONPATH = {toxinidir}/external:{toxinidir}/st2common:{toxinidir}/st2api:{toxinidir}/st2actions:{toxinidir}/st2exporter:{toxinidir}/st2reactor:{toxinidir}/st2tests:{toxinidir}/contrib/runners/action_chain_runner:{toxinidir}/contrib/runners/local_runner:{toxinidir}/contrib/runners/python_runner:{toxinidir}/contrib/runners/http_runner:{toxinidir}/contrib/runners/noop_runner:{toxinidir}/contrib/runners/announcement_runner:{toxinidir}/contrib/runners/remote_runner:{toxinidir}/contrib/runners/remote_runner:{toxinidir}/contrib/runners/mistral_v2:{toxinidir}/contrib/runners/orquesta_runner:{toxinidir}/contrib/runners/inquirer_runner:{toxinidir}/contrib/runners/http_runner:{toxinidir}/contrib/runners/winrm_runner + VIRTUALENV_DIR = {envdir} +passenv = NOSE_WITH_TIMER TRAVIS +install_command = pip install -U --force-reinstall {opts} {packages} +deps = virtualenv + -r{toxinidir}/requirements.txt + -e{toxinidir}/st2client + -e{toxinidir}/st2common +commands = + nosetests --rednose --immediate -sv contrib/runners/mistral_v2/tests/unit/ + [testenv:py36-packs] basepython = python3.6 setenv = PYTHONPATH = {toxinidir}/external:{toxinidir}/st2common:{toxinidir}/st2api:{toxinidir}/st2actions:{toxinidir}/st2exporter:{toxinidir}/st2reactor:{toxinidir}/st2tests:{toxinidir}/contrib/runners/action_chain_runner:{toxinidir}/contrib/runners/local_runner:{toxinidir}/contrib/runners/python_runner:{toxinidir}/contrib/runners/http_runner:{toxinidir}/contrib/runners/noop_runner:{toxinidir}/contrib/runners/announcement_runner:{toxinidir}/contrib/runners/remote_runner:{toxinidir}/contrib/runners/remote_runner:{toxinidir}/contrib/runners/mistral_v2:{toxinidir}/contrib/runners/orquesta_runner:{toxinidir}/contrib/runners/inquirer_runner:{toxinidir}/contrib/runners/http_runner:{toxinidir}/contrib/runners/winrm_runner