Aggregate errors
This commit is contained in:
parent
3bd942d471
commit
c3e881d52b
29
build.py
29
build.py
@ -10,8 +10,10 @@ import argparse
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
ReleaseType = Literal["release", "snapshot", "old_beta", "old_alpha"]
|
||||
DockerPlatforms = Literal["linux/amd64", "linux/amd64/v2", "linux/amd64/v3", "linux/arm64", "linux/riscv64", "linux/ppc64le", "linux/s390x", "linux/386", "linux/mips64le", "linux/mips64", "linux/arm/v7", "linux/arm/v6"]
|
||||
supported_docker_platforms: list[DockerPlatforms] = ["linux/amd64", "linux/amd64/v2", "linux/amd64/v3", "linux/arm64", "linux/riscv64", "linux/ppc64le", "linux/s390x", "linux/386", "linux/mips64le", "linux/mips64", "linux/arm/v7", "linux/arm/v6"]
|
||||
DockerPlatforms = Literal["linux/amd64", "linux/amd64/v2", "linux/amd64/v3", "linux/arm64", "linux/riscv64",
|
||||
"linux/ppc64le", "linux/s390x", "linux/386", "linux/mips64le", "linux/mips64", "linux/arm/v7", "linux/arm/v6"]
|
||||
supported_docker_platforms: list[DockerPlatforms] = ["linux/amd64", "linux/amd64/v2", "linux/amd64/v3", "linux/arm64",
|
||||
"linux/riscv64", "linux/ppc64le", "linux/s390x", "linux/386", "linux/mips64le", "linux/mips64", "linux/arm/v7", "linux/arm/v6"]
|
||||
|
||||
|
||||
class LatestVersions(TypedDict):
|
||||
@ -152,9 +154,11 @@ default_java_version: JavaVersion = {
|
||||
"majorVersion": 8
|
||||
}
|
||||
|
||||
|
||||
class NoServerException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
def build_version(manifest: VersionManifest, version_id: str, repository: str = "hub.cnml.de/minecraft"):
|
||||
matching_version = list(
|
||||
filter(lambda v: v["id"] == version_id, manifest["versions"]))
|
||||
@ -167,7 +171,8 @@ def build_version(manifest: VersionManifest, version_id: str, repository: str =
|
||||
server_jar_file = Path("versions") / version['id'] / "server.jar"
|
||||
server_jar = version["downloads"].get("server")
|
||||
if server_jar is None:
|
||||
raise NoServerException(f"No server build exists for {version['id']} (Java {java_version['majorVersion']})")
|
||||
raise NoServerException(
|
||||
f"No server build exists for {version['id']} (Java {java_version['majorVersion']})")
|
||||
|
||||
download_file(server_jar, server_jar_file)
|
||||
|
||||
@ -177,19 +182,23 @@ def build_version(manifest: VersionManifest, version_id: str, repository: str =
|
||||
"DOCKER_IMAGE": ""
|
||||
}
|
||||
|
||||
print(f"Building version {version['id']} (Java {java_version['majorVersion']})")
|
||||
print(
|
||||
f"Building version {version['id']} (Java {java_version['majorVersion']})")
|
||||
|
||||
# Build GraalVM images
|
||||
if java_version['majorVersion'] == 17:
|
||||
graal_platforms: list[DockerPlatforms] = ["linux/arm64", "linux/amd64"]
|
||||
build_args["DOCKER_IMAGE"] = f"ghcr.io/graalvm/jdk:java{java_version['majorVersion']}"
|
||||
docker_buildx(repository, [f"{version['id']}-graalvm"], graal_platforms, build_args=build_args)
|
||||
docker_buildx(repository, [
|
||||
f"{version['id']}-graalvm"], graal_platforms, build_args=build_args)
|
||||
else:
|
||||
print(f"No GraalVM image can be built for {version['id']} (Java {java_version['majorVersion']})")
|
||||
print(
|
||||
f"No GraalVM image can be built for {version['id']} (Java {java_version['majorVersion']})")
|
||||
|
||||
# Build Temurin
|
||||
build_args["DOCKER_IMAGE"] = f"eclipse-temurin:{java_version['majorVersion']}-jre"
|
||||
temurin_platforms: list[DockerPlatforms] = ["linux/arm64", "linux/arm/v7", "linux/amd64", "linux/ppc64le"]
|
||||
temurin_platforms: list[DockerPlatforms] = [
|
||||
"linux/arm64", "linux/arm/v7", "linux/amd64", "linux/ppc64le"]
|
||||
docker_buildx(
|
||||
repository, [version["id"], f"{version['id']}-temurin"], temurin_platforms, build_args=build_args)
|
||||
|
||||
@ -209,15 +218,21 @@ if __name__ == "__main__":
|
||||
manifest = load_manifest(args.reload)
|
||||
versions: list[str] = list(version["id"] for version in manifest["versions"]
|
||||
if version["type"] == "release") if args.all else args.versions
|
||||
|
||||
errors: list[tuple[str, Exception]] = []
|
||||
for version_id in versions:
|
||||
print()
|
||||
try:
|
||||
build_version(manifest, version_id)
|
||||
except NoServerException as e:
|
||||
print(e)
|
||||
errors.append((version_id, e))
|
||||
except Exception as e:
|
||||
print(f"Failed building images for version {version_id}")
|
||||
if args.force:
|
||||
print(e)
|
||||
errors.append((version_id, e))
|
||||
else:
|
||||
raise
|
||||
for (version_id, e) in errors:
|
||||
print(f"Error building version {version_id}:\n\t{e}")
|
Loading…
Reference in New Issue
Block a user