From bf647c147a089d1fd2e455e1f853ec9d67709023 Mon Sep 17 00:00:00 2001 From: Jeremy Goh Date: Mon, 30 Jan 2017 15:49:34 +0800 Subject: [PATCH] [#45] Set up Travis CI (#64) This is to allow all future PRs to be tested on the travis CI service for the convenience of the project maintainers. This ensures that PRs does not break any of the existing features. The build file will instruct travis to write a log message before running any test. This is to give developers and maintainers looking at the log an ease of mind that the tests are indeed being run. This is because the log will look very empty and suspicious even if the build passed if this feature is not implemented. --- .gitignore | 5 +++++ .travis.yml | 10 ++++++++++ README.md | 1 + build.gradle | 41 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 57 insertions(+) create mode 100644 .travis.yml create mode 100644 build.gradle diff --git a/.gitignore b/.gitignore index aa97fb757..fc9333371 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,8 @@ test/data/ /bin/ /data/ publish.sh + +# Gradle build files +.gradle/ +build/ + diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..ab1a94652 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,10 @@ +language: java +matrix: + include: + - jdk: oraclejdk8 + + +addons: + apt: + packages: + - oracle-java8-installer diff --git a/README.md b/README.md index 30edc698c..15de7ea29 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +[![Build Status](https://travis-ci.org/se-edu/addressbook-level3.svg?branch=master)](https://travis-ci.org/se-edu/addressbook-level3) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/d4a0954383444a8db8cb26e5f5b7302c)](https://www.codacy.com/app/se-edu/addressbook-level3?utm_source=github.com&utm_medium=referral&utm_content=se-edu/addressbook-level3&utm_campaign=Badge_Grade) # AddressBook (Level 3) diff --git a/build.gradle b/build.gradle new file mode 100644 index 000000000..2a76a6b8b --- /dev/null +++ b/build.gradle @@ -0,0 +1,41 @@ +apply plugin: 'java' + +repositories { + mavenCentral() +} + +sourceSets { + main { + java { + srcDirs = ['src'] + } + } + test { + java { + srcDirs = ['test/java'] + } + } +} + +dependencies { + testCompile 'junit:junit:4.12' +} + +test { + /* + * Prints the currently running test's name in the CI's build log, + * so that we can check if tests are being silently skipped or stalling the build. + */ + if (System.env.'CI') { + beforeTest { descriptor -> + logger.lifecycle('Running test: ' + descriptor) + } + } +} + +compileJava { + sourceCompatibility = 1.8 + targetCompatibility = 1.8 +} + +defaultTasks 'clean', 'test'