mirror of
https://github.com/d9pouces/id_configurator.git
synced 2026-11-09 01:47:21 +01:00
feat: add support for Go, Ruby, and NuGet modules with integration testing configurations
Signed-off-by: d9pouces <github@19pouces.net>
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
"""Build a minimal NuGet v3 static feed around one real, `dotnet pack`-built
|
||||
.nupkg, for integration-testing the `nuget` module of id-configurator.
|
||||
|
||||
Only two resources are populated: the flat container (`PackageBaseAddress`,
|
||||
used to enumerate versions and download the .nupkg directly) and the
|
||||
top-level service index pointing at it. `dotnet add package`/`dotnet
|
||||
restore` with an explicit, dependency-free package version only ever calls
|
||||
these two - never the (considerably more complex) registration resource -
|
||||
so it is intentionally not implemented here.
|
||||
|
||||
The service index bakes in a __BASE_URL__ placeholder for its "@id" fields,
|
||||
since the host:port this fixture is actually reached on is only known once
|
||||
tox-docker starts the container, not at image-build time (see
|
||||
nuget-repo.nginx.conf). The flat container's own files never embed a URL,
|
||||
so they need no such rewriting.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import pathlib
|
||||
import shutil
|
||||
|
||||
PACKAGE_ID = "idconfiguratortestpkg"
|
||||
VERSION = "0.0.1"
|
||||
NUPKG_NAME = f"{PACKAGE_ID}.{VERSION}.nupkg"
|
||||
NUPKG_SRC = pathlib.Path("/nupkg") / NUPKG_NAME
|
||||
OUT_DIR = pathlib.Path("/srv")
|
||||
|
||||
|
||||
def write_flat_container() -> None:
|
||||
package_dir = OUT_DIR / "flatcontainer" / PACKAGE_ID
|
||||
version_dir = package_dir / VERSION
|
||||
version_dir.mkdir(parents=True, exist_ok=True)
|
||||
(package_dir / "index.json").write_text(
|
||||
json.dumps({"versions": [VERSION]}), encoding="utf-8"
|
||||
)
|
||||
shutil.copy(NUPKG_SRC, version_dir / NUPKG_NAME)
|
||||
|
||||
|
||||
def write_service_index() -> None:
|
||||
index = {
|
||||
"version": "3.0.0",
|
||||
"resources": [
|
||||
{
|
||||
"@id": "__BASE_URL__/flatcontainer/",
|
||||
"@type": "PackageBaseAddress/3.0.0",
|
||||
}
|
||||
],
|
||||
}
|
||||
(OUT_DIR / "index.json").write_text(json.dumps(index), encoding="utf-8")
|
||||
|
||||
|
||||
def main() -> None:
|
||||
OUT_DIR.mkdir(parents=True, exist_ok=True)
|
||||
write_flat_container()
|
||||
write_service_index()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user