diff --git a/Dockerfile b/Dockerfile index f76a4a24..79e2e6b8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,24 +5,26 @@ # Pull base image. FROM dockerfile/ubuntu + +# Set the env variables to non-interactive +ENV DEBIAN_FRONTEND noninteractive +ENV DEBIAN_PRIORITY critical +ENV DEBCONF_NOWARNINGS yes +ENV TERM linux +RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections + +# ADD codewarrior user +RUN useradd codewarrior +RUN rm -rf ~codewarrior && cp -a ~root ~codewarrior && chown -R codewarrior:codewarrior ~codewarrior RUN apt-get install -y python python-dev python-pip python-virtualenv # Define mountable directories. # Install Node.js -RUN \ - cd /tmp && \ - wget http://nodejs.org/dist/node-latest.tar.gz && \ - tar xvzf node-latest.tar.gz && \ - rm -f node-latest.tar.gz && \ - cd node-v* && \ - ./configure && \ - CXX="g++ -Wno-unused-local-typedefs" make && \ - CXX="g++ -Wno-unused-local-typedefs" make install && \ - cd /tmp && \ - rm -rf /tmp/node-v* && \ - echo '\n# Node.js\nexport PATH="node_modules/.bin:$PATH"' >> /root/.bash_profile - +RUN add-apt-repository ppa:chris-lea/node.js +RUN apt-get update +RUN apt-get install -y nodejs +RUN su codewarrior -c "echo '\n# Node.js\nexport PATH=\"/codewars/node_modules/.bin:$PATH\"' >> ~codewarrior/.bash_profile" # Define default command. CMD ["bash"] @@ -40,12 +42,8 @@ RUN apt-get install -y fsharp # Install Coffeescript RUN npm -g install coffee-script -# Install Node testing frameworks -RUN npm -g install chai -RUN npm -g install mocha - -# Install additional node frameworks -RUN npm install immutable +# Install Node testing frameworks & additional frameworks +RUN npm -g install chai mocha immutable # Install Lua RUN apt-get install -y lua5.2 @@ -64,18 +62,14 @@ RUN echo debconf shared/accepted-oracle-license-v1-1 select true | debconf-set-s echo debconf shared/accepted-oracle-license-v1-1 seen true | debconf-set-selections RUN apt-get install -y oracle-java8-installer -# Install Clojure +# Install Clojure (well, install Leiningen) RUN curl https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein > /usr/bin/lein RUN chmod a+x /usr/bin/lein -# Add a few packages by default -RUN mkdir ~/.lein && echo '{:user {:dependencies [[org.clojure/clojure "1.6.0"] [junit/junit "4.11"] [org.hamcrest/hamcrest-core "1.3"]]}}' > ~/.lein/profiles.clj -RUN echo '(defproject codewars "Docker")' > project.clj -RUN LEIN_ROOT=true lein deps # Install Haskell -RUN DEBIAN_FRONTEND=noninteractive apt-get install -y ghc cabal-install -RUN cabal update -RUN cabal install hspec +RUN apt-get install -y ghc cabal-install +RUN su codewarrior -c "cabal update" +RUN su codewarrior -c "cd ~codewarrior ; cabal install hspec" # Install Julia # Julia is really slow, but v0.3 is okay (see http://stackoverflow.com/a/20566032) @@ -90,7 +84,10 @@ RUN printf '#!/bin/bash\njulia-noisy "$@" 2> >(grep -v "OpenBLAS : Your OS does RUN chmod a+x /usr/bin/julia # Install erlang -RUN apt-get -y install erlang +RUN echo "deb http://packages.erlang-solutions.com/ubuntu trusty contrib" >> /etc/apt/sources.list +RUN curl http://packages.erlang-solutions.com/ubuntu/erlang_solutions.asc | apt-key add - +RUN apt-get update +RUN apt-get -y install erlang-nox erlang-dev # Install PHP RUN apt-get -y install php5-cli @@ -98,16 +95,15 @@ RUN apt-get -y install php5-cli # Install GoLang WORKDIR /tmp # http://blog.labix.org/2013/06/15/in-flight-deb-packages-of-go -RUN curl https://godeb.s3.amazonaws.com/godeb-amd64.tar.gz | tar zxv -RUN ./godeb install 1.3 -RUN rm godeb +# This was cool but then it stopped working... that sucks... ~Matt +#RUN curl https://godeb.s3.amazonaws.com/godeb-amd64.tar.gz | tar zxv +#RUN ./godeb install 1.3.1 +#RUN rm godeb +RUN apt-get install -y golang # Install TypeScript RUN npm -g install typescript -# Install Pip -RUN apt-get install python-pip - #Install ruby RUN apt-get install -y python-software-properties && \ apt-add-repository -y ppa:brightbox/ruby-ng && \ @@ -135,23 +131,21 @@ RUN gem install rspec-its --no-ri --no-rdoc #RUN gem install minitest --no-ri --no-rdoc # Install additional gems - RUN gem install rails --no-ri --no-rdoc # Install SQLITE RUN apt-get install -y sqlite libsqlite3-dev RUN gem install sqlite3 --no-ri --no-rdoc -RUN npm install sqlite3 +RUN npm -g install sqlite3 # Install MongoDB RUN apt-get install -y mongodb-server && \ - mkdir /data && \ - mkdir /data/db + mkdir -p /data/db && \ + chown codewarrior:codewarrior /data/db # Install mongo packages for languages -RUN npm install mongoose -RUN npm install mongodb +RUN npm -g install mongoose mongodb RUN pip install pymongo RUN gem install mongo --no-ri --no-rdoc RUN gem install mongoid --no-ri --no-rdoc @@ -160,7 +154,7 @@ RUN gem install mongoid --no-ri --no-rdoc RUN apt-get install -y redis-server # Install Redis Language packages -RUN npm install redis +RUN npm -g install redis RUN gem install redis --no-ri --no-rdoc RUN pip install redis @@ -179,8 +173,21 @@ RUN apt-get -y install clang-3.4 lldb-3.4 # ADD cli-runner and install node deps ADD . /codewars + +# Build the jvm-runner +WORKDIR /codewars/jvm-runner +RUN [ -e target/jvm-runner-0.1.1-standalone.jar ] || LEIN_ROOT=true lein do clean, test, uberjar + WORKDIR /codewars RUN npm install + +# Run the test suite to make sure this thing works + +USER codewarrior +# Set environment variables +ENV TIMEOUT 2000 +ENV USER codewarrior +ENV HOME /home/codewarrior RUN mocha -t 5000 test/* #timeout is a fallback in case an error with node diff --git a/frameworks/clojure/clojure/test/codewars.clj b/frameworks/clojure/clojure/test/codewars.clj deleted file mode 100644 index 62c15baa..00000000 --- a/frameworks/clojure/clojure/test/codewars.clj +++ /dev/null @@ -1,79 +0,0 @@ -(ns clojure.test.codewars - (:refer-clojure :exclude [time]) - (:require - [clojure.test :refer :all :exclude [run-tests with-test-out]] - [clojure.string] - [clojure.stacktrace :as stack])) - -(defmacro with-test-out [& body] - `(-> - (with-out-str ~@body) - (clojure.string/replace "\n" "<:LF:>\n") - (print) - clojure.test/with-test-out)) - -(defn- print-context [] - (when (seq *testing-contexts*) - (->> (testing-contexts-str) (str "") println))) - -(defn- print-with-message [status {:keys [:message]}] - (if (string? message) - (println (str status message)) - (println status))) - -(defn- expr-str [expression] - (if (instance? Throwable expression) - (with-out-str - (stack/print-cause-trace expression *stack-trace-depth*)) - (pr-str expression))) - -(defn- print-expectations [{:keys [:expected :actual]}] - (println "expected:" (pr-str expected) "- actual:" (expr-str actual))) - -(defmulti codewars-report :type) - -(defmethod codewars-report :pass [_] - (with-test-out - (print-context) - (println "Test Passed"))) - -(defmethod codewars-report :fail [m] - (with-test-out - (print-context) - (print-with-message "" m) - (print-expectations m)) - (flush) - (System/exit 1)) - -(defmethod codewars-report :error [m] - (with-test-out - (print-context) - (print-with-message "" m) - (print-expectations m)) - (flush) - (System/exit 1)) - -(defmethod codewars-report :begin-test-ns [_]) -(defmethod codewars-report :end-test-ns [_]) - -(defmethod codewars-report :begin-test-var [m] - (with-test-out - (print "") - (-> m :var (. sym) println))) -(defmethod codewars-report :end-test-var [_]) - -(defmethod codewars-report :summary [_]) - -(defmacro time - [expr] - `(let [start# (System/nanoTime) - ret# ~expr] - (println (str "" - (/ (double (- (System/nanoTime) start#)) 1000000.0) - " msecs <:LF:>")) - ret#)) - -(defmacro run-tests [] - (binding [clojure.test/report - clojure.test.codewars/codewars-report] - (time (clojure.test/run-tests)))) diff --git a/frameworks/java/CwRunListener.java b/frameworks/java/CwRunListener.java deleted file mode 100644 index 0598bda1..00000000 --- a/frameworks/java/CwRunListener.java +++ /dev/null @@ -1,29 +0,0 @@ -import org.junit.runner.notification.Failure; -import org.junit.runner.notification.RunListener; -import org.junit.runner.Description; - -public class CwRunListener extends RunListener -{ - private boolean failed; - public void testFailure(Failure failure) - { - failed = true; - System.out.println("" + formatMessage(failure.getMessage())); - } - public void testStarted(Description description) - { - System.out.println("" + formatMessage(description.getDisplayName())); - failed = false; - } - public void testFinished(Description description) - { - if(!failed) - { - System.out.println("Test Passed"); - } - } - private static String formatMessage(String s) - { - return s.replaceAll("\n", "<:LF:>"); - } -} diff --git a/frameworks/java/CwTestRunner.java b/frameworks/java/CwTestRunner.java deleted file mode 100644 index bb62c379..00000000 --- a/frameworks/java/CwTestRunner.java +++ /dev/null @@ -1,11 +0,0 @@ -import org.junit.runner.JUnitCore; - -public class CwTestRunner -{ - public static void main(String[] args) - { - JUnitCore core = new JUnitCore(); - core.addListener(new CwRunListener()); - core.run(TestFixture.class); - } -}