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

Commit

Permalink
Updated readme, added docker compose configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoffner committed Apr 19, 2016
1 parent 2daa4d4 commit b87bae4
Show file tree
Hide file tree
Showing 4 changed files with 337 additions and 11 deletions.
59 changes: 49 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,32 @@ Within each Docker image, there is a copy of the Node executable and a `run` scr
for executing code. For example to run a simple javascript script which would output `2`:

```
# this is how you run the Node CLI. For this to work you would have to be bash into the correct Docker image
node run -l javascript -c "console.log(1+1)"
```

Because everything runs inside of Docker, you would normally not run Node directly from your host but instead via a Docker run command.
To do this, you would need to choose the right Docker image for the language you wish to execute.
To do this, you would either bash into the corret Docker image like so:

```
# direct Docker call:
docker run --rm -it codewars/node-runner bash
# alternatively you can use the provided Docker Compose configuration:
docker-compose run node-runner
```

Or you could choose to execute the code outside of Docker by creating a container that will remove itself after it executes:

```
# direct Docker call:
docker run --rm codewars/node-runner run -l javascript -c "console.log('I ran inside of Docker using NodeJS')"
docker run --rm codewars/ruby-runner run -l ruby -c "puts 'I ran inside of Docker using Ruby'"
# alternatively you can use the provided Docker Compose configuration:
docker-compose run javascript -c "console.log('I ran inside of Docker using NodeJS')"
docker-compose run ruby -c "puts 'I ran inside of Docker using Ruby'"
```

### Integrated Test Suites
Expand All @@ -39,7 +56,11 @@ code testing methods.
Here is a very simple example of running tests using the simplified CW testing framework.

```
docker run --rm codewars/node-runner run -l javascript -c "var a = 1;" -t cw -f "Test.assertEquals(a, 1)"
# manually running docker
docker run --rm codewars/node-runner run -l javascript -c "var a = 1;" -t cw -f "Test.assertEquals(a, 1)"
# using docker compose
docker-compose run javascript -c "var a = 1;" -t cw -f "Test.assertEquals(a, 1)"
```

Which would output `<PASSED::>Test Passed: Value == 1` to STDOUT.
Expand Down Expand Up @@ -98,7 +119,15 @@ have to worry about having any of the project dependencies loaded directly on yo
Run the following command:

```
docker run -it --rm --entrypoint bash -v $(pwd)/lib:/runner/lib -v $(pwd)/examples:/runner/examples -v $(pwd)/frameworks:/runner/frameworks -v $(pwd)/test:/runner/test codewars/node-runner
docker run \
-it \
--rm \
--entrypoint bash \
-v $(pwd)/lib:/runner/lib \
-v $(pwd)/examples:/runner/examples \
-v $(pwd)/frameworks:/runner/frameworks \
-v $(pwd)/test:/runner/test \
codewars/node-runner
```

This will create a new container and send you into the instance with your project's lib and test directories mounted
Expand All @@ -108,9 +137,15 @@ from within the container.
**Notice**: We did not mount the entire directory because that would overwrite things such as your node_modules directory. If you need
to update these you should `make {image_you_want_to_update}` the image to ensure you are always testing against the correct packages.

If you already have Node installed on your host machine, you can just manage your node_module packages locally for an easier development
flow. This would allow you to just mount your entire source directory.
In this case you would run `npm install` and then `docker run -it --rm --entrypoint bash -v $(pwd):/runner codewars/node-runner`.
### Docker Compose
We mentioned before that you also have the option of using Docker Compose to run the CLI tool. We have setup the `docker-compose.yml`
file to provide very useful pre-configured services for making development easier. Instead of having to issue the long command
mentioned above, you can simply run `docker-compose run node_runner` to bash into a fresh container with your local volumes already mounted.

All of the docker compose services are setup to mount volumes for easier developer, so that is the recommended way of
interacting with the codebase. You should note though that the compose file is unable to build images due to how
the directory structure is layed out, so you have to first `make {runner_name}` the image before you can run it. Otherwise
it will pull down the latest copy from Docker Hub.

### Running Tests

Expand All @@ -119,6 +154,9 @@ Once you are in the Docker image, you can run tests as a part of your developmen
```
# inside of container
mocha test/runners/typescript_spec.js
# or from outside the container
docker-compose run typescript_test
```

