diff --git a/README.md b/README.md index 738353ccce..4830dc6b4e 100644 --- a/README.md +++ b/README.md @@ -68,44 +68,34 @@ and open [http://localhost:1042/](http://localhost:1042/). ### Using Docker -You'll need to install [Docker](https://docs.docker.com/get-docker/) and [Docker-Compose](https://docs.docker.com/compose/install/). After that, just run `$ docker-compose up --build` in the project directory (or do the GUI-equivalent of this). If this fails because it "couldn't fetch dependencies", try again, it was just a networking error. +You'll need to install [Docker](https://docs.docker.com/get-docker/) and [Docker-Compose](https://docs.docker.com/compose/install/). After that, just run `bin/up` in the project directory (or do the GUI-equivalent of this). If this fails because it "couldn't fetch dependencies", try again, it was just a networking error. It can take a while. You'll see lots of messages, so just wait until you see something like `netrunner-server-1 | nREPL server started on port 44867`. After that, you can visit [http://localhost:1042/](http://localhost:1042/) and the server should be running. -While coding clojure it's important to have a REPL connection going. The server's REPL is configured to always run on port `44867`, so you can connect using `$ lein repl :connect nrepl://localhost:44867` (or the program of your preference, like your code editor). +While coding clojure it's important to have a REPL connection going. The server's REPL is configured to always run on port `44867`, so you can connect using `$ bin/repl` (or the program of your preference, like your code editor). -Now, let's populate the database and create indexes. First, let's open a terminal inside the server container: `$ docker exec -it netrunner-server-1 /bin/bash`. Now, inside this new therminal, we'll run these two commands: *The `--no-card-images` is optional, and removing it causes the card images to be downloaded, which can be slower.* +Now, let's populate the database and create indexes with `bin/database-seed`. This will download card images, which can be slow. When its done the server will be restarted. If you ever need to drop the database, run `bin/database-drop`. This will keep the card images you downloaded previously, but you'll need to do `bin/up` and `bin/database-seed` again. -``` - $ lein fetch --no-card-images - 1648 cards imported - - $ lein create-indexes - Indexes successfully created. -``` +You can access the servers' bash and lein commands individually using `bin/bash` and `bin/lein`. -After this, just restart the server by running `(restart)` in the REPL. - -To do testing, you run them inside the container: `$ docker exec -it netrunner-server-1 /bin/bash` and then `$ lein kaocha`. ### Tests +To do testing, you run them inside the container with `bin/test` and `bin/test-focus`. + To run all tests: - $ lein kaocha - Ran 2640 tests containing 44704 assertions. - 0 failures, 0 errors. + $ bin/test + 3602 tests, 118797 assertions, 0 failures. To run a single test file: - $ lein kaocha --focus game.cards.agendas-test - Ran 216 tests containing 3536 assertions. - 0 failures, 0 errors. + $ bin/test-focus game.cards.agendas-test + 285 tests, 9715 assertions, 0 failures. Or a single test: - $ lein kaocha --focus game.cards.agendas-test/fifteen-minutes - Ran 1 tests containing 29 assertions. - 0 failures, 0 errors. + $ bin/test-focus game.cards.agendas-test/fifteen-minutes + 1 tests, 47 assertions, 0 failures. For more information refer to the [development guide](https://github.com/mtgred/netrunner/wiki/Getting-Started-with-Development). diff --git a/bin/bash b/bin/bash new file mode 100755 index 0000000000..d34b7e5b08 --- /dev/null +++ b/bin/bash @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +docker exec -it netrunner-server-1 /bin/bash "$@" diff --git a/bin/build b/bin/build old mode 100644 new mode 100755 diff --git a/bin/database-drop b/bin/database-drop new file mode 100755 index 0000000000..1642de5998 --- /dev/null +++ b/bin/database-drop @@ -0,0 +1,6 @@ +#!/usr/bin/env sh + +set -eux -o pipefail + +docker exec -it mongodb /usr/bin/mongosh netrunner --eval 'db.dropDatabase()' +bin/down diff --git a/bin/database-seed b/bin/database-seed new file mode 100755 index 0000000000..f5135bd0ae --- /dev/null +++ b/bin/database-seed @@ -0,0 +1,8 @@ +#!/usr/bin/env sh + +set -eux -o pipefail + +docker exec -it netrunner-server-1 /bin/bash lein fetch +docker exec -it netrunner-server-1 /bin/bash lein create-indexes +bin/restart-server + diff --git a/bin/down b/bin/down old mode 100644 new mode 100755 diff --git a/bin/kaocha b/bin/kaocha old mode 100644 new mode 100755 diff --git a/bin/lein b/bin/lein new file mode 100755 index 0000000000..0fd2e7662d --- /dev/null +++ b/bin/lein @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +bin/bash lein "$@" diff --git a/bin/logs b/bin/logs old mode 100644 new mode 100755 diff --git a/bin/repl b/bin/repl new file mode 100755 index 0000000000..524fbd8792 --- /dev/null +++ b/bin/repl @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +bin/lein repl :connect nrepl://localhost:44867 diff --git a/bin/restart b/bin/restart old mode 100644 new mode 100755 diff --git a/bin/restart-server b/bin/restart-server old mode 100644 new mode 100755 diff --git a/bin/test b/bin/test new file mode 100755 index 0000000000..b3eb31f2f4 --- /dev/null +++ b/bin/test @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +bin/lein kaocha "$@" diff --git a/bin/test-focus b/bin/test-focus new file mode 100755 index 0000000000..0973d7aa36 --- /dev/null +++ b/bin/test-focus @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +bin/lein kaocha --focus "$@" diff --git a/bin/up b/bin/up old mode 100644 new mode 100755 index 1318eb0684..507fe8319d --- a/bin/up +++ b/bin/up @@ -1,3 +1,3 @@ #!/usr/bin/env sh -docker-compose up -d --build +docker-compose up diff --git a/docker-compose.yml b/docker-compose.yml index 44141ee3db..c498796781 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,6 +17,7 @@ services: - "./package.json:/usr/src/app/package.json" - "./src:/usr/src/app/src" - "./test:/usr/src/app/test" + - "./tests.edn:/usr/src/app/tests.edn" - "./docker/docker-prod.edn:/usr/src/app/resources/prod.edn" # Override server configs depends_on: - database diff --git a/test/clj/game/core/say_test.clj b/test/clj/game/core/say_test.clj index 1c5c7bfc20..1a7c8d06a8 100644 --- a/test/clj/game/core/say_test.clj +++ b/test/clj/game/core/say_test.clj @@ -21,6 +21,7 @@ (let [cmd-source (with-out-str (repl/source game.core.commands/parse-command)) implemented-cmds (map str (re-seq #"(?<=\")\/[^ \"]*(?=\")" cmd-source)) documented-cmds (map :name command-info)] + (is true) ;; so kaocha doesn't fail this test with no assertions (doseq [cmd implemented-cmds] (when-not (some #(= % cmd) documented-cmds) (is false (str "command '" cmd "' is undocumented"))))