Skip to content
This repository has been archived by the owner on Oct 14, 2020. It is now read-only.

Commit

Permalink
Merge pull request #478 from kazk/feature/erlang-otp20
Browse files Browse the repository at this point in the history
Add Erlang support
  • Loading branch information
jhoffner committed Aug 5, 2017
2 parents 44479ad + 7d87188 commit ddd645c
Show file tree
Hide file tree
Showing 16 changed files with 909 additions and 77 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ env:
- TEST_IMG=nim
- TEST_IMG=r
- TEST_IMG=erlang
- TEST_IMG=elixir

script:
- eslint '**/*.js'
Expand Down
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
HOSTNAME=codewars

# Building erlang images have been suspended (frozen) until they are able to be repaired
CONTAINERS=node dotnet jvm java python ruby alt rust julia systems dart crystal ocaml swift haskell objc go lua esolangs chapel nim r erlang
CONTAINERS=node dotnet jvm java python ruby alt rust julia systems dart crystal ocaml swift haskell objc go lua esolangs chapel nim r erlang elixir

ALL_CONTAINERS=${CONTAINERS} base

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ Many languages are currently supported in various states of completeness. This l
| Chapel | 1.15.0 ||| cw-2 | cw-2 | | chapel-runner | cw-2 | |
| Crystal | 0.21.1 || | spec | spec | spec | crystal-runner | spec | |
| Dart | 1.23.0 || | test | test | | dart-runner | test | |
| Elixir | 1.2.4 || | exunit | exunit | | erlang-runner | | |
| Erlang | 18 || | | | | erlang-runner | | |
| Elixir | 1.2.4 || | exunit | exunit | | elixir-runner | | |
| Erlang | 20.0 || | eunit | | | erlang-runner | | |
| F# | 4.1 || | fuchu | fuchu | | dotnet-runner | Fuchu | Tests should be placed in a module called "Tests", in a Fuchu testList |
| Go | 1.8 || | ginkgo | ginkgo | ginkgo | go-runner | ginkgo | |
| Groovy | || | | Kumite Only | | jvm-runner | | |
Expand Down
44 changes: 44 additions & 0 deletions docker/elixir.docker
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
FROM codewars/base-runner

# Set the locale
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

RUN cd /tmp \
&& wget -q https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb \
&& dpkg -i erlang-solutions_1.0_all.deb \
&& rm erlang-solutions_1.0_all.deb \
&& apt-get update -q \
# && apt-cache showpkg esl-erlang \
# && apt-cache showpkg elixir \
&& apt-get install -q -y --no-install-recommends 'esl-erlang=1:18.3' 'elixir=1.2.4-*'

# Install local Elixir hex and rebar
RUN mix local.hex --force \
&& mix local.rebar --force

RUN ln -s /home/codewarrior /workspace
ENV NPM_CONFIG_LOGLEVEL warn

WORKDIR /runner
COPY package.json package.json
RUN npm install --production

