Skip to content
Merged
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
4,522 changes: 4,522 additions & 0 deletions .github/scripts/chain_feed.py

Large diffs are not rendered by default.

53 changes: 52 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,26 @@ on:
push:
branches: [main]
pull_request:
# Chain leg contract (ai-game-dev-software `.scripts/chain/leg/chain_feed.py` §C1-C5, node `code-exec`):
# a release-train / chain run dispatches this workflow with the lock; on every other event each chain step is a
# no-op. A plain dispatch (no lock) still runs the whole CI.
workflow_dispatch:
inputs:
lock:
description: the chain lock JSON (<= 60000 characters)
required: false
default: ""
type: string
lock_hash8:
description: first 8 hex characters of the lock hash
required: false
default: ""
type: string

run-name: ${{ github.event_name == 'workflow_dispatch' && inputs.lock_hash8 != '' && format('chain {0} code-exec', inputs.lock_hash8) || '' }}

concurrency:
group: ci-${{ github.ref }}
group: ${{ github.event_name == 'workflow_dispatch' && inputs.lock_hash8 != '' && format('chain-{0}-{1}', inputs.lock_hash8, github.workflow) || format('ci-{0}', github.ref) }}
cancel-in-progress: false

permissions:
Expand All @@ -16,6 +32,8 @@ permissions:
env:
DOTNET_CLI_TELEMETRY_OPTOUT: "1"
DOTNET_NOLOGO: "1"
CHAIN_LOCK: ${{ inputs.lock }}
CHAIN_LOCK_HASH8: ${{ inputs.lock_hash8 }}

jobs:
# The adapter ships as SOURCE and compiles against the consumer's Roslyn: test the same source on every
Expand Down Expand Up @@ -57,6 +75,9 @@ jobs:
- name: Test (net48)
run: dotnet test dotnet/CodeExec.Tests/CodeExec.Tests.csproj -c Release -f net48 -p:IncludeNetFx=true -p:RoslynVersion=${{ matrix.roslyn }}

