This repository has been archived on 2026-11-08. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
platform-ci/tests/support.py
forge-recoveryandClaude Sonnet 5.5 fd4689fd19
KofTwentyTwo/ci-policy: ci / fork-guard (pull_request) Skipped
KofTwentyTwo/ci-policy: ci / go-0 (pull_request) Skipped
KofTwentyTwo/ci-policy: ci / go-nix-1 (pull_request) Skipped
KofTwentyTwo/ci-policy: ci / gradle-2 (pull_request) Skipped
KofTwentyTwo/ci-policy: ci / gradle-3 (pull_request) Skipped
KofTwentyTwo/ci-policy: ci / java-docker-4 (pull_request) Skipped
KofTwentyTwo/ci-policy: ci / java-maven-5 (pull_request) Skipped
KofTwentyTwo/ci-policy: ci / manifests-6 (pull_request) Skipped
KofTwentyTwo/ci-policy: ci / nix-7 (pull_request) Skipped
KofTwentyTwo/ci-policy: ci / node-8 (pull_request) Skipped
KofTwentyTwo/ci-policy: ci / python-9 (pull_request) Skipped
KofTwentyTwo/ci-policy: ci / rust-10 (pull_request) Skipped
KofTwentyTwo/ci-policy: ci / rust-11 (pull_request) Skipped
KofTwentyTwo/ci-policy: ci / rust-12 (pull_request) Skipped
KofTwentyTwo/ci-policy: ci / source-config-13 (pull_request) Skipped
KofTwentyTwo/ci-policy: ci / source-config-14 (pull_request) Skipped
KofTwentyTwo/ci-policy: ci / image-build-0 (pull_request) Skipped
KofTwentyTwo/ci-policy: ci / image-build-1 (pull_request) Skipped
KofTwentyTwo/ci-policy: ci / image-build-2 (pull_request) Skipped
KofTwentyTwo/ci-policy: ci / image-build-3 (pull_request) Skipped
KofTwentyTwo/ci-policy: ci / image-build-4 (pull_request) Skipped
KofTwentyTwo/ci-policy: ci / image-build-5 (pull_request) Skipped
KofTwentyTwo/ci-policy: ci / image-build-6 (pull_request) Skipped
KofTwentyTwo/ci-policy: ci / image-build-7 (pull_request) Skipped
KofTwentyTwo/ci-policy: ci / not-enrolled (pull_request) Skipped
KofTwentyTwo/ci-policy: ci / content-validate-0 (pull_request) Skipped
KofTwentyTwo/ci-policy: ci / standards-0 (pull_request) Skipped
KofTwentyTwo/ci-policy: ci / node-matrix-0 (pull_request) Skipped
KofTwentyTwo/ci-policy: ci / source-config-15 (pull_request) Blocked by required conditions
KofTwentyTwo/ci-policy: Shared source and config CI / verify (pull_request) Blocked by required conditions
KofTwentyTwo/ci-policy: Shared source and config CI / secrets (pull_request) Blocked by required conditions
KofTwentyTwo/ci-policy: Shared source and config CI / gate (pull_request) Waiting for needed jobs
KofTwentyTwo/ci-policy: ci / ci-result (pull_request) Waiting for needed jobs
KofTwentyTwo/ci-policy: native / fork-deny (pull_request) Skipped
KofTwentyTwo/ci-policy: native / build-macos-0 (pull_request) Skipped
KofTwentyTwo/ci-policy: native / build-macos-1 (pull_request) Skipped
KofTwentyTwo/ci-policy: native / build-macos-2 (pull_request) Skipped
KofTwentyTwo/ci-policy: native / build-macos-3 (pull_request) Skipped
KofTwentyTwo/ci-policy: native / build-windows-4 (pull_request) Skipped
KofTwentyTwo/ci-policy: native / build-windows-5 (pull_request) Skipped
KofTwentyTwo/ci-policy: native / build-windows-6 (pull_request) Skipped
KofTwentyTwo/ci-policy: native / build-windows-7 (pull_request) Skipped
KofTwentyTwo/ci-policy: native / dotnet-8 (pull_request) Skipped
KofTwentyTwo/ci-policy: native / dotnet-9 (pull_request) Skipped
KofTwentyTwo/ci-policy: native / dotnet-10 (pull_request) Skipped
KofTwentyTwo/ci-policy: native / dotnet-11 (pull_request) Skipped
KofTwentyTwo/ci-policy: native / swift-12 (pull_request) Skipped
KofTwentyTwo/ci-policy: native / swift-13 (pull_request) Skipped
KofTwentyTwo/ci-policy: native / swift-14 (pull_request) Skipped
KofTwentyTwo/ci-policy: native / swift-15 (pull_request) Skipped
KofTwentyTwo/ci-policy: native / swift-16 (pull_request) Skipped
KofTwentyTwo/ci-policy: native / swift-17 (pull_request) Skipped
KofTwentyTwo/ci-policy: native / swift-18 (pull_request) Skipped
KofTwentyTwo/ci-policy: native / swift-19 (pull_request) Skipped
KofTwentyTwo/ci-policy: native / native-result (pull_request) Canceled after 3s
feat(ci): reuse verified builds before merge verification
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-05 03:54:30 +00:00