## Test Suite Output Format
Expand Down Expand Up @@ -167,11 +205,12 @@ state so not all steps may be needed in your case

1. Install the language and its related packages on one of the Docker images. We have grouped many of the Docker images
together so if that grouping makes sense then add it there, otherwise you will need to create a new docker image within
the docker folder and add that image to the Makefile.
2. Add a new runner script within `lib/runners`. More details about this script later on.
3. Add a new runner spec within `test/runners`. You will also need to add the runner spec to the Docker image so that
the docker folder
1. Add the newly created docker file to the Make and docker-compose files (if applicable)
1. Add a new runner script within `lib/runners`. More details about this script later on.
1. Add a new runner spec within `test/runners`. You will also need to add the runner spec to the Docker image so that
it is tested as a part of the build process.
4. Add a new examples yml file within the `examples` folder. These are the code examples that are used on Codewars.com
1. Add a new examples yml file within the `examples` folder. These are the code examples that are used on Codewars.com
when a user clicks the "Insert Example" button within the kata editor. There is also a helper available for running your examples
as a part of the test suite.

Expand Down
272 changes: 272 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,272 @@
version: '2'
services:
node-runner:
image: codewars/node-runner
volumes:
- ./lib:/runner/lib
- ./examples:/runner/examples
- ./frameworks:/runner/frameworks
- ./test:/runner/test
entrypoint: ''
command: bash

jvm-runner:
image: codewars/jvm-runner
volumes:
- ./lib:/runner/lib
- ./examples:/runner/examples
- ./frameworks:/runner/frameworks
- ./test:/runner/test
entrypoint: ''
command: bash

ruby-runner:
image: codewars/ruby-runner
volumes:
- ./lib:/runner/lib
- ./examples:/runner/examples
- ./frameworks:/runner/frameworks
- ./test:/runner/test
entrypoint: ''
command: bash

python-runner:
image: codewars/python-runner
volumes:
- ./lib:/runner/lib
- ./examples:/runner/examples
- ./frameworks:/runner/frameworks
- ./test:/runner/test
entrypoint: ''
command: bash

func-runner:
image: codewars/func-runner
volumes:
- ./lib:/runner/lib
- ./examples:/runner/examples
- ./frameworks:/runner/frameworks
- ./test:/runner/test
entrypoint: ''
command: bash

systems-runner:
image: codewars/systems-runner
volumes:
- ./lib:/runner/lib
- ./examples:/runner/examples
- ./frameworks:/runner/frameworks
- ./test:/runner/test
entrypoint: ''
command: bash

erlang-runner:
image: codewars/erlang-runner
volumes:
- ./lib:/runner/lib
- ./examples:/runner/examples
- ./frameworks:/runner/frameworks
- ./test:/runner/test
entrypoint: ''
command: bash

alt-runner:
image: codewars/alt-runner
volumes:
- ./lib:/runner/lib
- ./examples:/runner/examples
- ./frameworks:/runner/frameworks
- ./test:/runner/test
entrypoint: ''
command: bash

dotnet-runner:
image: codewars/alt-runner
volumes:
- ./lib:/runner/lib
- ./examples:/runner/examples
- ./frameworks:/runner/frameworks
- ./test:/runner/test
entrypoint: ''
command: bash

# LANGUAGE SPECIFIC HELPERS
javascript:
image: codewars/node-runner
volumes:
- ./lib:/runner/lib
- ./examples:/runner/examples
- ./frameworks:/runner/frameworks
- ./test:/runner/test
entrypoint: 'node run -l javascript'

javascript_test:
image: codewars/node-runner
volumes:
- ./lib:/runner/lib
- ./examples:/runner/examples
- ./frameworks:/runner/frameworks
- ./test:/runner/test
entrypoint: 'mocha -t 5000 test/runners/javascript_spec.js'

coffeescript:
image: codewars/node-runner
volumes:
- ./lib:/runner/lib
- ./examples:/runner/examples
- ./frameworks:/runner/frameworks
- ./test:/runner/test
entrypoint: 'node run -l coffeescript'

coffeescript_test:
image: codewars/node-runner
volumes:
- ./lib:/runner/lib
- ./examples:/runner/examples
- ./frameworks:/runner/frameworks
- ./test:/runner/test
entrypoint: 'mocha -t 5000 test/runners/coffeescript_spec.js'

