From a3fe3861987074099b2b1a4ba3a1653e51ec1f2c Mon Sep 17 00:00:00 2001 From: Daniel Dolezal Date: Fri, 3 Apr 2026 18:37:16 +0200 Subject: [PATCH] use battlsnake cli from git repo and build client localy --- .gitignore | 4 +++- justfile | 42 ++++++++++++++++++++++++++++++++++++------ 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index a737dd1..ab9f877 100644 --- a/.gitignore +++ b/.gitignore @@ -7,5 +7,7 @@ __pycache__/ data/ .env +.tools/ + dbschema/migrations/ -*.jsonl +*.jsonl \ No newline at end of file diff --git a/justfile b/justfile index 7d26b27..fb2a9cd 100644 --- a/justfile +++ b/justfile @@ -12,6 +12,9 @@ set dotenv-required := true # Use zsh set shell := ["bash", "-cu"] +BATTLESNAKE_CLI_DIR := ".tools/battlesnake-cli" +BATTLESNAKE_CLI_BIN := ".tools/battlesnake-cli/battlesnake" + # ------------------------------------------------------------------------------ # Default # ------------------------------------------------------------------------------ @@ -28,23 +31,50 @@ default: run: "{{justfile_directory()}}/main.py" +build-battlesnake-cli: + #!/usr/bin/env bash + set -euo pipefail + + install_dir="{{justfile_directory()}}/{{BATTLESNAKE_CLI_DIR}}" + bin_path="{{justfile_directory()}}/{{BATTLESNAKE_CLI_BIN}}" + mkdir -p "$install_dir" + + if [ ! -f "{{justfile_directory()}}/local-client/go.mod" ]; then + echo "Missing local-client source. Run: git submodule update --init --recursive" + exit 1 + fi + + ( + cd "{{justfile_directory()}}/local-client" + go build -o "$bin_path" ./cli/battlesnake/main.go + ) + + "$bin_path" --help > /dev/null + echo "Built Battlesnake CLI at $bin_path" + +battlesnake-cli-version: + #!/usr/bin/env bash + set -euo pipefail + + "{{justfile_directory()}}/{{BATTLESNAKE_CLI_BIN}}" --help + # ------------------------------------------------------------------------------ # Testing helpers # ------------------------------------------------------------------------------ -test-constrictor: +test-constrictor: build-battlesnake-cli #!/usr/bin/env bash set -euo pipefail - BATTLESNAKE_CLI=battlesnake_cli_1.2.3_Linux_x86_64/battlesnake - $BATTLESNAKE_CLI play -W 11 -H 11 --name 'Python Starter Project' --url http://localhost:8000 -g constrictor --browser --minimumFood 0 + BATTLESNAKE_CLI="{{justfile_directory()}}/{{BATTLESNAKE_CLI_BIN}}" + "$BATTLESNAKE_CLI" play -W 11 -H 11 --name 'Python Starter Project' --url http://localhost:8000 -g constrictor --browser --minimumFood 0 -test-seed: +test-seed: build-battlesnake-cli #!/usr/bin/env bash set -euo pipefail - BATTLESNAKE_CLI=battlesnake_cli_1.2.3_Linux_x86_64/battlesnake - $BATTLESNAKE_CLI play -W 11 -H 11 --name 'Python Starter Project' --url http://localhost:8000 -g solo --browser --seed 1713099635738952360 + BATTLESNAKE_CLI="{{justfile_directory()}}/{{BATTLESNAKE_CLI_BIN}}" + "$BATTLESNAKE_CLI" play -W 11 -H 11 --name 'Python Starter Project' --url http://localhost:8000 -g solo --browser --seed 1713099635738952360 # ------------------------------------------------------------------------------ # Fataset helpers