COPY *.js ./
COPY lib/*.js lib/
COPY lib/*.sh lib/
COPY lib/utils lib/utils
COPY lib/runners/elixir.js lib/runners/
COPY examples/elixir.yml examples/
COPY frameworks/elixir frameworks/elixir
COPY test/runner.js test/
COPY test/runners/elixir_spec.js test/runners/

USER codewarrior
ENV USER=codewarrior HOME=/home/codewarrior

RUN mocha -t 5000 test/runners/elixir_spec.js

ENTRYPOINT ["node"]
33 changes: 22 additions & 11 deletions docker/erlang.docker
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@ RUN cd /tmp \
&& dpkg -i erlang-solutions_1.0_all.deb \
&& rm erlang-solutions_1.0_all.deb \
&& apt-get update -q \
# && apt-cache showpkg esl-erlang \
# && apt-cache showpkg elixir \
&& apt-get install -q -y --no-install-recommends 'esl-erlang=1:18.3' 'elixir=1.2.4-*'
&& apt-get install -q -y --no-install-recommends 'esl-erlang=1:20.0'

RUN cd /usr/local/bin \
&& wget -q https://github.com/erlang/rebar3/releases/download/3.4.2/rebar3 \
&& chmod a+x rebar3

# Install local Elixir hex and rebar
RUN mix local.hex --force \
&& mix local.rebar --force

RUN ln -s /home/codewarrior /workspace
ENV NPM_CONFIG_LOGLEVEL warn
Expand All @@ -26,21 +25,33 @@ WORKDIR /runner
COPY package.json package.json
RUN npm install --production


COPY *.js ./
COPY lib/*.js lib/
COPY lib/*.sh lib/
COPY lib/utils lib/utils
COPY lib/runners/erlang.js lib/runners/
COPY lib/runners/elixir.js lib/runners/
COPY examples/elixir.yml examples/
COPY frameworks/elixir frameworks/elixir
COPY test/runner.js test/
COPY test/runners/erlang_spec.js test/runners/
COPY test/runners/elixir_spec.js test/runners/
COPY examples/erlang.yml examples/
COPY frameworks/erlang/cw /workspace/erlang
RUN chown -R codewarrior:codewarrior /workspace/erlang

USER codewarrior
ENV USER=codewarrior HOME=/home/codewarrior

RUN mocha -t 5000 test/runners/{erlang,elixir}_spec.js
# fetch packages if any, compile 'eunit_codewars', run some example tests
# 'eunit_codewars' is compiled again with submitted code since it's in '_checkouts'
ENV REBAR_COLOR=none
RUN cd /workspace/erlang \
&& rebar3 compile \
# show dependencies
&& rebar3 deps \
# show project structure
&& rebar3 tree \
&& rebar3 eunit || true \
&& rm -rf src/*.erl test/*.erl _build/test

RUN mocha -t 5000 test/runners/erlang_spec.js

ENTRYPOINT ["node"]
13 changes: 13 additions & 0 deletions documentation/environments/erlang.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Environment

Code is executed within a Dockerized Ubuntu 14.04 container.

## Language

[Erlang/OTP 20.0](http://www.erlang.org/news/114)

## Packages

## Testing

[EUnit](http://erlang.org/doc/apps/eunit/chapter.html)
24 changes: 24 additions & 0 deletions examples/erlang.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
eunit:
algorithms:
initial: |-
-module(algo).
-export([two_oldest_ages/1]).
two_oldest_ages(List) ->
[0, 0].
answer: |-
-module(algo).
-export([two_oldest_ages/1]).
two_oldest_ages(List) ->
lists:nthtail(length(List)-2, lists:sort(List)).
fixture:
-module(algo_tests).
-include_lib("eunit/include/eunit.hrl").

two_oldest_ages_test_() ->
{"Two Oldest Ages",
[{"returns [45, 87] for [1,5,87,45,8,8]", ?_assertMatch([45, 87], algo:two_oldest_ages([1,5,87,45,8,8]))},
{"returns [18, 83] for [6,5,83,5,3,18]", ?_assertMatch([18, 83], algo:two_oldest_ages([6,5,83,5,3,18]))}]}.
10 changes: 10 additions & 0 deletions frameworks/erlang/cw/_checkouts/eunit_codewars/rebar.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{erl_opts, []}.
{deps, []}.

{eunit_opts, [
no_tty,
{report, {eunit_codewars, []}}
]}.
{eunit_compile_opts, [
nowarn_missing_spec
]}.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{application, eunit_codewars,
[{description, "EUnit reporter for Codewars"},
{vsn, "0.1.0"},
{registered, []},
{applications,
[kernel,
stdlib
]},
{env,[]},
{modules, []},
{maintainers, []},
{licenses, ["Apache 2.0"]},
{links, []}
]}.
Loading

0 comments on commit ddd645c

Please sign in to comment.