From ae6a4f25d7dab86bf0c53c0d2dd5961983c37a51 Mon Sep 17 00:00:00 2001 From: micuele Date: Sun, 15 Nov 2026 00:54:05 +0100 Subject: [PATCH 1/2] feat: migrate game to the new GameServer API --- .devcontainer/Dockerfile | 38 ++++++---------- .devcontainer/devcontainer-lock.json | 9 ++++ .devcontainer/devcontainer.json | 47 +++++++++++++------ .devcontainer/post-create.sh | 20 ++++++++ .devcontainer/start-server.sh | 20 ++++++++ .github/workflows/build.yml | 64 ++++++++++---------------- .github/workflows/build_non_main.yml | 41 +++++++---------- .gitignore | 17 ++----- .i18n/en/Game.pot | 14 +----- Game/Doc/Definitions.lean | 2 +- Game/Doc/Tactics.lean | 2 +- Game/Doc/Theorems.lean | 2 +- Game/Metadata.lean | 2 +- lake-manifest.json | 26 +++++------ lakefile.lean | 68 ++++++++++------------------ lean-toolchain | 2 +- sofi.sh | 0 17 files changed, 183 insertions(+), 191 deletions(-) create mode 100644 .devcontainer/devcontainer-lock.json create mode 100755 .devcontainer/post-create.sh create mode 100755 .devcontainer/start-server.sh mode change 100755 => 100644 sofi.sh diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index ea661eb..9dcfb72 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,27 +1,19 @@ -FROM node:18 +FROM mcr.microsoft.com/devcontainers/javascript-node:26-bookworm -# Set default shell to bash -SHELL ["/bin/bash", "-c"] +# The game server (leangame) in the version of the game, e.g. `v4.35.0` for +# `leanprover/lean4:v4.35.0`. It finds the game as a sibling folder in `/workspaces`, which only +# root can write to. Docker caches this step: after a tag has moved, rebuild without cache. +COPY lean-toolchain /tmp/lean-toolchain +RUN version="$(sed -E 's/.*:(v[0-9.]+).*/\1/' /tmp/lean-toolchain)" \ + && git clone --depth 1 --branch "$version" https://github.com/hhu-adam/leangame.git /workspaces/leangame \ + && chown -R node:node /workspaces/leangame -# ADD ./* GameSkeleton/ +USER node -# install curl, git and nodejs -RUN apt-get update && \ - apt-get install -y curl && \ - apt-get install -y git && \ - apt-get install -y python3 && \ - apt-get clean +# the browser for the tests of the game server is not needed +RUN cd /workspaces/leangame && CYPRESS_INSTALL_BINARY=0 npm ci && npm cache clean --force -# install lean4game -#COPY lean-toolchain . -#COPY npm-install.sh . - -#RUN chmod +x npm-install.sh -#RUN ./npm-install.sh - -# install lean -#COPY lean-install.sh . -#RUN chmod +x lean-install.sh -#RUN ./lean-install.sh - -#CMD ["bash"] +# install elan and the Lean toolchain of the game +RUN curl https://elan.lean-lang.org/elan-init.sh -sSf \ + | sh -s -- -y --default-toolchain "$(cat /tmp/lean-toolchain)" +ENV PATH="/home/node/.elan/bin:${PATH}" diff --git a/.devcontainer/devcontainer-lock.json b/.devcontainer/devcontainer-lock.json new file mode 100644 index 0000000..62fb41f --- /dev/null +++ b/.devcontainer/devcontainer-lock.json @@ -0,0 +1,9 @@ +{ + "features": { + "ghcr.io/devcontainers/features/git:1": { + "version": "1.3.8", + "resolved": "ghcr.io/devcontainers/features/git@sha256:fd75977de13a9979000e0e78baf949adb0ca71d2398995fa22e0a36d7e7e7fe2", + "integrity": "sha256:fd75977de13a9979000e0e78baf949adb0ca71d2398995fa22e0a36d7e7e7fe2" + } + } +} diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 34113ab..a645bd5 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,19 +1,38 @@ { - "forwardPorts": [3000], - "build": {"dockerfile": "Dockerfile"}, - "onCreateCommand": "bash .devcontainer/setup.sh", - "postAttachCommand": "bash .devcontainer/run-server.sh", + "name": "game", + + "build": { + "dockerfile": "Dockerfile", + // the Dockerfile reads `lean-toolchain` + "context": ".." + }, + + "features": { + "ghcr.io/devcontainers/features/git:1": {} + }, + "customizations": { "vscode": { - "settings": { - "remote.autoForwardPorts": false - }, - "extensions": [ - "leanprover.lean4" - ] - }, - "codespaces": { - "openFiles": ["Game.lean"] + "extensions": ["leanprover.lean4"] } - } + }, + + "remoteEnv": { + // don't expose the host's forwarded SSH agent + "SSH_AUTH_SOCK": "" + }, + + "remoteUser": "node", + "containerUser": "node", + + "runArgs": ["--cap-drop=ALL", "--security-opt=no-new-privileges:true"], + + // the game server, see `start-server.sh` + "forwardPorts": [3000], + "portsAttributes": { + "3000": { "label": "Game", "onAutoForward": "openBrowserOnce" } + }, + // builds the game, see `post-create.sh` + "postCreateCommand": ".devcontainer/post-create.sh", + "postAttachCommand": ".devcontainer/start-server.sh" } diff --git a/.devcontainer/post-create.sh b/.devcontainer/post-create.sh new file mode 100755 index 0000000..16464f7 --- /dev/null +++ b/.devcontainer/post-create.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +# Builds the game once the devcontainer is created. If the game depends on mathlib, the +# prebuilt mathlib is downloaded first, building it from scratch would take hours. +set -euo pipefail + +cd "$(dirname "${BASH_SOURCE[0]}")/.." + +# fails if the game doesn't depend on mathlib, which only has the executable `cache` +if ! lake exe cache get; then + # the dependencies have been fetched by now + if [ -d .lake/packages/mathlib ]; then + echo "Downloading the prebuilt mathlib failed, not building it from scratch." >&2 + echo "Run \`lake exe cache get\` and then \`lake build\` to try again." >&2 + exit 1 + fi + echo "The game doesn't depend on mathlib, nothing to download." +fi + +lake build +lake build GameServer diff --git a/.devcontainer/start-server.sh b/.devcontainer/start-server.sh new file mode 100755 index 0000000..556d6f8 --- /dev/null +++ b/.devcontainer/start-server.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +# Starts the game server (leangame), which the Dockerfile installs next to the game, at +# http://localhost:3000. Runs when VS Code connects to the devcontainer. Stop it with Ctrl+C +# and start it again with `.devcontainer/start-server.sh`. +set -euo pipefail + +GAME_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +GAME="$(basename "$GAME_DIR" | tr '[:upper:]' '[:lower:]')" +URL="http://localhost:3000/g/local/$GAME" + +# e.g. after reloading the window, the server may still be running +if curl --silent --fail --max-time 2 --output /dev/null http://localhost:3000; then + echo "The game server is already running: $URL" + exit 0 +fi + +echo "Starting the game server, the game will be at $URL" +echo "After changing the game, run \`lake build\` and reload the page." +cd /workspaces/leangame +exec npm start diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 39084ff..54a4403 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,63 +4,45 @@ on: workflow_dispatch: push: branches: - - "main" + - 'main' jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - - name: Free disk space - # Mathlib's build is several GB and grows with every release, and packaging the game - # needs room for a zip of it too. Remove preinstalled SDKs this job never uses. + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 + + # `lean-action` refuses to run without a `lake-manifest.json`, but we do not want to include + # the manifest from the `leangame` repo. + # When using this template, you can replace the following steps with + # - uses: leanprover/lean-action@v1 + # with: + # use-github-cache: false + - name: install elan run: | - df -h / - sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL - df -h / - - - uses: leanprover/lean-action@v1 - with: - use-github-cache: false - - - name: Offline checks (build, axioms, world tree, inventory, shortcuts, translation) - run: bash test/run_checks.sh - - - name: Show the check logs on the run page - # Written to the job summary, not uploaded: the Game Server imports a repository's newest - # artifact whatever its name, so the built game must be the only artifact this repo makes. - if: always() + curl -sSfL https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh | sh -s -- -y --default-toolchain none + echo "$HOME/.elan/bin" >> "$GITHUB_PATH" + - name: update dependencies + run: lake update -R --keep-toolchain + - name: build game run: | - shopt -s nullglob - for f in test/results/*.log; do - printf '
%s\n\n```text\n' "$f" - cat "$f" - printf '\n```\n
\n\n' - done >> "$GITHUB_STEP_SUMMARY" + lake build + lake build GameServer - - name: Make sure the game fits on disk once zipped - # The Mathlib cache download is no longer needed after the build. A zip is never larger - # than what it compresses, so stop here with a clear message rather than in `zip`. - run: | - rm -rf ~/.cache/mathlib - need=$(du -sb --exclude=.git . | cut -f1) - have=$(df -B1 --output=avail . | tail -1) - echo "packaging needs up to $((need / 2**30)) GiB, $((have / 2**30)) GiB free" - if [ "$have" -lt "$need" ]; then - echo "::error::Not enough disk space to package the game: need up to $((need / 2**30)) GiB, have $((have / 2**30)) GiB." - exit 1 - fi + # The Lean server loads all `.ilean` files into RAM, which the game server does not need. + # Lake only needs the files to exist, otherwise it considers the game as not built. + - name: empty the .ilean files + run: find -L .lake -name '*.ilean' -exec truncate -s 0 {} + - name: compress built game #run: tar -czvf ../game.tar.gz . run: zip game.zip * .lake/ .i18n/ -r - name: upload compressed game folder - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7 with: name: build-for-server-import path: | game.zip - name: What next? - run: echo "To export the game to the Game Server, open https://adam.math.hhu.de/import/trigger/${GITHUB_REPOSITORY,,} \n Afterwards, you can play the game at https://adam.math.hhu.de/#/g/${GITHUB_REPOSITORY,,}" + run: echo "To load the game to the game server, visit https://adam.math.hhu.de/import. \n Afterwards, you can play the game at https://adam.math.hhu.de/g/${GITHUB_REPOSITORY,,}" diff --git a/.github/workflows/build_non_main.yml b/.github/workflows/build_non_main.yml index 4db6d00..58d7e4d 100644 --- a/.github/workflows/build_non_main.yml +++ b/.github/workflows/build_non_main.yml @@ -5,35 +5,26 @@ on: pull_request: push: branches-ignore: - - "main" + - 'main' jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 - - name: Free disk space - # Mathlib's build is several GB and grows with every release, and packaging the game - # needs room for a zip of it too. Remove preinstalled SDKs this job never uses. + # `lean-action` refuses to run without a `lake-manifest.json`, but we do not want to include + # the manifest from the `leangame` repo. + # When using this template, you can replace the following steps with + # - uses: leanprover/lean-action@v1 + # with: + # use-github-cache: false + - name: install elan run: | - df -h / - sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL - df -h / - - uses: leanprover/lean-action@v1 - with: - use-github-cache: false - - - name: Offline checks (build, axioms, world tree, inventory, shortcuts, translation) - run: bash test/run_checks.sh - - - name: Show the check logs on the run page - # Written to the job summary, not uploaded: the Game Server imports a repository's newest - # artifact whatever its name, so the built game must be the only artifact this repo makes. - if: always() + curl -sSfL https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh | sh -s -- -y --default-toolchain none + echo "$HOME/.elan/bin" >> "$GITHUB_PATH" + - name: update dependencies + run: lake update -R --keep-toolchain + - name: build game run: | - shopt -s nullglob - for f in test/results/*.log; do - printf '
%s\n\n```text\n' "$f" - cat "$f" - printf '\n```\n
\n\n' - done >> "$GITHUB_STEP_SUMMARY" + lake build + lake build GameServer diff --git a/.gitignore b/.gitignore index 9f3047a..b0f755d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,14 +1,5 @@ -build/ -lake-packages/ -.lake/ -**/.DS_Store -.i18n/**/*.mo -__pycache__/ +.DS_Store -# Durable-runner logs and notes from automated agents -.argus_subagents/ -.autors -.scratch - -# Output paths -test/results +# Lean +**/.lake +**/.i18n/**/*.mo diff --git a/.i18n/en/Game.pot b/.i18n/en/Game.pot index 010d85c..224eae8 100644 --- a/.i18n/en/Game.pot +++ b/.i18n/en/Game.pot @@ -1,7 +1,7 @@ msgid "" msgstr "Project-Id-Version: Game v4.35.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-10-31\n" +"POT-Creation-Date: 2026-11-15\n" "Last-Translator: \n" "Language-Team: none\n" "Language: en\n" @@ -10,18 +10,6 @@ msgstr "Project-Id-Version: Game v4.35.0\n" "X-Poedit-Basepath: ../..\n" "X-Poedit-SearchPath-0: ." -#: GameServer/RpcHandlers.lean:169 -msgid "level completed! 🎉" -msgstr "" - -#: GameServer/RpcHandlers.lean:177 -msgid "level completed with warnings… 🎭" -msgstr "" - -#: GameServer/RpcHandlers.lean:190 -msgid "intermediate goal solved! 🎉" -msgstr "" - #. §0: `intro h` #. §1: `∀` #. §2: `h` diff --git a/Game/Doc/Definitions.lean b/Game/Doc/Definitions.lean index c48ab7a..31a78fb 100644 --- a/Game/Doc/Definitions.lean +++ b/Game/Doc/Definitions.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Game.Machines /-! diff --git a/Game/Doc/Tactics.lean b/Game/Doc/Tactics.lean index d1a1ef8..1c2c5a6 100644 --- a/Game/Doc/Tactics.lean +++ b/Game/Doc/Tactics.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi /-! # Tactic documentation diff --git a/Game/Doc/Theorems.lean b/Game/Doc/Theorems.lean index 3b855dc..a3e5848 100644 --- a/Game/Doc/Theorems.lean +++ b/Game/Doc/Theorems.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Game.Machines /-! diff --git a/Game/Metadata.lean b/Game/Metadata.lean index a83e7dd..9a9aa2d 100644 --- a/Game/Metadata.lean +++ b/Game/Metadata.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Game.Machines import Game.Doc.Tactics import Game.Doc.Definitions diff --git a/lake-manifest.json b/lake-manifest.json index 56ae987..69fc413 100644 --- a/lake-manifest.json +++ b/lake-manifest.json @@ -11,11 +11,11 @@ "inputRev": "v4.35.0", "inherited": false, "configFile": "lakefile.toml"}, - {"url": "https://github.com/leanprover-community/lean4game.git", + {"url": "https://github.com/hhu-adam/GameServer.git", "type": "git", - "subDir": "server", + "subDir": null, "scope": "hhu-adam", - "rev": "9f0aadcc19cb9edc808ff29f38210cac3eec20d6", + "rev": "43fd5128c775ca2385727b9423cc2f7272d0c55e", "name": "GameServer", "manifestFile": "lake-manifest.json", "inputRev": "v4.35.0", @@ -31,6 +31,16 @@ "inputRev": "v4.35.0", "inherited": true, "configFile": "lakefile.lean"}, + {"url": "https://github.com/leanprover-community/import-graph", + "type": "git", + "subDir": null, + "scope": "leanprover-community", + "rev": "a41f0e9a4dea23188ea9cc1c41ac9f8bbafe0b93", + "name": "importGraph", + "manifestFile": "lake-manifest.json", + "inputRev": "main", + "inherited": true, + "configFile": "lakefile.toml"}, {"url": "https://github.com/hhu-adam/lean-i18n", "type": "git", "subDir": null, @@ -71,16 +81,6 @@ "inputRev": "main", "inherited": true, "configFile": "lakefile.toml"}, - {"url": "https://github.com/leanprover-community/import-graph", - "type": "git", - "subDir": null, - "scope": "leanprover-community", - "rev": "a41f0e9a4dea23188ea9cc1c41ac9f8bbafe0b93", - "name": "importGraph", - "manifestFile": "lake-manifest.json", - "inputRev": "main", - "inherited": true, - "configFile": "lakefile.toml"}, {"url": "https://github.com/leanprover-community/ProofWidgets4", "type": "git", "subDir": null, diff --git a/lakefile.lean b/lakefile.lean index 5805c65..8a61b5a 100644 --- a/lakefile.lean +++ b/lakefile.lean @@ -5,17 +5,25 @@ open Lake DSL def leanVersion : String := s!"v{Lean.versionString}" /-- -Use the GameServer from a `lean4game` folder lying next to the game on your local computer. -Activated with `lake update -Klean4game.local`. - -Note: Lake 4.35 replaced `Dependency.version?` (an `Option String`) with -`Dependency.version` (an `InputVer`), so the GameSkeleton spelling of these two -declarations has been updated accordingly. +Use the GameServer from a `leangame` folder lying next to the game on your local computer. +Activated with `lake update -R -Kleangame.local --keep-toolchain`. -/ def LocalGameServer : Dependency := { name := `GameServer scope := "hhu-adam" - src? := DependencySrc.path "../lean4game/server" + src? := DependencySrc.path "../leangame/server/lean" + version := .none + opts := ∅ +} + +/-- +For development of the game server itself, the GameServer dependency needs to come from within the repo. +Activated with `lake update -R -Kleangame.testgame --keep-toolchain`. +-/ +def TestGameServer : Dependency := { + name := `GameServer + scope := "hhu-adam" + src? := DependencySrc.path "../server/lean" version := .none opts := ∅ } @@ -27,56 +35,28 @@ Deactivate local version with `lake update -R`. def RemoteGameServer : Dependency := { name := `GameServer scope := "hhu-adam" - src? := DependencySrc.git "https://github.com/leanprover-community/lean4game.git" leanVersion "server" + src? := DependencySrc.git "https://github.com/hhu-adam/GameServer.git" leanVersion .none version := .git leanVersion opts := ∅ } /- -Choose GameServer dependency depending on whether `-Klean4game.local` has been passed to `lake`. +Choose GameServer dependency depending on whether `-Kleangame.local` or `-Kleangame.testgame` has been passed to `lake`. -/ open Lean in #eval (do - let gameServerName := if get_config? lean4game.local |>.isSome then - ``LocalGameServer else ``RemoteGameServer + let gameServerName := if get_config? leangame.testgame |>.isSome then + ``TestGameServer + else if get_config? leangame.local |>.isSome then + ``LocalGameServer + else + ``RemoteGameServer modifyEnv (fun env => Lake.packageDepAttr.ext.addEntry env gameServerName) : Elab.Command.CommandElabM Unit) -/-! -# USER DEPENDENCIES - -Add any further dependencies of your game below. - -Note: If your package (like `mathlib` or `Std`) has tags of the form `v4.X.0` then -you can use - -``` -require "leanprover-community" / mathlib @ git leanVersion -``` - -/ - -/- -CSlib supplies the computer-science abstractions this game teaches: deterministic automata, -labelled transition systems with executions, simulation/bisimulation, and verified sorting. -CSlib publishes a tag `v4.X.0` for each Lean release, so `leanVersion` pins it to the same -release as the toolchain and the GameServer. CSlib pulls in Mathlib at the matching tag. --/ +-- Game-specific dependencies (preserved during the GameSkeleton migration). require "leanprover" / cslib @ git leanVersion -/-! -# PACKAGE CONFIGURATION - -Here you can set options used in your game. The player will use the same options as you'll -have set here. - -NOTE: The `leanOptions` and `moreServerOptions` influence how the player preceives the game. -For example, it is important to have `linter.all` set to `false` to prevent any linter -warnings from showing up during playing. - -NOTE: We abuse the `trace.debug` option to toggle messages in VSCode on and -off when calling `lake build`. Ideally there would be a better way using `logInfo` and -an option like `lean4game.verbose`. --/ package Game where /- Used in all cases. -/ leanOptions := #[ diff --git a/lean-toolchain b/lean-toolchain index d87704e..a6aff06 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1 +1 @@ -leanprover/lean4:v4.35.0 \ No newline at end of file +leanprover/lean4:v4.35.0 diff --git a/sofi.sh b/sofi.sh old mode 100755 new mode 100644 From f7a8e0922820790f3e73569df806946db5588351 Mon Sep 17 00:00:00 2001 From: Jon Eugster Date: Sat, 21 Nov 2026 02:50:17 +0100 Subject: [PATCH 2/2] bump gameserver --- .devcontainer/post-create.sh | 1 - .github/workflows/build.yml | 1 - .github/workflows/build_non_main.yml | 1 - .i18n/en/Game.pot | 4 +- lake-manifest.json | 34 ++++++++-------- lakefile.lean | 60 ++++++++++++++++++++++++++-- lean-toolchain | 2 +- 7 files changed, 76 insertions(+), 27 deletions(-) diff --git a/.devcontainer/post-create.sh b/.devcontainer/post-create.sh index 16464f7..75ef9bf 100755 --- a/.devcontainer/post-create.sh +++ b/.devcontainer/post-create.sh @@ -17,4 +17,3 @@ if ! lake exe cache get; then fi lake build -lake build GameServer diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 54a4403..6b26e57 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,7 +26,6 @@ jobs: - name: build game run: | lake build - lake build GameServer # The Lean server loads all `.ilean` files into RAM, which the game server does not need. # Lake only needs the files to exist, otherwise it considers the game as not built. diff --git a/.github/workflows/build_non_main.yml b/.github/workflows/build_non_main.yml index 58d7e4d..65e3f6a 100644 --- a/.github/workflows/build_non_main.yml +++ b/.github/workflows/build_non_main.yml @@ -27,4 +27,3 @@ jobs: - name: build game run: | lake build - lake build GameServer diff --git a/.i18n/en/Game.pot b/.i18n/en/Game.pot index 224eae8..986de62 100644 --- a/.i18n/en/Game.pot +++ b/.i18n/en/Game.pot @@ -1,7 +1,7 @@ msgid "" -msgstr "Project-Id-Version: Game v4.35.0\n" +msgstr "Project-Id-Version: Game v4.36.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-11-15\n" +"POT-Creation-Date: 2026-11-21\n" "Last-Translator: \n" "Language-Team: none\n" "Language: en\n" diff --git a/lake-manifest.json b/lake-manifest.json index 69fc413..c40eac6 100644 --- a/lake-manifest.json +++ b/lake-manifest.json @@ -5,37 +5,37 @@ "type": "git", "subDir": null, "scope": "leanprover", - "rev": "5b56df99362532c46e1175381fbbdd755bd56030", + "rev": "22b39634cb3dc80d829683ad1f65c5680b722309", "name": "cslib", "manifestFile": "lake-manifest.json", - "inputRev": "v4.35.0", + "inputRev": "v4.36.0", "inherited": false, "configFile": "lakefile.toml"}, {"url": "https://github.com/hhu-adam/GameServer.git", "type": "git", "subDir": null, "scope": "hhu-adam", - "rev": "43fd5128c775ca2385727b9423cc2f7272d0c55e", + "rev": "8d7bd73afb67c560c277570e3f513a4a354a00e4", "name": "GameServer", "manifestFile": "lake-manifest.json", - "inputRev": "v4.35.0", + "inputRev": "v4.36.0", "inherited": false, "configFile": "lakefile.lean"}, {"url": "https://github.com/leanprover-community/mathlib4", "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "56a005855ea17e0b0958f73ec801ae140b0a1679", + "rev": "fc4f59e577feb1a4956671bc04ac18aaaf8cd842", "name": "mathlib", "manifestFile": "lake-manifest.json", - "inputRev": "v4.35.0", + "inputRev": "v4.36.0", "inherited": true, "configFile": "lakefile.lean"}, {"url": "https://github.com/leanprover-community/import-graph", "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "a41f0e9a4dea23188ea9cc1c41ac9f8bbafe0b93", + "rev": "8370c640afcd1cc3fb1cb9bf1560cc66eafee5e0", "name": "importGraph", "manifestFile": "lake-manifest.json", "inputRev": "main", @@ -45,17 +45,17 @@ "type": "git", "subDir": null, "scope": "hhu-adam", - "rev": "83015d7010f332c2e83bcf2f88c89eb06f9e1d7d", + "rev": "b932dae1f0872da19f53594ddb922fead0d7b793", "name": "i18n", "manifestFile": "lake-manifest.json", - "inputRev": "v4.35.0", + "inputRev": "v4.36.0", "inherited": true, "configFile": "lakefile.lean"}, {"url": "https://github.com/leanprover-community/batteries", "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "66e469188fe07963e5cf666c7d4433f45b8131c5", + "rev": "b4b25a3886a16daacaf6615c2eea7170a6e8f458", "name": "batteries", "manifestFile": "lake-manifest.json", "inputRev": "main", @@ -65,7 +65,7 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "dfa4f38190d07c37e315953e08b90fe2d95b3c24", + "rev": "054b228ce0ac61d767c6e71ba73a24728f191b72", "name": "plausible", "manifestFile": "lake-manifest.json", "inputRev": "main", @@ -75,7 +75,7 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "d6b4c7be5be75ec4917c873ac50c756dc1436372", + "rev": "4fb58e749ef3fc0395fe274f6cab70c2ea85f1c9", "name": "LeanSearchClient", "manifestFile": "lake-manifest.json", "inputRev": "main", @@ -85,7 +85,7 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "df72b022e558978a1c50264cfc4d7fec86fa8e04", + "rev": "2f0f3520daeac2d9310ff25b7a877a0e5cdaa203", "name": "proofwidgets", "manifestFile": "lake-manifest.json", "inputRev": "main", @@ -95,7 +95,7 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "4a174c490d8707121c4a9290800489f105d85e07", + "rev": "66ff77cf0c4c898799e4b94d14db55f7a02d0c5a", "name": "aesop", "manifestFile": "lake-manifest.json", "inputRev": "master", @@ -105,7 +105,7 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "dce0ad79c486cb1fb504af04f953c3466b0c6db8", + "rev": "ff055a2fcc835935e0ae607339b455a5f5896b4b", "name": "Qq", "manifestFile": "lake-manifest.json", "inputRev": "master", @@ -115,10 +115,10 @@ "type": "git", "subDir": null, "scope": "leanprover", - "rev": "c24fe6078c630e89b489bffe59b3e20ac30d12c8", + "rev": "50810f72af7618bee62fe9800dc26e806c188703", "name": "Cli", "manifestFile": "lake-manifest.json", - "inputRev": "v4.35.0", + "inputRev": "v4.36.0", "inherited": true, "configFile": "lakefile.toml"}], "name": "Game", diff --git a/lakefile.lean b/lakefile.lean index 8a61b5a..0693417 100644 --- a/lakefile.lean +++ b/lakefile.lean @@ -54,9 +54,35 @@ open Lean in modifyEnv (fun env => Lake.packageDepAttr.ext.addEntry env gameServerName) : Elab.Command.CommandElabM Unit) --- Game-specific dependencies (preserved during the GameSkeleton migration). +/-! +# USER DEPENDENCIES + +Add any further dependencies of your game below. + +Note: If your package (like `mathlib` or `Std`) has tags of the form `v4.X.0` then +you can use + +``` +require "leanprover-community" / mathlib @ git leanVersion +``` + -/ + require "leanprover" / cslib @ git leanVersion +/-! +# PACKAGE CONFIGURATION + +Here you can set options used in your game. The player will use the same options as you'll +have set here. + +NOTE: The `leanOptions` and `moreServerOptions` influence how the player preceives the game. +For example, it is important to have `linter.all` set to `false` to prevent any linter +warnings from showing up during playing. + +NOTE: We abuse the `trace.debug` option to toggle messages in VSCode on and +off when calling `lake build`. Ideally there would be a better way using `logInfo` and +an option like `leangame.verbose`. +-/ package Game where /- Used in all cases. -/ leanOptions := #[ @@ -68,12 +94,38 @@ package Game where ⟨`tactic.hygienic, false⟩] /- Used when calling `lake build`. -/ moreLeanArgs := #[ - -- TODO: replace with `lean4game.verbose` + -- TODO: replace with `leangame.verbose` "-Dtrace.debug=false"] /- Used when opening a file in VSCode or when playing the game. -/ moreServerOptions := #[ - -- TODO: replace with `lean4game.verbose` + -- TODO: replace with `leangame.verbose` ⟨`trace.debug, true⟩] +/-- Non-Lean build targets: if the content of `images/` or `.i18n/config.json` changed, +then we need to force `lake` to rebuild instead of replay. -/ +target makeGameInputs pkg : Unit := do + let imagesDir := pkg.dir / "images" + let imagesJob ← if ← imagesDir.isDir then + inputDir imagesDir (text := false) (fun _ => true) + else + pure (Job.pure #[]) + + let i18nConfig := pkg.dir / ".i18n" / "config.json" + let configJob ← if ← i18nConfig.pathExists then + inputTextFile i18nConfig + else + pure (Job.pure i18nConfig) + + return imagesJob.mix configJob + +/-- Note: changes to any target in `needs` cause the entire game to be rebuilt. -/ @[default_target] -lean_lib Game +lean_lib Game where + needs := #[ + /- The library `GameServer` is not imported by the game, but needed to run it. -/ + `@GameServer/GameServer, -- built the GameServer library, too + `@/makeGameInputs] -- ensure non-Lean inputs are up to date + +-- @[test_driver] +-- lean_lib test where +-- globs := #[.submodules `Test] diff --git a/lean-toolchain b/lean-toolchain index a6aff06..00f8483 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1 +1 @@ -leanprover/lean4:v4.35.0 +leanprover/lean4:v4.36.0