Skip to content

Commit

Permalink
dockerizing build verification, adding back ignored integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
matyb committed Feb 22, 2018
1 parent b05a5b3 commit 4be9929
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 6 deletions.
14 changes: 12 additions & 2 deletions .travis.yml
@@ -1,2 +1,12 @@
language: java
script: "./lib/gradlew -b lib/build.gradle test"
sudo: required

language: ruby

services:
- docker

before_install:
- docker build -t java/koans .

script:
- docker run java/koans /bin/bash -c "git clone https://github.com/matyb/java-koans && gradle -p java-koans/lib buildApp"
18 changes: 18 additions & 0 deletions docker/Dockerfile
@@ -0,0 +1,18 @@
FROM centos:7
MAINTAINER Mat Bentley <mathewkbentley@gmail.com>

ENV JAVA_VERSION 1.8.0
ENV GRADLE_VERSION 3.4.1

# install wget, git, curl, jdk, which
RUN yum remove -y java &&\
yum install -y wget git curl unzip java-$JAVA_VERSION-openjdk-devel which

# install gradle
RUN wget https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-bin.zip &&\
mkdir -p /etc/alternatives/gradle &&\
unzip -d /etc/alternatives/gradle gradle-$GRADLE_VERSION-bin.zip &&\
ln -s /etc/alternatives/gradle/gradle-$GRADLE_VERSION /opt/gradle

ENV PATH $PATH:/opt/gradle/bin
RUN JAVA_HOME=$(readlink $(readlink `which java`) | gawk '$0=gensub(/\/jre\/bin\/java/,"",1)')
30 changes: 30 additions & 0 deletions docker/spec/Dockerfile_spec.rb
@@ -0,0 +1,30 @@
#! /usr/bin/ruby

require "serverspec"
require "docker"

describe "Dockerfile" do
before(:all) do
image = Docker::Image.build_from_dir('.')

set :os, family: :redhat
set :backend, :docker
set :docker_image, image.id
end

it "has jdk8 installed" do
expect(command("javac -version").stderr).to include(" 1.8.")
end

it "has gradle installed" do
expect(command("gradle -version").stdout).to include("Build time")
end

it "can build app" do
output = command("git clone https://github.com/matyb/java-koans && gradle -p java-koans/lib buildApp").stdout
expect(output).to include(":test\n")
expect(output).to include("BUILD SUCCESSFUL")
end

end

Expand Up @@ -15,7 +15,6 @@
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.Ignore;

import com.sandwich.koan.KoanMethod;
import com.sandwich.koan.cmdline.CommandLineArgumentBuilder;
Expand Down Expand Up @@ -94,7 +93,7 @@ public void testGetKoans() throws Exception {
KoanMethod.getInstance(entry.getValue().get("koan")).getMethod().toString());
}

@Test @Ignore /** Ensures that koans are ready for packaging & distribution */
@Test
public void testKoanSuiteRunner_firstKoanFail() throws Exception {
final KoanSuiteResult[] result = new KoanSuiteResult[]{null};
stubPresenter(new SuitePresenter(){
Expand All @@ -116,7 +115,7 @@ public void run(){
assertEquals(result[0].getFailingCase(), firstSuiteClassRan.substring(firstSuiteClassRan.lastIndexOf(".") + 1));
}

@Test @Ignore /** Ensures that koans are ready for packaging & distribution */
@Test
public void testKoanSuiteRunner_allKoansFail() throws Exception {
setRealPath();
final KoanSuiteResult[] result = new KoanSuiteResult[]{null};
Expand Down Expand Up @@ -165,7 +164,7 @@ public void testLineExceptionIsThrownAtIsHintedAtEvenIfThrownFromSuperClass() th
assertSystemOutDoesntContain("Line 10");
}

@Test @Ignore /** Passes locally, fails in CI? */
@Test
public void testWarningFromPlacingExpectationOnWrongSide() throws Throwable {
final String[] message = new String[1];
stubAllKoans(Arrays.asList(new WrongExpectationOrderKoan()));
Expand Down

0 comments on commit 4be9929

Please sign in to comment.