Skip to content

Commit

Permalink
Check if sub-directories have changes (#16940)
Browse files Browse the repository at this point in the history
* Check if sub-directories have changes

On travis check if the projects directory and dependencies have any
changes. If not we finish early.

Limitation: This still requires travis to setup a VM. We just terminate
the VM early when the test detects that the system under test or it's
dependencies have no changes.

- do not run unit/integration/system tests if asciidoc files have been
  modified only
  • Loading branch information
Steffen Siering authored Mar 11, 2020
1 parent 30e432e commit 99ded8e
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 5 deletions.
22 changes: 22 additions & 0 deletions .ci/scripts/travis_has_changes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
set -exuo pipefail

# commit range to check for. For example master...<PR branch>
RANGE=$TRAVIS_COMMIT_RANGE
DIRLIST=$@

# find modified files in range and filter out docs only changes
CHANGED_FILES=$(git diff --name-only $RANGE | grep -v '.asciidoc')

beginswith() { case $2 in "$1"*) true;; *) false;; esac }

for path in $DIRLIST; do
for changed in $CHANGED_FILES; do
if beginswith $path $changed; then
exit 0 # found a match -> continue testing
fi
done
done

echo "NOT testing required. Modified files: $CHANGED_FILES"
exit 1
45 changes: 40 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,169 +34,203 @@ jobs:

# Filebeat
- os: linux
before_install: .ci/scripts/travis_has_changes.sh filebeat libbeat vendor || travis_terminate 0
env: TARGETS="-C filebeat testsuite"
go: $TRAVIS_GO_VERSION
stage: test
- os: osx
before_install: .ci/scripts/travis_has_changes.sh filebeat libbeat vendor || travis_terminate 0
env: TARGETS="TEST_ENVIRONMENT=0 -C filebeat testsuite"
go: $TRAVIS_GO_VERSION
stage: test
- os: linux
before_install: .ci/scripts/travis_has_changes.sh filebeat libbeat vendor || travis_terminate 0
env: TARGETS="-C x-pack/filebeat testsuite"
go: $(GO_VERSION)
stage: test

# Heartbeat
- os: linux
before_install: .ci/scripts/travis_has_changes.sh heartbeat libbeat vendor || travis_terminate 0
env: TARGETS="-C heartbeat testsuite"
go: $TRAVIS_GO_VERSION
stage: test
- os: osx
before_install: .ci/scripts/travis_has_changes.sh heartbeat libbeat vendor || travis_terminate 0
env: TARGETS="TEST_ENVIRONMENT=0 -C heartbeat testsuite"
go: $TRAVIS_GO_VERSION
stage: test

# Auditbeat
- os: linux
before_install: .ci/scripts/travis_has_changes.sh auditbeat libbeat vendor || travis_terminate 0
env: TARGETS="-C auditbeat testsuite"
go: $TRAVIS_GO_VERSION
stage: test
- os: osx
before_install: .ci/scripts/travis_has_changes.sh auditbeat libbeat vendor || travis_terminate 0
env: TARGETS="TEST_ENVIRONMENT=0 -C auditbeat testsuite"
go: $TRAVIS_GO_VERSION
stage: test
- os: linux
before_install: .ci/scripts/travis_has_changes.sh auditbeat libbeat vendor || travis_terminate 0
env: TARGETS="-C auditbeat crosscompile"
go: $TRAVIS_GO_VERSION
stage: test
- os: linux
before_install: .ci/scripts/travis_has_changes.sh auditbeat libbeat vendor || travis_terminate 0
env: TARGETS="-C x-pack/auditbeat testsuite"
go: $TRAVIS_GO_VERSION
stage: test

# Libbeat
- os: linux
before_install: .ci/scripts/travis_has_changes.sh libbeat vendor || travis_terminate 0
env: TARGETS="-C libbeat testsuite"
go: $TRAVIS_GO_VERSION
stage: test
- os: linux
before_install: .ci/scripts/travis_has_changes.sh libbeat vendor || travis_terminate 0
env: TARGETS="-C libbeat crosscompile"
go: $TRAVIS_GO_VERSION
stage: test
- os: linux
before_install: .ci/scripts/travis_has_changes.sh libbeat vendor || travis_terminate 0
env: STRESS_TEST_OPTIONS="-timeout=20m -race -v -parallel 1" TARGETS="-C libbeat stress-tests"
go: $TRAVIS_GO_VERSION
stage: test
- os: linux
before_install: .ci/scripts/travis_has_changes.sh libbeat vendor || travis_terminate 0
env: TARGETS="-C x-pack/libbeat testsuite"
go: $TRAVIS_GO_VERSION
stage: test

# Metricbeat
- os: linux
before_install: .ci/scripts/travis_has_changes.sh metricbeat libbeat vendor || travis_terminate 0
env: TARGETS="-C metricbeat unit-tests coverage-report"
go: $TRAVIS_GO_VERSION
stage: test
- os: linux
before_install: .ci/scripts/travis_has_changes.sh metricbeat libbeat vendor || travis_terminate 0
env: TARGETS="-C metricbeat integration-tests-environment coverage-report"
go: $TRAVIS_GO_VERSION
stage: test
- os: linux
before_install: .ci/scripts/travis_has_changes.sh metricbeat libbeat vendor || travis_terminate 0
env: TARGETS="-C metricbeat update system-tests-environment coverage-report"
go: $TRAVIS_GO_VERSION
stage: test

