mirror of
https://github.com/clockworklabs/SpacetimeDB.git
synced 2026-05-06 07:26:43 -04:00
Tighten package sources in C# smoketests (#1735)
This commit is contained in:
@@ -137,9 +137,18 @@ jobs:
|
||||
<packageSources>
|
||||
<!-- Local NuGet repositories -->
|
||||
<add key="Local SpacetimeDB.BSATN.Runtime" value="../crates/bindings-csharp/BSATN.Runtime/bin/Release" />
|
||||
<!-- Official NuGet.org server -->
|
||||
<add key="NuGet.org" value="https://api.nuget.org/v3/index.json" />
|
||||
</packageSources>
|
||||
<packageSourceMapping>
|
||||
<!-- Ensure that SpacetimeDB.BSATN.Runtime is used from the local folder. -->
|
||||
<!-- Otherwise we risk an outdated version being quietly pulled from NuGet for testing. -->
|
||||
<packageSource key="Local SpacetimeDB.BSATN.Runtime">
|
||||
<package pattern="SpacetimeDB.BSATN.Runtime" />
|
||||
</packageSource>
|
||||
<!-- Fallback to NuGet for other packages. -->
|
||||
<packageSource key="nuget.org">
|
||||
<package pattern="*" />
|
||||
</packageSource>
|
||||
</packageSourceMapping>
|
||||
</configuration>
|
||||
EOF
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import tempfile
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import subprocess
|
||||
import xml.etree.ElementTree as xml
|
||||
|
||||
|
||||
@requires_dotnet
|
||||
@@ -26,20 +27,28 @@ class CreateProject(unittest.TestCase):
|
||||
|
||||
packed_projects = ["BSATN.Runtime", "Runtime"]
|
||||
|
||||
config = []
|
||||
config.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>")
|
||||
config.append("<configuration>")
|
||||
config.append("<packageSources>")
|
||||
config.append("<!-- Local NuGet repositories -->")
|
||||
for project in packed_projects:
|
||||
path = bindings / project / "bin" / "Release"
|
||||
config.append("<add key=\"Local %s\" value=\"%s\" />\n" % (project, str(path)))
|
||||
config.append("<!-- Official NuGet.org server -->")
|
||||
config.append("<add key=\"NuGet.org\" value=\"https://api.nuget.org/v3/index.json\" />")
|
||||
config.append("</packageSources>")
|
||||
config.append("</configuration>")
|
||||
config = xml.Element("configuration")
|
||||
|
||||
config = "\n".join(config)
|
||||
sources = xml.SubElement(config, "packageSources")
|
||||
mappings = xml.SubElement(config, "packageSourceMapping")
|
||||
|
||||
for project in packed_projects:
|
||||
# Add local build directories as NuGet repositories.
|
||||
path = bindings / project / "bin" / "Release"
|
||||
project = f"SpacetimeDB.{project}"
|
||||
xml.SubElement(sources, "add", key=project, value=str(path))
|
||||
|
||||
# Add strict package source mappings to ensure that
|
||||
# SpacetimeDB.* packages are used from those directories
|
||||
# and never from nuget.org.
|
||||
#
|
||||
# This prevents bugs where we silently used an outdated
|
||||
# version which led to tests passing when they shouldn't.
|
||||
mapping = xml.SubElement(mappings, "packageSource", key=project)
|
||||
xml.SubElement(mapping, "package", pattern=project)
|
||||
|
||||
xml.indent(config)
|
||||
config = xml.tostring(config, encoding="unicode", xml_declaration=True)
|
||||
|
||||
print("Writing `nuget.config` contents:")
|
||||
print(config)
|
||||
|
||||
Reference in New Issue
Block a user