82 lines
4.1 KiB
Python

"""Shared fixtures: the example configurations, fixed revisions, and event builders."""
import copy
from pathlib import Path
from typing import cast
import yaml
from platform_ci.configuration import ProjectConfiguration, parse_project_configuration
from platform_ci.plan import EventContext, Plan, Target, prepare_plan
from platform_ci.runtimes import RuntimeCatalog, parse_runtime_catalog
EXAMPLES_DIRECTORY = Path(__file__).resolve().parent.parent / "examples"
SOURCE_REVISION = "a" * 40
SOURCE_TREE = "d" * 40
PLATFORM_REVISION = "b" * 40
# Syntactically valid placeholders for tests only; they name no real image and are never used outside tests.
JAVA_IMAGE = f"registry.example/toolchain-java@sha256:{'1' * 64}"
NODE_IMAGE = f"registry.example/toolchain-node@sha256:{'2' * 64}"
TEST_RUNTIME_CATALOG = parse_runtime_catalog({"schema": 1, "toolchains": {"java": {"21": {"image": JAVA_IMAGE}}, "node": {"22.20.0": {"image": NODE_IMAGE}}}})
def placeholder_image(toolchain: str) -> str:
"""Return a syntactically valid placeholder image for a toolchain; it names no real image and is used only in tests."""
return f"registry.example/toolchain-{toolchain}@sha256:{'4' * 64}"
# Every toolchain is qualified here, so tests can plan mixed-platform configurations. Host platforms are attested for the
# toolchains that run natively. Runner labels are placeholders, not the operator's real labels.
NATIVE_RUNTIME_CATALOG = parse_runtime_catalog(
{
"schema": 1,
"runners": {"windows-amd64": {"standard": "test-windows-pool"}, "macos-arm64": {"standard": "test-macos-pool"}},
"toolchains": {
"java": {"21": {"image": JAVA_IMAGE, "browser_image": placeholder_image("browser")}},
"node": {"22.20.0": {"image": NODE_IMAGE}},
"go": {"1": {"image": placeholder_image("go"), "hosts": ["macos-arm64", "windows-amd64"]}},
"rust": {"1": {"image": placeholder_image("rust"), "hosts": ["macos-arm64", "windows-amd64"]}},
"python": {"3.13": {"image": placeholder_image("python")}},
"android": {"2026.10.1": {"image": placeholder_image("android")}},
"dotnet": {"10.0.403": {"image": None, "hosts": ["windows-amd64"]}},
"xcode": {"27": {"image": None, "hosts": ["macos-arm64"]}},
},
}
)
def example_mapping(file_name: str) -> dict[str, object]:
"""Return a fresh, mutable copy of an example `.ci.yaml` as parsed YAML."""
text = (EXAMPLES_DIRECTORY / file_name).read_text(encoding="utf-8")
return copy.deepcopy(cast("dict[str, object]", yaml.safe_load(text)))
def example_configuration(file_name: str) -> ProjectConfiguration:
"""Return a validated example configuration."""
return parse_project_configuration(example_mapping(file_name))
def component_mapping(configuration: dict[str, object], name: str) -> dict[str, object]:
"""Return one component's mutable mapping inside a parsed example."""
return cast("dict[str, object]", cast("dict[str, object]", configuration["components"])[name])
def build_mapping(configuration: dict[str, object], name: str) -> dict[str, object]:
"""Return one component's mutable `build` mapping inside a parsed example."""
return cast("dict[str, object]", component_mapping(configuration, name)["build"])
def first_target(file_name: str, context: EventContext | None = None) -> Target:
"""Return the first planned target of an example for the given event (a pull request by default)."""
return plan_for(example_configuration(file_name), context or event())["targets"][0]
def plan_for(configuration: ProjectConfiguration, context: EventContext, runtimes: RuntimeCatalog = TEST_RUNTIME_CATALOG) -> Plan:
"""Prepare a plan against the fully qualified test catalog unless a test supplies its own."""
return prepare_plan(configuration, context, runtimes)
def event(name: str = "pull_request", ref: str = "refs/pull/1/merge", default_branch: str = "main") -> EventContext:
"""Build an event context with fixed revisions and a default branch."""
return EventContext(name=name, ref=ref, source_revision=SOURCE_REVISION, platform_revision=PLATFORM_REVISION, default_branch=default_branch)