- os: osx
before_install: .ci/scripts/travis_has_changes.sh metricbeat libbeat vendor || travis_terminate 0
env: TARGETS="TEST_ENVIRONMENT=0 -C metricbeat testsuite"
go: $TRAVIS_GO_VERSION
stage: test
- os: linux
before_install: .ci/scripts/travis_has_changes.sh metricbeat libbeat vendor || travis_terminate 0
env: TARGETS="-C metricbeat crosscompile"
go: $TRAVIS_GO_VERSION
stage: test
- os: linux
before_install: .ci/scripts/travis_has_changes.sh metricbeat libbeat vendor || travis_terminate 0
env: TARGETS="-C x-pack/metricbeat testsuite"
go: $TRAVIS_GO_VERSION
stage: test

# Packetbeat
- os: linux
before_install: .ci/scripts/travis_has_changes.sh packetbeat libbeat vendor || travis_terminate 0
env: TARGETS="-C packetbeat testsuite"
go: $TRAVIS_GO_VERSION
stage: test

# Winlogbeat
- os: linux
before_install: .ci/scripts/travis_has_changes.sh winlogbeat libbeat vendor || travis_terminate 0
env: TARGETS="-C winlogbeat crosscompile"
go: $TRAVIS_GO_VERSION
stage: test

# Functionbeat
- os: linux
before_install: .ci/scripts/travis_has_changes.sh x-pack/functionbeat libbeat vendor || travis_terminate 0
env: TARGETS="-C x-pack/functionbeat testsuite"
go: $TRAVIS_GO_VERSION
stage: test
- os: osx
before_install: .ci/scripts/travis_has_changes.sh x-pack/functionbeat libbeat vendor || travis_terminate 0
env: TARGETS="TEST_ENVIRONMENT=0 -C x-pack/functionbeat testsuite"
go: $TRAVIS_GO_VERSION
stage: test

# Docker Log Driver
- os: linux
before_install: .ci/scripts/travis_has_changes.sh x-pack/dockerlogbeat libbeat vendor || travis_terminate 0
env: TARGETS="-C x-pack/dockerlogbeat testsuite"
go: $TRAVIS_GO_VERSION
stage: test

# Journalbeat
- os: linux
before_install: .ci/scripts/travis_has_changes.sh journalbeat libbeat vendor || travis_terminate 0
env: TARGETS="-C journalbeat testsuite"
go: $TRAVIS_GO_VERSION
stage: test

# Agent
- os: linux
before_install: .ci/scripts/travis_has_changes.sh x-pack/agent libbeat vendor || travis_terminate 0
env: TARGETS="-C x-pack/agent testsuite"
go: $TRAVIS_GO_VERSION
stage: test
- os: osx
before_install: .ci/scripts/travis_has_changes.sh x-pack/agent libbeat vendor || travis_terminate 0
env: TARGETS="TEST_ENVIRONMENT=0 -C x-pack/agent testsuite"
go: $TRAVIS_GO_VERSION
stage: test

# Generators
# https://github.com/elastic/beats/issues/16951
#- os: linux
# before_install: .ci/scripts/travis_has_changes.sh generator metricbeat libbeat vendor || travis_terminate 0
# env: TARGETS="-C generator/_templates/metricbeat test test-package"
# go: $TRAVIS_GO_VERSION
# stage: test
#- os: linux
# before_install: .ci/scripts/travis_has_changes.sh generator libbeat vendor || travis_terminate 0
# env: TARGETS="-C generator/_templates/beat test test-package"
# go: $TRAVIS_GO_VERSION
# stage: test

- os: osx
before_install: .ci/scripts/travis_has_changes.sh generator metricbeat libbeat vendor || travis_terminate 0
env: TARGETS="-C generator/_templates/metricbeat test"
go: $TRAVIS_GO_VERSION
stage: test
- os: osx
before_install: .ci/scripts/travis_has_changes.sh generator libbeat vendor || travis_terminate 0
env: TARGETS="-C generator/_templates/beat test"
go: $TRAVIS_GO_VERSION
stage: test

# Kubernetes
- os: linux
before_install: .ci/scripts/travis_has_changes.sh deploy/kubernetes metricbeat filebeat libbeat vendor || travis_terminate 0
install: deploy/kubernetes/.travis/setup.sh
env:
- TARGETS="-C deploy/kubernetes test"
- TRAVIS_K8S_VERSION=v1.9.4
stage: test
- os: linux
before_install: .ci/scripts/travis_has_changes.sh deploy/kubernetes metricbeat filebeat libbeat || travis_terminate 0
install: deploy/kubernetes/.travis/setup.sh
env:
- TARGETS="-C deploy/kubernetes test"
- TRAVIS_K8S_VERSION=v1.10.0
stage: test
- os: linux
before_install: .ci/scripts/travis_has_changes.sh deploy/kubernetes metricbeat filebeat libbeat || travis_terminate 0
dist: xenial
install: deploy/kubernetes/.travis/setup.sh
env:
Expand Down Expand Up @@ -240,7 +274,12 @@ addons:
- python3.6
- python3.6-venv

before_install:


# Skips installations step
install: true

before_script:
- if [ x$TRAVIS_DIST = xtrusty ]; then sudo ln -sf python3.6 /usr/bin/python3; fi
- python --version
- python3 --version
Expand All @@ -253,10 +292,6 @@ before_install:
- sudo mv docker-compose /usr/local/bin
- if [ $TRAVIS_OS_NAME = osx ]; then pip install virtualenv==16.7.9; fi


# Skips installations step
install: true

script:
# Replacement for travis_wait which doesn't print output in real time.
# Default Travis timeout is 10min, so this workaround prints timestamps every 9min to reset the counter.
Expand Down

0 comments on commit 99ded8e

Please sign in to comment.