Skip to content

Commit

Permalink
Update travis.script for targeted builds (#1740)
Browse files Browse the repository at this point in the history
* Test new travis.script for target build

This test should only run the components module tests and skip all other tests. Everything should still be compiled.

* Check all commits against master when not running tests.
If we don't run tests then don't dowload bower dependencies nor start the jetty server.

* Skip the travis install step.
Skip the install step of travis as we will do the same actions in script.

* Only consider commits to this branch.
We now ignore any merge commits and only check changed files for current branch.

* Make the script travis compatible.

* Only run and test changed modules.
Only build and test modules with changes and those that depend on the changed modules

* Modules add their own -pl

* Ignore expense manager on travis.

*  sub-module needs to be marked module/submodule

* exclude flow from expense manager

Exclusion is added as else the import tree
is broken.

* Run everything for tests.
Due to travis failing for expense manager
we run the whole flow when building the
test module.

* Only activate expense manager for gatling test
* Build flow-tests for tests
* Have test module as last.
* Don't remove merged pull requests on non pull-request
Only remove merged pull requests when building a pull-request.
  • Loading branch information
caalador authored and pleku committed Jun 7, 2017
1 parent 1f1e208 commit e4e03ef
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 24 deletions.
74 changes: 70 additions & 4 deletions .travis.script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,86 @@
# TRAVIS_SECURE_ENV_VARS == true if encrypted variables, e.g. SONAR_HOST is available
# TRAVIS_REPO_SLUG == the repository, e.g. vaadin/vaadin

# Get all changes to branch (no-merges)
actualCommits=`git log --no-merges --pretty=oneline master^..HEAD`

# If running a pull request drop merged pull requests that have '(#' in the comment)
if [[ "$TRAVIS_PULL_REQUEST" != "false" ]]
then
actualCommits=`echo "$actualCommits" | grep -v "(#"`
fi

#Collect commit hashes
actualCommits=`echo "$actualCommits" | awk '{print $1}' | tr '\n' ' '`

# Get changed files with full path for branch commits.
change=`diff <(git show --name-only $actualCommits) <(git show --summary $actualCommits)`

# Collect changed modules to build and build also modules that depend on the
# selected modules (see the flag '-amd')

modules=
if [[ $change == *"flow-push/"* ]]
then
modules="$modules -pl flow-push"
else
## All modules except for production mode depend on push.
if [[ $change == *"flow-server/"* ]]
then
modules="$modules -pl flow-server"
else
if [[ $change == *"flow-html-components/"* ]]
then
modules="$modules -pl flow-html-components"
else
if [[ $change == *"flow-documentation/"* ]]
then
modules="$modules -pl flow-documentation"
fi
fi

if [[ $change == *"flow-components/"* ]]
then
echo "Setting components flag to true"
modules="$modules -pl flow-components"
fi

if [[ $change == *"flow-client/"* ]]
then
modules="$modules -pl flow-client"
else
if [[ $change == *"flow-test-util/"* ]]
then
modules="$modules -pl flow-test-util"
else
if [[ $change == *"flow-tests/"* ]]
then
modules="$modules -pl flow-tests"
fi
fi
fi
fi
fi

if [[ $change == *"flow-server-production-mode/"* ]]
then
modules="$modules -pl flow-server-production-mode"
fi

if [ "$TRAVIS_PULL_REQUEST" != "false" ] && [ "$TRAVIS_SECURE_ENV_VARS" == "true" ]
then
# Pull request for master with secure vars (SONAR_GITHUB_OAUTH, SONAR_HOST) available

# Trigger Sonar analysis
echo "Running Sonar"
mvn -B -e -V -P validation -Dvaadin.testbench.developer.license=$TESTBENCH_LICENSE -Dtest.excludegroup= -Dsonar.verbose=true -Dsonar.analysis.mode=issues -Dsonar.github.repository=$TRAVIS_REPO_SLUG -Dsonar.host.url=$SONAR_HOST -Dsonar.github.oauth=$SONAR_GITHUB_OAUTH -Dsonar.login=$SONAR_LOGIN -Dsonar.github.pullRequest=$TRAVIS_PULL_REQUEST clean org.jacoco:jacoco-maven-plugin:prepare-agent verify sonar:sonar javadoc:javadoc
mvn -B -e -V -P validation -Dvaadin.testbench.developer.license=$TESTBENCH_LICENSE -Dtest.excludegroup= -Dsonar.verbose=true -Dsonar.analysis.mode=issues -Dsonar.github.repository=$TRAVIS_REPO_SLUG -Dsonar.host.url=$SONAR_HOST -Dsonar.github.oauth=$SONAR_GITHUB_OAUTH -Dsonar.login=$SONAR_LOGIN -Dsonar.github.pullRequest=$TRAVIS_PULL_REQUEST clean org.jacoco:jacoco-maven-plugin:prepare-agent verify sonar:sonar javadoc:javadoc $modules -amd
elif [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" == "master" ]
then
# master build
mvn -B -e -V -Dmaven.javadoc.skip=false -Dvaadin.testbench.developer.license=$TESTBENCH_LICENSE -Pall-tests -Dgatling.skip=true clean org.jacoco:jacoco-maven-plugin:prepare-agent install
mvn -B -e -V -Dmaven.javadoc.skip=false -Dvaadin.testbench.developer.license=$TESTBENCH_LICENSE -Pall-tests -Dgatling.skip=true clean org.jacoco:jacoco-maven-plugin:prepare-agent install $modules -amd
# Sonar should be run after the project is built so that findbugs can analyze compiled sources
mvn -B -e -V -Dmaven.javadoc.skip=false -Dvaadin.testbench.developer.license=$TESTBENCH_LICENSE -Dgatling.skip=true -Dsonar.verbose=true -Dsonar.analysis.mode=publish -Dsonar.host.url=$SONAR_HOST -Dsonar.login=$SONAR_LOGIN sonar:sonar
mvn -B -e -V -Dmaven.javadoc.skip=false -Dvaadin.testbench.developer.license=$TESTBENCH_LICENSE -Dgatling.skip=true -Dsonar.verbose=true -Dsonar.analysis.mode=publish -Dsonar.host.url=$SONAR_HOST -Dsonar.login=$SONAR_LOGIN sonar:sonar $modules -amd
else
# Something else than a "safe" pull request
mvn -B -e -V -Dmaven.javadoc.skip=false -Dvaadin.testbench.developer.license=$TESTBENCH_LICENSE -Pall-tests verify javadoc:javadoc
mvn -B -e -V -Dmaven.javadoc.skip=false -Dvaadin.testbench.developer.license=$TESTBENCH_LICENSE -Pall-tests verify javadoc:javadoc $modules -amd
fi
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ addons:

before_install: ./.travis.before_install.sh

# Skip the installation step.
# https://docs.travis-ci.com/user/customizing-the-build#Skipping-the-Installation-Step
install: true

# Make Chrome IT tests more stable
# https://docs.travis-ci.com/user/gui-and-headless-browsers/#Using-xvfb-to-Run-Tests-That-Require-a-GUI
before_script:
Expand Down
24 changes: 8 additions & 16 deletions flow-components/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,17 @@
<properties>
<frontend.maven.plugin.version>1.4</frontend.maven.plugin.version>
<flow.version>${project.version}</flow.version>
<maven.test.skip>true</maven.test.skip>
</properties>

<profiles>
<profile>
<id>Components-test</id>
<activation>
<property>
<name>test.components</name>
<value>true</value>
</property>
</activation>

<!-- Can we get this nicer somehow? -->
<properties>
<maven.test.skip>false</maven.test.skip>
</properties>
</profile>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>flow-server</artifactId>
<version>0.1.8-SNAPSHOT</version>
</dependency>
</dependencies>

<profiles>
<!-- Profile for generating components from Polymer APIs. -->
<profile>
<id>generator</id>
Expand Down
14 changes: 13 additions & 1 deletion flow-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
<!--<module>test-performance</module>-->
<module>test-scalability</module>
<module>test-memory-leaks</module>
<module>test-expense-manager-imperative</module>
</modules>

<properties>
Expand Down Expand Up @@ -145,7 +144,20 @@
</plugins>
</pluginManagement>
</build>

<profiles>
<profile>
<id>expense-manager</id>
<activation>
<property>
<name>gatling.skip</name>
<value>false</value>
</property>
</activation>
<modules>
<module>test-expense-manager-imperative</module>
</modules>
</profile>
<profile>
<id>eclipse</id>
<build>
Expand Down
4 changes: 4 additions & 0 deletions flow-tests/test-expense-manager-imperative/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
<artifactId>flow-polymer-components</artifactId>
<version>0.0.3-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>com.vaadin</groupId>
<artifactId>flow</artifactId>
</exclusion>
<exclusion>
<groupId>com.vaadin</groupId>
<artifactId>flow-html-components</artifactId>
Expand Down
2 changes: 2 additions & 0 deletions flow-tests/test-root-context/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<packaging>war</packaging>
<properties>
<maven.deploy.skip>true</maven.deploy.skip>
<skip.npm>${maven.test.skip}</skip.npm>
<skip.bower>${maven.test.skip}</skip.bower>
</properties>
<!-- uses default ports 8888 and 8889 -->

Expand Down
2 changes: 2 additions & 0 deletions flow-tests/test-subcontext/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
<maven.deploy.skip>true</maven.deploy.skip>
<server.port>9999</server.port>
<server.stop.port>9998</server.stop.port>

<jetty.skip>${maven.test.skip}</jetty.skip>
</properties>

<dependencies>
Expand Down
4 changes: 1 addition & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@
<npm.version>4.6.1</npm.version>
<frontend.working.directory>src/main/frontend</frontend.working.directory>

<!-- Set to true to run tests for components and skip other tests -->
<test.components>false</test.components>
<maven.test.skip>${test.components}</maven.test.skip>
<maven.test.skip>false</maven.test.skip>
</properties>

<repositories>
Expand Down

0 comments on commit e4e03ef

Please sign in to comment.