Skip to content

A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.

repo: a devcontainer for the headless checks (fixes #262) (#275)

Guy Shoham5a6582444765
diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile
new file mode 100644
index 000000000..88d7403b8
--- /dev/null
+++ b/.devcontainer/Dockerfile
@@ -0,0 +1,7 @@
+# Base image: Ubuntu 24.04, the same OS as the CI runner (ubuntu-24.04 in .github/workflows/ci.yml). Pinned by version
+# and digest; bump it by hand.
+FROM mcr.microsoft.com/devcontainers/base:3.0.8-ubuntu24.04@sha256:d7c468679f45a52ad3673d06656b5bf16e488990b17216a1fa295d9e1f89d724
+
+# uv 0.12.5 is the version CI uses (astral-sh/setup-uv, `version:` in .github/workflows/ci.yml).
+# Keep this tag equal to that value, and change both together.
+COPY --from=ghcr.io/astral-sh/uv:0.12.5@sha256:e85be844203885286c60ffad8a858d48afb6c5a5c237ca0e67f12e74b8f174b1 /uv /uvx /usr/local/bin/
diff --git a/.devcontainer/README.md b/.devcontainer/README.md
new file mode 100644
index 000000000..92f2b7ee4
--- /dev/null
+++ b/.devcontainer/README.md
@@ -0,0 +1,30 @@
+# Dev container
+
+This container runs the headless checks in a clean Linux environment, for example in a GitHub Codespace
+or for a coding agent. It has no Unity. Unity work (`unity/`, builds, edit-mode tests) needs a local machine.
+
+## What it holds
+
+| Tool | Version | Where the version comes from |
+| --- | --- | --- |
+| .NET SDK | 10.0.401 | `dotnet-version` in `.github/workflows/ci.yml`. The sim targets `net10.0`. There is no `global.json`. |
+| uv | 0.12.5 | `version` of `astral-sh/setup-uv` in `.github/workflows/ci.yml` |
+| Python | 3.12 | Ubuntu 24.04's own `python3`, as on the `ubuntu-24.04` CI runner, and `UV_PYTHON` in `.github/workflows/ci.yml`. The scripts need `>=3.11`. |
+| OS | Ubuntu 24.04 (`devcontainers/base` 3.0.8) | `runs-on: ubuntu-24.04` in `.github/workflows/ci.yml` |
+| git | from the base image | |
+
+When CI changes one of these versions, change it here too. The base image and the uv image are pinned by version and digest and are bumped by hand. Dependabot bumps the features.
+
+`postCreateCommand` runs `dotnet restore sim/Statecraft.sln`.
+
+The container has an SSH server, so `gh codespace ssh -c <name>` can run the checks.
+
+## Run the checks
+
+```bash
+dotnet test sim/Statecraft.sln -c Release
+uv run scripts/oss/check_repo.py
+uv run --with pytest==9.1.1 --with pyyaml==6.0.3 --with requests==2.32.5 pytest scripts/oss/tests -q
+```
+
+The data tool tests (`tools/tests`) run in CI too. See `.github/workflows/ci.yml` for the full command.
diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
new file mode 100644
index 000000000..9c239ff08
--- /dev/null
+++ b/.devcontainer/devcontainer.json
@@ -0,0 +1,28 @@
+// Headless checks only: the sim tests and the repo policy checks. No Unity. See .devcontainer/README.md.
+{
+ "name": "Statecraft: Israel (headless checks)",
+ "build": { "dockerfile": "Dockerfile" },
+ "features": {
+ // .NET SDK 10.0.401: the `dotnet-version` in .github/workflows/ci.yml. The sim targets net10.0
+ // (sim/Statecraft.Sim and sim/Statecraft.Cli csproj files). There is no global.json, so CI is the source of truth.
+ "ghcr.io/devcontainers/features/dotnet:2.5.0": {
+ "version": "10.0.401"
+ },
+ // Python: Ubuntu 24.04's own python3 (3.12), the same one the ubuntu-24.04 runner CI uses. UV_PYTHON below is
+ // CI's value. Every script declares `requires-python = ">=3.11"`. uv runs the scripts, so no extra Python tools.
+ "ghcr.io/devcontainers/features/python:1.8.0": {
+ "version": "os-provided",
+ "installTools": false
+ },
+ // SSH server: `gh codespace ssh` needs it, so agents and CLI users can run the headless checks.
+ "ghcr.io/devcontainers/features/sshd:1.1.0": {}
+ },
+ // git comes with the base image. uv 0.12.5 is installed in the Dockerfile.
+ // Restore the solution so `dotnet test` starts from a warm cache.
+ "postCreateCommand": "dotnet restore sim/Statecraft.sln",
+ "remoteEnv": {
+ "DOTNET_CLI_TELEMETRY_OPTOUT": "1",
+ "DOTNET_NOLOGO": "1",
+ "UV_PYTHON": "3.12"
+ }
+}
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
index 4f18d7b55..0a4355c49 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -7,3 +7,11 @@ updates:
interval: weekly
commit-message:
prefix: "ci"
+ # Keeps the dev container features in .devcontainer/devcontainer.json current. The uv image is bumped by hand with
+ # CI's setup-uv version, so the two never differ.
+ - package-ecosystem: devcontainers
+ directory: /
+ schedule:
+ interval: weekly
+ commit-message:
+ prefix: "repo"
diff --git a/docs/dev-setup.md b/docs/dev-setup.md
index ba3bf52a4..fdbff41bb 100644
--- a/docs/dev-setup.md
+++ b/docs/dev-setup.md
@@ -14,7 +14,7 @@
## Without Unity (Linux, a container, a sandbox)
-Unity, a Unity licence and macOS are only needed for `unity/`. The sim, the content and the policy checks run headless. These are the commands CI runs (`.github/workflows/ci.yml`), with the .NET SDK 10.0.401 and `uv`:
+Unity, a Unity licence and macOS are only needed for `unity/`. The sim, the content and the policy checks run headless, also in the dev container (`.devcontainer/README.md`, for a local container or a Codespace). These are the commands CI runs (`.github/workflows/ci.yml`), with the .NET SDK 10.0.401 and `uv`:
| Check | Command | CI job |
|---|---|---|