# The chain leg (manifest `legs:` of node `code-exec`): on a chain dispatch this job also packs both packages at the
# lock's ws version into .artifacts/nuget, where `record` proves them (the Core's assembly ProductVersion, the
# source-only adapter's nuspec version). Consumer legs self-build Code-Exec from the lock sha; nothing is uploaded.
package:
name: pack + strict consumer
runs-on: ubuntu-latest
Expand All @@ -68,6 +89,23 @@ jobs:
dotnet-version: |
8.0.x
10.0.x
- name: chain python (posix)
if: always() && env.CHAIN_PY == ''
shell: bash
run: |
for c in python3 python; do
exe="$("$c" -c 'import sys, select, socket, ssl, zlib, ctypes, hashlib; sys.version_info >= (3, 9) or sys.exit(1); print(sys.executable.replace(chr(92), chr(47)))' 2>/dev/null)" || continue
case "$exe" in /*) ;; *) continue ;; esac
case "$exe" in *[[:space:]]*) continue ;; esac
[ -f "$exe" ] && [ -x "$exe" ] || continue
echo "CHAIN_PY=$exe" >> "$GITHUB_ENV"; exit 0
done
echo 'chain: no Python 3.9+ on PATH that runs and reports an absolute, space-free sys.executable (tried python3, python)' >&2; exit 2
# Chain feed (§C4): asserts this run is at the lock's sha and exports CHAIN_BUILD_PROPS (-p:Version=<ws>) +
# CHAIN_WS_VERSION + CHAIN_ACTIVE. Code-Exec is a root: no lower layers to build.
- name: chain feed
id: chain
run: ${{ env.CHAIN_PY }} .github/scripts/chain_feed.py apply --node code-exec --job package
- name: Pack and check the packages' shape
run: scripts/pack.sh packages
- name: "Compile Core + adapter as source (C# 9, netstandard2.0, as Unity vendors them)"
Expand All @@ -77,6 +115,19 @@ jobs:
done
- name: Consume the packages (Roslyn 3.8.0 and 5.9.0)
run: scripts/consume.sh 3.8.0 5.9.0
- name: Pack at the lock's ws version (chain)
if: env.CHAIN_ACTIVE == '1'
run: scripts/pack.sh .artifacts/nuget ${{ env.CHAIN_BUILD_PROPS }}
- name: chain leg record
id: chain_record
if: always()
run: ${{ env.CHAIN_PY }} .github/scripts/chain_feed.py record --node code-exec --job package --job-status ${{ job.status }} --out chain-leg.json
- name: chain leg artifact
if: always() && steps.chain_record.outputs.artifact_name != ''
uses: actions/upload-artifact@v7
with:
name: ${{ steps.chain_record.outputs.artifact_name }}
path: chain-leg.json

python:
name: python ${{ matrix.python }}
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
name: Release

# Releases ONLY by a manual dispatch (as RQL / ReflectorNet / McpPlugin). Merging a version bump to `main` publishes nothing.
# Releases ONLY through the workspace release train (`python .scripts/chain.py train release` in ai-game-dev-software,
# node `code-exec`), which dispatches this workflow on main like every other internal package, after bumping the
# version and moving every consumer (Godot-MCP and Brutal-MCP pins, the sources Unity-MCP and Unreal-MCP vendor).
# Never dispatch it with dry_run=false by hand. Merging a version bump to `main` publishes nothing.
# Order: guard -> pack + package checks + version checks -> full test suite -> NuGet publish of BOTH packages (Trusted
# Publishing) -> verify both are live -> tag nuget-v<version> + GitHub Release. The tag is created only after the
# packages are live, so re-dispatching the same commit after a failed publish / verify is always possible
# (--skip-duplicate); a version already live from another commit fails the run.
#
# gh workflow run release.yml -R IvanMurzak/Code-Exec --ref main -f dry_run=true
# gh workflow run release.yml -R IvanMurzak/Code-Exec --ref main -f dry_run=false
# gh workflow run release.yml -R IvanMurzak/Code-Exec --ref main -f dry_run=true # a rehearsal; publishes nothing
#
# NuGet Trusted Publishing: nuget.org account IvanMurzak needs a policy for repository IvanMurzak/Code-Exec, workflow
# release.yml, covering com.IvanMurzak.CodeExec and com.IvanMurzak.CodeExec.Roslyn.
Expand Down
9 changes: 7 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@ Unity, Godot, Unreal, MCP, ReflectorNet or any hosted service — hosts plug in
Every new Roslyn API needs a check that it exists in 3.8.
4. The value converter runs before an unloadable snippet is released; nothing of the snippet's own types may escape.
5. Python stays standard-library-only and Python 3.10 compatible (Unreal bundles 3.11).
6. Publishing: only `com.IvanMurzak.CodeExec` and `com.IvanMurzak.CodeExec.Roslyn` to NuGet, only by dispatching
`.github/workflows/release.yml` (Trusted Publishing, no API key), only when the owner asks. No other publishing.
6. Publishing: only `com.IvanMurzak.CodeExec` and `com.IvanMurzak.CodeExec.Roslyn` to NuGet, and only through the
workspace release train (`python .scripts/chain.py train create|review|release` in ai-game-dev-software, node
`code-exec`), which bumps the version, re-pins Godot-MCP and Brutal-MCP, re-vendors the sources into Unity-MCP and
Unreal-MCP, and dispatches `.github/workflows/release.yml` (Trusted Publishing, no API key). Never dispatch it with
`dry_run=false` by hand: a manual release leaves the consumers on the old version. No other publishing.
7. `.github/scripts/chain_feed.py` is vendored from ai-game-dev-software (`chain.py feed vendor`): never edit it here.
`ci.yml`'s `package` job is this repo's chain leg; `scripts/pack.sh <dir> -p:Version=<v>` packs at a given version.

## Commands
- Everything: `scripts/test-all.sh` (`ROSLYN_VERSIONS="3.8.0 5.9.0"` for several Roslyn lines).
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ scripts/pack.sh # pack + package shape chec
python3 scripts/readme-assets.py # regenerate the README art in docs/assets/
```

Releases: [`.github/workflows/release.yml`](.github/workflows/release.yml), dispatch only.
Releases: [`.github/workflows/release.yml`](.github/workflows/release.yml), dispatched only by the ai-game-dev release train.

## Documentation

Expand Down
2 changes: 1 addition & 1 deletion python/code_exec/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@

__all__ = ["run", "run_json", "run_b64", "set_value_converter", "set_default_timeout_ms", "set_max_timeout_ms",
"set_max_recursion_limit", "SnippetTimeout", "SnippetThreadStopped", "SNIPPET_FILE"]
__version__ = "0.4.0"
__version__ = "0.4.1"
11 changes: 11 additions & 0 deletions python/tests/test_code_exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@
INCLUDE_ROOT = os.path.join(ROOT, GOLDEN["includeRoot"])


class VersionTests(unittest.TestCase):
def test_the_python_version_is_the_package_version(self):
"""One version for the whole release: the release train bumps dotnet/Directory.Build.props and this
`__version__` together (its `lockstep`), and Unreal-MCP vendors this file."""
import re

with open(os.path.join(ROOT, "dotnet", "Directory.Build.props"), encoding="utf-8") as handle:
props = re.search(r"<Version>\s*([^<\s]+)\s*</Version>", handle.read()).group(1)
self.assertEqual(code_exec.__version__, props)


class GoldenTests(unittest.TestCase):
def test_golden(self):
for case in GOLDEN["cases"]:
Expand Down
10 changes: 8 additions & 2 deletions scripts/pack.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
#!/usr/bin/env bash
# Packs com.IvanMurzak.CodeExec + com.IvanMurzak.CodeExec.Roslyn into $1 (default: ./packages) and checks the
# source-only package's shape. Prints the version on stdout. Publishes nothing.
# scripts/pack.sh [out-dir] [msbuild args...] e.g. -p:Version=0.4.1-ws.g0123abcd (a release-train chain leg)
set -euo pipefail
root="$(cd "$(dirname "$0")/.." && pwd)"
out="${1:-$root/packages}"
[ $# -gt 0 ] && shift
props=("$@")
mkdir -p "$out"
dotnet pack "$root/dotnet/CodeExec/CodeExec.csproj" -c Release -o "$out" >&2
dotnet pack "$root/dotnet/CodeExec.Roslyn/CodeExec.Roslyn.csproj" -c Release -o "$out" >&2
dotnet pack "$root/dotnet/CodeExec/CodeExec.csproj" -c Release -o "$out" ${props[@]+"${props[@]}"} >&2
dotnet pack "$root/dotnet/CodeExec.Roslyn/CodeExec.Roslyn.csproj" -c Release -o "$out" ${props[@]+"${props[@]}"} >&2
version="$(sed -n 's:.*<Version>\(.*\)</Version>.*:\1:p' "$root/dotnet/Directory.Build.props")"
for arg in ${props[@]+"${props[@]}"}; do
case "$arg" in -p:Version=*) version="${arg#-p:Version=}" ;; esac
done
roslyn="$out/com.IvanMurzak.CodeExec.Roslyn.$version.nupkg"
listing="$(unzip -l "$roslyn")"
for f in src/RoslynCSharpCompiler.cs src/SnippetWriter.cs src/GuardWriter.cs build/com.IvanMurzak.CodeExec.Roslyn.props LICENSE.md; do
Expand Down
Loading