Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 15 additions & 23 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -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}"
9 changes: 9 additions & 0 deletions .devcontainer/devcontainer-lock.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
47 changes: 33 additions & 14 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -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"
}
19 changes: 19 additions & 0 deletions .devcontainer/post-create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/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
20 changes: 20 additions & 0 deletions .devcontainer/start-server.sh
Original file line number Diff line number Diff line change
@@ -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
63 changes: 22 additions & 41 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,63 +4,44 @@ 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 '<details><summary>%s</summary>\n\n```text\n' "$f"
cat "$f"
printf '\n```\n</details>\n\n'
done >> "$GITHUB_STEP_SUMMARY"
lake build

- 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,,}"
40 changes: 15 additions & 25 deletions .github/workflows/build_non_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,25 @@ 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 '<details><summary>%s</summary>\n\n```text\n' "$f"
cat "$f"
printf '\n```\n</details>\n\n'
done >> "$GITHUB_STEP_SUMMARY"
lake build
17 changes: 4 additions & 13 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
16 changes: 2 additions & 14 deletions .i18n/en/Game.pot
Original file line number Diff line number Diff line change
@@ -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-10-31\n"
"POT-Creation-Date: 2026-11-21\n"
"Last-Translator: \n"
"Language-Team: none\n"
"Language: en\n"
Expand All @@ -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`
Expand Down
2 changes: 1 addition & 1 deletion Game/Doc/Definitions.lean
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import GameServer
import GameApi
import Game.Machines

/-!
Expand Down
2 changes: 1 addition & 1 deletion Game/Doc/Tactics.lean
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import GameServer
import GameApi

/-!
# Tactic documentation
Expand Down
2 changes: 1 addition & 1 deletion Game/Doc/Theorems.lean
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import GameServer
import GameApi
import Game.Machines

/-!
Expand Down
2 changes: 1 addition & 1 deletion Game/Metadata.lean
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import GameServer
import GameApi
import Game.Machines
import Game.Doc.Tactics
import Game.Doc.Definitions
Expand Down
Loading