typescript:
image: codewars/node-runner
volumes:
- ./lib:/runner/lib
- ./examples:/runner/examples
- ./frameworks:/runner/frameworks
- ./test:/runner/test
entrypoint: 'node run -l typescript'

typescript_test:
image: codewars/node-runner
volumes:
- ./lib:/runner/lib
- ./examples:/runner/examples
- ./frameworks:/runner/frameworks
- ./test:/runner/test
entrypoint: 'mocha -t 5000 test/runners/typescript_spec.js'

python:
image: codewars/python-runner
volumes:
- ./lib:/runner/lib
- ./examples:/runner/examples
- ./frameworks:/runner/frameworks
- ./test:/runner/test
entrypoint: 'node run -l python'

python_test:
image: codewars/python-runner
volumes:
- ./lib:/runner/lib
- ./examples:/runner/examples
- ./frameworks:/runner/frameworks
- ./test:/runner/test
entrypoint: 'mocha -t 5000 test/runners/python_spec.js'

python3:
image: codewars/python-runner
volumes:
- ./lib:/runner/lib
- ./examples:/runner/examples
- ./frameworks:/runner/frameworks
- ./test:/runner/test
entrypoint: 'node run -l python3'

python3_test:
image: codewars/python-runner
volumes:
- ./lib:/runner/lib
- ./examples:/runner/examples
- ./frameworks:/runner/frameworks
- ./test:/runner/test
entrypoint: 'mocha -t 5000 test/runners/python3_spec.js'

ruby:
image: codewars/ruby-runner
volumes:
- ./lib:/runner/lib
- ./examples:/runner/examples
- ./frameworks:/runner/frameworks
- ./test:/runner/test
entrypoint: 'node run -l ruby'

ruby_test:
image: codewars/ruby-runner
volumes:
- ./lib:/runner/lib
- ./examples:/runner/examples
- ./frameworks:/runner/frameworks
- ./test:/runner/test
entrypoint: 'mocha -t 5000 test/runners/ruby_spec.js'

haskell:
image: codewars/func-runner
volumes:
- ./lib:/runner/lib
- ./examples:/runner/examples
- ./frameworks:/runner/frameworks
- ./test:/runner/test
entrypoint: 'node run -l haskell'

haskell_test:
image: codewars/func-runner
volumes:
- ./lib:/runner/lib
- ./examples:/runner/examples
- ./frameworks:/runner/frameworks
- ./test:/runner/test
entrypoint: 'mocha -t 5000 test/runners/haskell_spec.js'

java:
image: codewars/jvm-runner
volumes:
- ./lib:/runner/lib
- ./examples:/runner/examples
- ./frameworks:/runner/frameworks
- ./test:/runner/test
entrypoint: 'node run -l java'

java_test:
image: codewars/jvm-runner
volumes:
- ./lib:/runner/lib
- ./examples:/runner/examples
- ./frameworks:/runner/frameworks
- ./test:/runner/test
entrypoint: 'mocha -t 5000 test/runners/java_spec.js'

clojure:
image: codewars/jvm-runner
volumes:
- ./lib:/runner/lib
- ./examples:/runner/examples
- ./frameworks:/runner/frameworks
- ./test:/runner/test
entrypoint: 'node run -l clojure'

clojure_test:
image: codewars/jvm-runner
volumes:
- ./lib:/runner/lib
- ./examples:/runner/examples
- ./frameworks:/runner/frameworks
- ./test:/runner/test
entrypoint: 'mocha -t 5000 test/runners/clojure_spec.js'

csharp:
image: codewars/dotnet-runner
volumes:
- ./lib:/runner/lib
- ./examples:/runner/examples
- ./frameworks:/runner/frameworks
- ./test:/runner/test
entrypoint: 'node run -l csharp'

csharp_test:
image: codewars/dotnet-runner
volumes:
- ./lib:/runner/lib
- ./examples:/runner/examples
- ./frameworks:/runner/frameworks
- ./test:/runner/test
entrypoint: 'mocha -t 5000 test/runners/csharp_spec.js'
Loading

0 comments on commit b87bae4

Please sign in to comment.