diff --git a/.docker/compose-up.sh b/.docker/compose-up.sh deleted file mode 100755 index bf4f7515a6..0000000000 --- a/.docker/compose-up.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -set -e - -./gradlew shadowJar -docker compose -f .docker/docker-compose.yml --ansi never -p triplea up diff --git a/.docker/dip.sh b/.docker/dip.sh deleted file mode 100755 index 8bc8b8d030..0000000000 --- a/.docker/dip.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash - -# -# dip - Displays an equivalent of 'docker container ls' but -# also with IP addresses. -# -# Source this file, then can invoke command "dip" -# -# -# Example Output: -# -# NAMES ┊IP ┊STATUS ┊SIZE -# triplea-database-1 ┊172.20.0.2┊Up 34 minutes (healthy)┊63B (virtual 202MB) -# triplea-game-support-server-1┊172.20.0.4┊Up 20 minutes ┊32.8kB (virtual 241MB) -# triplea-lobby-1 ┊172.20.0.3┊Up 20 minutes ┊32.8kB (virtual 244MB) -# triplea-nginx-1 ┊172.20.0.5┊Up 20 minutes ┊2B (virtual 58.5MB) -# - -docker_ps="$( - docker ps --format 'table{{.Names}}|{{.Status}}|{{.Size}}' | - tail --lines +2 | - sort -)" - -# https://stackoverflow.com/a/20686101 -FORMAT='{{.Name}}|{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' - -ip_addresses=$( - echo "$docker_ps" | - cut --fields 1 --delimiter '|' | - while read -r container; do - docker inspect --format=$FORMAT "$container" - done | - sed 's|^/||' | - sort -) - -{ - FM="\033[1m%s\033[0m|\033[1m%s\033[0m|\033[1m%s\033[0m|\033[1m%s\033[0m" - printf "$FM\n" NAMES IP STATUS SIZE - join -t "|" <(echo "$ip_addresses") <(echo "$docker_ps") -} | - column --separator "|" --output-separator "┊" --table diff --git a/build.gradle b/build.gradle index fdfe62fd7b..c48794c101 100644 --- a/build.gradle +++ b/build.gradle @@ -231,7 +231,7 @@ subprojects { // composeBuild is the same as running => docker compose -f .docker/full-stack.yml --ansi never -p triplea build dockerCompose { projectName = 'triplea' - useComposeFiles = ['.docker/docker-compose.yml' ] + useComposeFiles = ['docker/docker-compose.yml' ] } // compose builds need WAR files for packaging, so we must run the corresponding package (shadowJar) tasks diff --git a/docker/compose-up.sh b/docker/compose-up.sh new file mode 100755 index 0000000000..35053f935e --- /dev/null +++ b/docker/compose-up.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +set -e + +scriptDir=$(realpath "$(dirname "$0")") +rootDir="$scriptDir/.." + +"$rootDir/gradlew" composeUp diff --git a/docker/connect-to-db.sh b/docker/connect-to-db.sh new file mode 100755 index 0000000000..904ea997ad --- /dev/null +++ b/docker/connect-to-db.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# Connect to a locally running database that was started up via docker-compose. + +set -eu + +DB_IP=$(docker inspect \ + --format='{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' \ + triplea-database-1) + +export PGPASSWORD=postgres +psql -h "$DB_IP" -U postgres diff --git a/.docker/docker-compose.yml b/docker/docker-compose.yml similarity index 94% rename from .docker/docker-compose.yml rename to docker/docker-compose.yml index 9f290992f4..4f3d16dc40 100644 --- a/.docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -21,7 +21,7 @@ services: context: ../servers/game-support/server/ dockerfile: Dockerfile environment: - - DB_URL=database:5432/error_report + - DB_URL=database:5432/lobby_db depends_on: - database maps-server: @@ -29,7 +29,7 @@ services: context: ../servers/maps/server/ dockerfile: Dockerfile environment: - - DB_URL=database:5432/maps + - DB_URL=database:5432/lobby_db depends_on: - database database: diff --git a/.docker/init.sql b/docker/init.sql similarity index 100% rename from .docker/init.sql rename to docker/init.sql diff --git a/.docker/nginx/default.conf b/docker/nginx/default.conf similarity index 100% rename from .docker/nginx/default.conf rename to docker/nginx/default.conf diff --git a/docs/development/README.md b/docs/development/README.md index 426de1f7df..66d12b69db 100644 --- a/docs/development/README.md +++ b/docs/development/README.md @@ -29,69 +29,74 @@ If you are new to Open Source & Github: ## Compile and launch TripleA (CLI) ```bash -"./gradlew :game-app:game-headed:run" -``` +# Build & Launch TripleA Game-Client +./gradlew :game-app:game-headed:run -For more detailed steps on building the project with CLI, see: -- [reference/cli-build-commands.md](cli-build-commands.md) +# Run all build checks +./verify -## Compile and launch TripleA (IDEA) +# Run formatting +./gradew spotlessApply -IDE setup has the needed configurations for the project to compile. There are checked in launchers that -IDEA should automatically find. Look in 'run configurations' to launch the game-client. +# Launch a Postgres DB, build & launch TripleA Servers +./gradlew composeUp -## Running build checks locally (CLI) +# Connect to locally running database +./docker/connect-to-db.sh -Verify will run all checks (including additional custom checks): -``` -./verify -``` +# Runs all tests that do not require database +./gradlew test -Tests are split between those that need a database (which runs on docker), vs those that do not. +./gradlew testWithDatabase -- `./gradlew test`: Runs all tests that do not require database -- `./gradlew testWithDatabase`: Runs tests that require a local database -- `./gradlew allTest`: Runs all tests +# Runs all tests +./gradlew allTest +# Run game-app tests +./game-app/run/check -## Run Formatting +# Run tests for a (sub)project +./gradlew :game-app:game-core:test + +# Run a specific test +./gradlew :game-app:game-core:test --tests games.strategy.triplea.UnitUtilsTest -We use 'google java format', be sure to install the plugin in your IDE to properly format -from IDE. Everything can also be formatted from CLI: +# Runs a specific test method +./gradlew :game-app:game-core:test --tests games.strategy.triplea.UnitUtilsTest.multipleTransportedUnitsAreTransferred +# Run specific tests using wildcard (be sure to use quotes around wildcard) +./gradlew :game-app:game-core:test --tests 'games.strategy.triplea.UnitUtilsTest.*Units*' ``` -./gradew spotlessApply + +`gradle` uses caches heavily, thus, if nothing has changed, re-running a test will not actually run the test again. +To really re-execute a test use the `--rerun-tasks` option: +``` +./gradlew --rerun-tasks :game-app:game-core:test ``` -PR builds will fail if the code is not formatted. +## Run Formatting + +We use 'google java format', be sure to install the plugin in your IDE to properly format from IDE. ## Code Conventions (Style Guide) Full list of coding conventions can be found at: [reference/code-conventions](code-conventions) -Please be sure to check these out so that you can fit the general style of the project. - -## Lobby Development - -### Launch Local Database +## Lobby / Server Development -Local database is needed to run the servers (lobby). - -```bash -## start database -./gradlew composeUp +Run: ``` +./gradlew composeUp +./gradlew :game-app:game-headed:run +``` +Nginx will be running on port 80 following the 'composeUp'. +All requests are sent to NGINX and then routed to the correct +docker container. -### Launch local lobby - -Lobby can be launched via the checked-in run configurations from IDE, or from CLI: -```bash -./gradlew :spitfire-server:dropwizard-server:run -``` To connect to local lobby, from the game client: - 'settings > testing > local lobby' - - play online + - click play online button - use 'test:test' to login to local lobby as a moderator ### Working with database @@ -139,11 +144,6 @@ save games from loading. '@RemoteMethod' indicates methods invoked over network. The API of these methods may not change. -## Lots of Manual Testing Required - -A lot of code is not automatically verified via tests. If reasonable tests can be added, do so! -Generally though even the smallest of changes will need to be manually and thoroughly tested -in a variety of maps and scenarios. # FAQ - common problems diff --git a/docs/development/cli-build-commands.md b/docs/development/cli-build-commands.md deleted file mode 100644 index cf20733406..0000000000 --- a/docs/development/cli-build-commands.md +++ /dev/null @@ -1,28 +0,0 @@ -This page serves as reference for the various -CLI build commands that can be run. - -## Running Tests via CLI - -``` -# Run game-app tests -./game-app/run/check - -# Run tests for a (sub)project -./gradlew :game-app:game-core:test - -# Run a specific test -./gradlew :game-app:game-core:test --tests games.strategy.triplea.UnitUtilsTest - -# Runs a specific test method -./gradlew :game-app:game-core:test --tests games.strategy.triplea.UnitUtilsTest.multipleTransportedUnitsAreTransferred - -# Run specific tests using wildcard (be sure to use quotes around wildcard) -./gradlew :game-app:game-core:test --tests 'games.strategy.triplea.UnitUtilsTest.*Units*' -``` - -`gradle` uses caches heavily, thus, if nothing has changed, re-running a test will not actually run the test again. -To really re-execute a test use the `--rerun-tasks` option: -``` -./gradlew --rerun-tasks :game-app:game-core:test -``` - diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/settings/lobby/LobbySelectionViewData.java b/game-app/game-core/src/main/java/games/strategy/triplea/settings/lobby/LobbySelectionViewData.java index 48500fad36..1edd38cf51 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/settings/lobby/LobbySelectionViewData.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/settings/lobby/LobbySelectionViewData.java @@ -28,7 +28,7 @@ class LobbySelectionViewData implements ViewData { @Getter enum LobbyChoice { PROD("Latest Stable", () -> UrlConstants.PROD_LOBBY, true), - LOCAL("Local", () -> "http://localhost:8080", true), + LOCAL("Local", () -> "http://localhost", true), OTHER("Other", () -> ClientSetting.lobbyUri.getValueOrThrow().toString(), false); private final String displayString;