ci: build amd64 on opt-in main commits [CI SKIP]
This commit is contained in:
1 parent
0f19d5047d
commit
46499b10b6
9 files changed
+143
-371
No files matched your search
@@ -0,0 +1,66 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Stage source and restore files for the Linux amd64 Agent or Probe image build."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
BACKEND = ROOT / "backend"
|
||||
IGNORED_PARTS = {".git", ".release", "artifacts", "bin", "obj", "TestResults", "tests"}
|
||||
GLOBAL_BACKEND_FILES = {
|
||||
"Directory.Build.props",
|
||||
"Directory.Build.targets",
|
||||
"Directory.Packages.props",
|
||||
"global.json",
|
||||
"NuGet.Config",
|
||||
"NuGet.config",
|
||||
}
|
||||
CONTAINERFILES = {
|
||||
"agent": ROOT / "packaging/container/Agent.NativeBuild.Containerfile",
|
||||
"probe": ROOT / "packaging/container/Probe.NativeBuild.Containerfile",
|
||||
}
|
||||
|
||||
|
||||
def stage(component: str, destination: Path) -> None:
|
||||
if destination.exists():
|
||||
shutil.rmtree(destination)
|
||||
restore = destination / "restore/backend"
|
||||
source = destination / "source/backend"
|
||||
restore.mkdir(parents=True)
|
||||
source.mkdir(parents=True)
|
||||
shutil.copy2(CONTAINERFILES[component], destination / "Containerfile")
|
||||
|
||||
for path in BACKEND.rglob("*"):
|
||||
if not path.is_file() or IGNORED_PARTS.intersection(path.parts):
|
||||
continue
|
||||
relative = path.relative_to(BACKEND)
|
||||
if (
|
||||
path.suffix in {".csproj", ".props", ".targets", ".slnx"}
|
||||
or path.name in GLOBAL_BACKEND_FILES
|
||||
or path.name == "packages.lock.json"
|
||||
):
|
||||
target = restore / relative
|
||||
target.parent.mkdir(parents=True, exist_ok=True)
|
||||
shutil.copy2(path, target)
|
||||
target = source / relative
|
||||
target.parent.mkdir(parents=True, exist_ok=True)
|
||||
shutil.copy2(path, target)
|
||||
|
||||
config = destination / "config"
|
||||
config.mkdir()
|
||||
(config / ".keep").write_text("", encoding="utf-8")
|
||||
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("component", choices=tuple(CONTAINERFILES))
|
||||
parser.add_argument("destination", type=Path)
|
||||
args = parser.parse_args()
|
||||
stage(args.component, args.destination)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in new issue
Block a user