Archive incari-client (client, 26.3, clean)

This commit is contained in:
2026-11-28 00:54:38 -06:00
parent 7a6174687f
commit 12838e838c
2383 changed files with 280266 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
# Fails if any commit in <base>..<head> lacks a Developer Certificate of Origin sign-off.
# Usage: tools/ci/check-dco.sh <base> <head>
set -euo pipefail
base=$1
head=$2
missing=0
for commit in $(git rev-list --no-merges "$base..$head"); do
author_email=$(git log -1 --format='%ae' "$commit")
if ! git log -1 --format='%(trailers:key=Signed-off-by,valueonly)' "$commit" | grep -qiF "<$author_email>"; then
echo "missing sign-off by its author: $(git log -1 --format='%h %s' "$commit")" >&2
missing=1
fi
done
if [ "$missing" -ne 0 ]; then
echo >&2
echo "Every commit needs 'Signed-off-by: Name <author email>' (git commit -s). See CONTRIBUTING.md." >&2
echo "To sign off existing commits: git rebase --signoff $base" >&2
exit 1
fi
echo "DCO check passed."
@@ -0,0 +1,34 @@
#!/usr/bin/env bash
# Validates every GLSL shader Incari tracks with glslang. Incari shaders are named by stage
# (.vert, .frag, .comp) so glslang never has to guess; shared .glsl includes are checked through
# the shaders that include them. Translated GLSL ES output is validated where it's generated, in
# the render-webgl2 build.
set -euo pipefail
cd "$(git rev-parse --show-toplevel)"
shaders=$(git ls-files --cached --others --exclude-standard -- '*.vert' '*.frag' '*.comp' | grep -v '^work/' || true)
if [ -z "$shaders" ]; then
echo "GLSL check passed: no Incari shaders yet."
exit 0
fi
if ! command -v glslangValidator >/dev/null; then
echo "glslangValidator is needed to check shaders (package: glslang)." >&2
exit 1
fi
failed=0
count=0
while IFS= read -r shader; do
count=$((count + 1))
if ! output=$(glslangValidator "$shader" 2>&1); then
echo "$output" >&2
failed=1
fi
done <<< "$shaders"
if [ "$failed" -ne 0 ]; then
exit 1
fi
echo "GLSL check passed: $count shaders valid."
@@ -0,0 +1,52 @@
#!/usr/bin/env bash
# Fails if a library pin in gradle/libs.versions.toml that must match Minecraft's version JSON
# doesn't. Incari compiles against these jars and the game runs with Mojang's copies, so after a
# Minecraft bump they have to move with it (docs/updating.md). Needs ./incari fetch first.
set -euo pipefail
cd "$(git rev-parse --show-toplevel)"
version=$(sed -n 's/^minecraft\.version=//p' incari.properties | tr -d '[:space:]')
json="work/cache/versions/${version}/${version}.json"
if [ ! -f "$json" ]; then
echo "No ${json}. Run ./incari fetch first." >&2
exit 1
fi
# <libs.versions.toml key> <Maven group:artifact in the version JSON>
python3 -I - "$json" gradle/libs.versions.toml <<'EOF'
import json, re, sys
pins = {
"lwjgl": "org.lwjgl:lwjgl",
"guava": "com.google.guava:guava",
"gson": "com.google.code.gson:gson",
}
with open(sys.argv[1]) as f:
mojang = {}
for lib in json.load(f)["libraries"]:
parts = lib["name"].split(":")
if len(parts) == 3:
mojang[parts[0] + ":" + parts[1]] = parts[2]
with open(sys.argv[2]) as f:
toml = f.read()
section = toml.split("[versions]", 1)[1].split("\n[", 1)[0]
ours = dict(re.findall(r'^([\w-]+)\s*=\s*"([^"]+)"', section, re.M))
bad = []
for key, coordinate in pins.items():
want = mojang.get(coordinate)
have = ours.get(key)
if want is None:
bad.append(f"{coordinate} is no longer in Minecraft's version JSON (libs.versions.toml: {key} = {have})")
elif have != want:
bad.append(f'{key} = "{have}" in gradle/libs.versions.toml, but Minecraft ships {coordinate}:{want}')
if bad:
print("\n".join(bad))
print("Move these pins to Minecraft's versions (see their comments in gradle/libs.versions.toml).", file=sys.stderr)
sys.exit(1)
print("Library pins match Minecraft's version JSON: " + ", ".join(f"{k} {ours[k]}" for k in pins))
EOF
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
# Fails if any workflow could publish a build. Every Incari build contains Mojang code, so CI
# may compile and test, but must never upload artifacts, cut releases or deploy pages.
set -euo pipefail
cd "$(git rev-parse --show-toplevel)"
workflows=$(git ls-files '.github/workflows/*.yml' '.github/workflows/*.yaml')
if [ -z "$workflows" ]; then
echo "No workflows to check."
exit 0
fi
# The pattern is spelled out in pieces so this script doesn't flag its own workflow file.
forbidden='actions/upload-''artifact|actions/upload-pages-''artifact|actions/deploy-''pages|action-gh-''release|gh release (create|upload)|(contents|packages|pages|deployments|id-token): *write'
# shellcheck disable=SC2086
if matches=$(grep -nE "$forbidden" $workflows); then
echo "Workflows must never publish builds or request write access (CONTRIBUTING.md):" >&2
echo "$matches" >&2
exit 1
fi
echo "Publishing check passed: no workflow uploads, releases or deploys."
@@ -0,0 +1,56 @@
#!/usr/bin/env bash
# Reports the size of Incari's changes to vendor code and fails if it grows past
# patches/budget.properties. Every vendor line touched is rebase cost on the next Minecraft drop,
# and every context line is Mojang text in the repo, so growth has to be deliberate: raise the
# budget in the same pull request and say why.
set -euo pipefail
cd "$(git rev-parse --show-toplevel)"
budget=patches/budget.properties
read_budget() {
grep -E "^$1=" "$budget" | cut -d= -f2 | tr -d '[:space:]'
}
patches=$(git ls-files --cached --others --exclude-standard -- 'patches/*.patch' 'patches/**/*.patch')
patch_count=0
changed=0
context=0
if [ -n "$patches" ]; then
patch_count=$(echo "$patches" | wc -l)
# Inside hunks: "+"/"-" lines are changes, " " lines are vendor context.
read -r changed context < <(echo "$patches" | xargs awk '
/^@@ / { in_hunk = 1; next }
/^diff --git / { in_hunk = 0; next }
in_hunk && /^[-+]/ { changed++ }
in_hunk && /^ / { context++ }
END { print changed + 0, context + 0 }')
fi
replaced=$(grep -cE '^\s*replace\s' patches/classes.txt || true)
deleted=$(grep -cE '^\s*delete\s' patches/classes.txt || true)
echo "Patch budget:"
printf ' %-28s %6s / %s\n' "patch files" "$patch_count" "$(read_budget max.patches)"
printf ' %-28s %6s / %s\n' "changed lines (+/-)" "$changed" "$(read_budget max.changed.lines)"
printf ' %-28s %6s / %s\n' "vendor context lines" "$context" "$(read_budget max.context.lines)"
printf ' %-28s %6s\n' "classes deleted (manifest)" "$deleted"
printf ' %-28s %6s\n' "classes replaced (manifest)" "$replaced"
over=0
check() {
local name=$1 value=$2 limit
limit=$(read_budget "$name")
if [ "$value" -gt "$limit" ]; then
echo "Over budget: $name is $value, the budget is $limit." >&2
over=1
fi
}
check max.patches "$patch_count"
check max.changed.lines "$changed"
check max.context.lines "$context"
if [ "$over" -ne 0 ]; then
echo "Make the patches thinner (move logic into an Incari module), or raise $budget in this" >&2
echo "pull request and explain the growth in its description." >&2
exit 1
fi
@@ -0,0 +1,29 @@
#!/usr/bin/env bash
# Fails if git tracks anything that looks like Mojang content or a compiled build.
# The repo must stay patch-only (CONTRIBUTING.md); this is the mechanical half of that rule.
set -euo pipefail
cd "$(git rev-parse --show-toplevel)"
violations=$(git ls-files -z | tr '\0' '\n' | awk '
# The Gradle wrapper jar is the one jar allowed in the repo.
$0 == "gradle/wrapper/gradle-wrapper.jar" { next }
# Generated workspace: jars, decompiled source, patched tree.
/^work\// { print "generated workspace: " $0; next }
# Game code and compiled builds.
/\.(jar|class|wasm|wasm\.map|teavmdbg)$/ { print "binary or build: " $0; next }
# Game assets and data.
/(^|\/)assets\/minecraft\// { print "Minecraft assets: " $0; next }
/(^|\/)data\/minecraft\// { print "Minecraft data: " $0; next }
/\.(ogg|nbt|mca|mcmeta)$/ { print "game asset format: " $0; next }
# Mojang core shaders, translated copies included (Incari shaders use .vert/.frag/.comp).
/\.(vsh|fsh)$/ { print "Mojang shader format: " $0; next }
/(^|\/)shaders\/core\// { print "Mojang core shaders: " $0; next }
')
if [ -n "$violations" ]; then
echo "These tracked files must not be in the repo (see CONTRIBUTING.md):" >&2
echo "$violations" >&2
exit 1
fi
echo "Repo content check passed: no Mojang content or builds tracked."
@@ -0,0 +1,27 @@
#!/usr/bin/env bash
# Fails if a feature has no Rust status in features/README.md (ADR 0068): every features/<name>
# has a row there, and every row's last column says Ported, Not yet or Won't port. Keeps the Rust
# build's gaps written down as features are added.
set -euo pipefail
cd "$(git rev-parse --show-toplevel)"
table=features/README.md
problems=$(
# Tracked modules only: a renamed module can leave an ignored build/ folder behind.
for build in $(git ls-files 'features/*/build.gradle.kts'); do
name=$(basename "$(dirname "$build")")
grep -q "](${name}/README.md)" "$table" || echo "features/${name} has no row in ${table}"
done
awk -F'|' '/^\| \[/ {
status = $(NF - 1); gsub(/^ +| +$/, "", status)
if (status != "Ported" && status != "Not yet" && status != "Won'"'"'t port") print "no Rust status: " $0
}' "$table"
)
if [ -n "$problems" ]; then
echo "$problems"
echo "Give each feature a Rust column in ${table}: Ported, Not yet or Won't port." >&2
exit 1
fi
echo "Every feature has a Rust status."
@@ -0,0 +1,37 @@
#!/usr/bin/env bash
# Fails if shipped code spells out the pinned Minecraft version ("26.3") as a string literal.
# incari.properties is the one place it's written: Gradle reads it, and code takes it from the
# generated IncariBuild.MINECRAFT_VERSION or the game's SharedConstants. A literal left behind is a
# silent bug on the next version bump (docs/updating.md). Comments, tests and docs may name it.
set -euo pipefail
cd "$(git rev-parse --show-toplevel)"
version=$(sed -n 's/^minecraft\.version=//p' incari.properties | tr -d '[:space:]')
if [ -z "$version" ]; then
echo "No minecraft.version in incari.properties" >&2
exit 1
fi
# The version as a whole quoted string: "26.3" or '26.3', not "26.3.1" or "incari/26.3".
pattern="[\"']${version//./[.]}[\"']"
hits=$(
git ls-files -z -- '*.java' '*.kt' '*.kts' '*.ts' '*.js' '*.mjs' '*.rs' \
':!:**/src/test/**' ':!:**/tests/**' ':!:**/tests.rs' ':!:**/*.test.ts' ':!:patches/**' \
| xargs -0 -r awk -v pat="$pattern" '
{
line = $0
sub(/^[ \t]*\|/, "", line) # Kotlin trimMargin() templates
if (line ~ /^[ \t]*(\/\/|\/\*|\*|#)/) next # comment lines
if (line ~ pat) print FILENAME ":" FNR ": " $0
}'
)
if [ -n "$hits" ]; then
echo "$hits"
echo "Don't hard-code the Minecraft version ${version}: use IncariBuild.MINECRAFT_VERSION," >&2
echo "SharedConstants.getCurrentVersion(), or read incari.properties (Gradle)." >&2
exit 1
fi
echo "No hard-coded Minecraft version ${version} in shipped code."