Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions .uloop/project-runner-pin.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
{
"projectRunnerVersion": "3.0.0-beta.46",
"minimumDispatcherVersion": "3.0.1-beta.6",
"packageName": "io.github.hatayama.uloopmcp",
"packageVersion": "3.0.0-beta.48",
"requiredProtocolVersion": 3,
"schemaVersion": 1
"minimumDispatcherVersion": "3.0.1-beta.6"
}
14 changes: 7 additions & 7 deletions Assets/Tests/Editor/CliPinSynchronizerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void SyncProjectPinFile_WhenDestinationMissing_ShouldCopyPackagePin()
Directory.CreateDirectory(projectRoot);
File.WriteAllText(
Path.Combine(packageRoot, UnityCliLoopConstants.ULOOP_PROJECT_RUNNER_PIN_FILE_NAME),
"{\"schemaVersion\":1}");
"{\"projectRunnerVersion\":\"3.0.0\",\"minimumDispatcherVersion\":\"3.0.1\"}");

bool changed = CliPinSynchronizer.SyncProjectPinFile(packageRoot, projectRoot);

Expand All @@ -37,7 +37,7 @@ public void SyncProjectPinFile_WhenDestinationMissing_ShouldCopyPackagePin()
projectRoot,
UnityCliLoopConstants.ULOOP_DIR,
UnityCliLoopConstants.ULOOP_PROJECT_RUNNER_PIN_FILE_NAME)),
Is.EqualTo("{\"schemaVersion\":1}"));
Is.EqualTo("{\"projectRunnerVersion\":\"3.0.0\",\"minimumDispatcherVersion\":\"3.0.1\"}"));
}
finally
{
Expand All @@ -64,8 +64,8 @@ public void SyncProjectPinFile_WhenDestinationMatches_ShouldSkipWrite()
string destinationPath = Path.Combine(
projectUloopRoot,
UnityCliLoopConstants.ULOOP_PROJECT_RUNNER_PIN_FILE_NAME);
File.WriteAllText(sourcePath, "{\"schemaVersion\":1}");
File.WriteAllText(destinationPath, "{\"schemaVersion\":1}");
File.WriteAllText(sourcePath, "{\"projectRunnerVersion\":\"3.0.0\",\"minimumDispatcherVersion\":\"3.0.1\"}");
File.WriteAllText(destinationPath, "{\"projectRunnerVersion\":\"3.0.0\",\"minimumDispatcherVersion\":\"3.0.1\"}");
DateTime previousWriteTime = File.GetLastWriteTimeUtc(destinationPath);

bool changed = CliPinSynchronizer.SyncProjectPinFile(packageRoot, projectRoot);
Expand Down Expand Up @@ -94,16 +94,16 @@ public void SyncProjectPinFile_WhenPackagePinChanges_ShouldUpdateProjectPin()
Directory.CreateDirectory(projectUloopRoot);
File.WriteAllText(
Path.Combine(packageRoot, UnityCliLoopConstants.ULOOP_PROJECT_RUNNER_PIN_FILE_NAME),
"{\"schemaVersion\":2}");
"{\"projectRunnerVersion\":\"3.0.1\",\"minimumDispatcherVersion\":\"3.0.1\"}");
string destinationPath = Path.Combine(
projectUloopRoot,
UnityCliLoopConstants.ULOOP_PROJECT_RUNNER_PIN_FILE_NAME);
File.WriteAllText(destinationPath, "{\"schemaVersion\":1}");
File.WriteAllText(destinationPath, "{\"projectRunnerVersion\":\"3.0.0\",\"minimumDispatcherVersion\":\"3.0.1\"}");

bool changed = CliPinSynchronizer.SyncProjectPinFile(packageRoot, projectRoot);

Assert.That(changed, Is.True);
Assert.That(File.ReadAllText(destinationPath), Is.EqualTo("{\"schemaVersion\":2}"));
Assert.That(File.ReadAllText(destinationPath), Is.EqualTo("{\"projectRunnerVersion\":\"3.0.1\",\"minimumDispatcherVersion\":\"3.0.1\"}"));
}
finally
{
Expand Down
6 changes: 1 addition & 5 deletions Packages/src/project-runner-pin.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
{
"projectRunnerVersion": "3.0.0-beta.46",
"minimumDispatcherVersion": "3.0.1-beta.6",
"packageName": "io.github.hatayama.uloopmcp",
"packageVersion": "3.0.0-beta.48",
"requiredProtocolVersion": 3,
"schemaVersion": 1
"minimumDispatcherVersion": "3.0.1-beta.6"
}
30 changes: 2 additions & 28 deletions cli/common/clicontract/protocol_version_consistency_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
// Unity package accepts. It is relative to this package directory (cli/common/clicontract).
const (
unityProtocolConstantPath = "../../../Packages/src/Editor/Domain/CliConstants.cs"
unityPackageManifestPath = "../../../Packages/src/package.json"
unityPackageCliPinPath = "../../../Packages/src/project-runner-pin.json"
unityProjectCliPinPath = "../../../.uloop/project-runner-pin.json"
)
Expand All @@ -23,17 +22,8 @@ var (
unityMinimumDispatcherVersionPattern = regexp.MustCompile(`MINIMUM_REQUIRED_DISPATCHER_VERSION\s*=\s*"([^"]+)"`)
)

type unityPackageManifest struct {
Name string `json:"name"`
Version string `json:"version"`
}

type unityPackageCliPin struct {
SchemaVersion int `json:"schemaVersion"`
PackageName string `json:"packageName"`
PackageVersion string `json:"packageVersion"`
ProjectRunnerVersion string `json:"projectRunnerVersion"`
RequiredProtocolVersion int `json:"requiredProtocolVersion"`
MinimumDispatcherVersion string `json:"minimumDispatcherVersion"`
}

Expand All @@ -55,30 +45,14 @@ func TestProtocolVersionMatchesUnityPackage(t *testing.T) {
}

// TestUnityPackageCliPinMatchesReleaseContracts verifies the dispatcher pin copied into
// projects points at the package release, project runner release, and protocol generation from their
// canonical declarations.
// projects points at the project runner release from cli/contract.json and at the minimum
// dispatcher version declared in CliConstants.
func TestUnityPackageCliPinMatchesReleaseContracts(t *testing.T) {
manifest := readJSONFile[unityPackageManifest](t, unityPackageManifestPath)
pin := readJSONFile[unityPackageCliPin](t, unityPackageCliPinPath)

if pin.SchemaVersion != 1 {
t.Fatalf("expected %s schemaVersion to be 1, got %d", unityPackageCliPinPath, pin.SchemaVersion)
}
if pin.PackageName != manifest.Name {
t.Fatalf("expected %s packageName to match %s name: %q != %q", unityPackageCliPinPath, unityPackageManifestPath, pin.PackageName, manifest.Name)
}
if pin.PackageVersion != manifest.Version {
t.Fatalf("expected %s packageVersion to match %s version: %q != %q", unityPackageCliPinPath, unityPackageManifestPath, pin.PackageVersion, manifest.Version)
}
if pin.ProjectRunnerVersion != ProjectRunnerVersion() {
t.Fatalf("expected %s projectRunnerVersion to match cli/contract.json projectRunnerVersion: %q != %q", unityPackageCliPinPath, pin.ProjectRunnerVersion, ProjectRunnerVersion())
}
if pin.RequiredProtocolVersion != ProtocolVersion() {
t.Fatalf("expected %s requiredProtocolVersion to match cli/contract.json protocolVersion: %d != %d", unityPackageCliPinPath, pin.RequiredProtocolVersion, ProtocolVersion())
}
if pin.RequiredProtocolVersion != readUnityRequiredProtocolVersion(t) {
t.Fatalf("expected %s requiredProtocolVersion to match %s", unityPackageCliPinPath, unityProtocolConstantPath)
}
if pin.MinimumDispatcherVersion == "" {
t.Fatalf("expected %s minimumDispatcherVersion to be set", unityPackageCliPinPath)
}
Expand Down
7 changes: 0 additions & 7 deletions cli/dispatcher/internal/dispatcher/dispatcher_pin.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ import (
var dispatcherProjectRunnerVersionPattern = regexp.MustCompile(`^[0-9]+\.[0-9]+\.[0-9]+(?:-[0-9A-Za-z][0-9A-Za-z.-]*)?(?:\+[0-9A-Za-z][0-9A-Za-z.-]*)?$`)

type dispatcherPin struct {
SchemaVersion int `json:"schemaVersion"`
PackageName string `json:"packageName"`
PackageVersion string `json:"packageVersion"`
ProjectRunnerVersion string `json:"projectRunnerVersion"`
RequiredProtocolVersion int `json:"requiredProtocolVersion"`
MinimumDispatcherVersion string `json:"minimumDispatcherVersion"`
SourcePath string `json:"-"`
}
Expand Down Expand Up @@ -96,9 +92,6 @@ func readDispatcherPin(pinPath string) (dispatcherPin, error) {
return dispatcherPin{}, fmt.Errorf("%s defines invalid minimumDispatcherVersion: %w", pinPath, err)
}
}
if pin.SchemaVersion == 0 {
return dispatcherPin{}, fmt.Errorf("%s does not define schemaVersion", pinPath)
}
pin.SourcePath = pinPath
return pin, nil
}
Expand Down
6 changes: 3 additions & 3 deletions cli/dispatcher/internal/dispatcher/dispatcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ func TestLoadDispatcherPinRejectsInvalidProjectRunnerVersion(t *testing.T) {
if err := os.MkdirAll(filepath.Dir(pinPath), 0o755); err != nil {
t.Fatalf("failed to create pin directory: %v", err)
}
content := `{"schemaVersion":1,"packageName":"io.github.hatayama.uloopmcp","packageVersion":"3.0.0-beta.1","projectRunnerVersion":"../../payload","requiredProtocolVersion":2,"minimumDispatcherVersion":"3.0.0-beta.39"}`
content := `{"projectRunnerVersion":"../../payload","minimumDispatcherVersion":"3.0.0-beta.39"}`
if err := os.WriteFile(pinPath, []byte(content), 0o644); err != nil {
t.Fatalf("failed to write pin: %v", err)
}
Expand Down Expand Up @@ -855,9 +855,9 @@ func writeDispatcherPinFileWithMinimum(t *testing.T, pinPath string, projectRunn
if err := os.MkdirAll(filepath.Dir(pinPath), 0o755); err != nil {
t.Fatalf("failed to create pin directory: %v", err)
}
content := `{"schemaVersion":1,"packageName":"io.github.hatayama.uloopmcp","packageVersion":"3.0.0-beta.1","projectRunnerVersion":"` +
content := `{"projectRunnerVersion":"` +
projectRunnerVersion +
`","requiredProtocolVersion":2,"minimumDispatcherVersion":"` +
`","minimumDispatcherVersion":"` +
minimumDispatcherVersion +
`"}`
if err := os.WriteFile(pinPath, []byte(content), 0o644); err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,7 @@ type dispatcherMinimumVersionReleaseContract struct {
}

type dispatcherMinimumVersionCliPin struct {
SchemaVersion int `json:"schemaVersion"`
PackageName string `json:"packageName"`
PackageVersion string `json:"packageVersion"`
ProjectRunnerVersion string `json:"projectRunnerVersion"`
RequiredProtocolVersion int `json:"requiredProtocolVersion"`
MinimumDispatcherVersion string `json:"minimumDispatcherVersion"`
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,9 @@ public const string MINIMUM_REQUIRED_DISPATCHER_VERSION = "` + minimumDispatcher
}

func buildDispatcherMinimumVersionPin(projectRunnerVersion string, minimumDispatcherVersion string) string {
return `{"schemaVersion":1,"packageName":"test.package","packageVersion":"3.0.0-beta.40","projectRunnerVersion":"` +
return `{"projectRunnerVersion":"` +
projectRunnerVersion +
`","requiredProtocolVersion":2,"minimumDispatcherVersion":"` +
`","minimumDispatcherVersion":"` +
minimumDispatcherVersion +
`"}`
}
Expand Down
10 changes: 0 additions & 10 deletions release-please-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,6 @@
"type": "json",
"path": "package.json",
"jsonpath": "$.version"
},
{
"type": "json",
"path": "project-runner-pin.json",
"jsonpath": "$.packageVersion"
},
{
"type": "json",
"path": "/.uloop/project-runner-pin.json",
"jsonpath": "$.packageVersion"
}
]
},
Expand Down
30 changes: 13 additions & 17 deletions scripts/test-release-please-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,9 @@ assert_json_value '.packages["Packages/src"].["changelog-path"]' 'CHANGELOG.md'
assert_json_value '.packages["Packages/src"].component' 'unity-package'
assert_json_value '.packages["Packages/src"].["include-component-in-tag"]' 'false'
assert_json_value '.packages["Packages/src"] | has("exclude-paths")' 'false'
assert_json_value '.packages["Packages/src"].["extra-files"] | length' '3'
assert_json_value '.packages["Packages/src"].["extra-files"][0].path' 'package.json'
assert_json_value '.packages["Packages/src"].["extra-files"][0].jsonpath' '$.version'
assert_json_value '.packages["Packages/src"].["extra-files"][1].path' 'project-runner-pin.json'
assert_json_value '.packages["Packages/src"].["extra-files"][1].jsonpath' '$.packageVersion'
assert_json_value '.packages["Packages/src"].["extra-files"][2].path' '/.uloop/project-runner-pin.json'
assert_json_value '.packages["Packages/src"].["extra-files"][2].jsonpath' '$.packageVersion'
assert_json_value '.packages["Packages/src"]["extra-files"] | length' '1'
assert_json_value '.packages["Packages/src"]["extra-files"][0].path' 'package.json'
assert_json_value '.packages["Packages/src"]["extra-files"][0].jsonpath' '$.version'

assert_json_value '.packages["cli/project-runner"].component' 'uloop-project-runner'
assert_json_value '.packages["cli/project-runner"].["include-component-in-tag"]' 'true'
Expand All @@ -143,13 +139,13 @@ assert_json_value '.packages["cli/project-runner"].["changelog-path"]' 'CHANGELO
# so there is nothing left under cli/project-runner to exclude from
# uloop-project-runner releases.
assert_json_value '.packages["cli/project-runner"] | has("exclude-paths")' 'false'
assert_json_value '.packages["cli/project-runner"].["extra-files"] | length' '4'
assert_json_value '.packages["cli/project-runner"].["extra-files"][0].path' '/cli/common/tools/default-tools.json'
assert_json_value '.packages["cli/project-runner"].["extra-files"][1].path' '/cli/common/clicontract/contract.json'
assert_json_value '.packages["cli/project-runner"].["extra-files"][2].path' '/Packages/src/project-runner-pin.json'
assert_json_value '.packages["cli/project-runner"].["extra-files"][2].jsonpath' '$.projectRunnerVersion'
assert_json_value '.packages["cli/project-runner"].["extra-files"][3].path' '/.uloop/project-runner-pin.json'
assert_json_value '.packages["cli/project-runner"].["extra-files"][3].jsonpath' '$.projectRunnerVersion'
assert_json_value '.packages["cli/project-runner"]["extra-files"] | length' '4'
assert_json_value '.packages["cli/project-runner"]["extra-files"][0].path' '/cli/common/tools/default-tools.json'
assert_json_value '.packages["cli/project-runner"]["extra-files"][1].path' '/cli/common/clicontract/contract.json'
assert_json_value '.packages["cli/project-runner"]["extra-files"][2].path' '/Packages/src/project-runner-pin.json'
assert_json_value '.packages["cli/project-runner"]["extra-files"][2].jsonpath' '$.projectRunnerVersion'
assert_json_value '.packages["cli/project-runner"]["extra-files"][3].path' '/.uloop/project-runner-pin.json'
assert_json_value '.packages["cli/project-runner"]["extra-files"][3].jsonpath' '$.projectRunnerVersion'

# The dispatcher tag format must stay dispatcher-v<version> to continue the
# existing tag sequence started before release-please management.
Expand All @@ -160,9 +156,9 @@ assert_json_value '.packages["cli/dispatcher"].["versioning"]' 'prerelease'
assert_json_value '.packages["cli/dispatcher"].["prerelease-type"]' 'beta'
assert_json_value '.packages["cli/dispatcher"].["changelog-path"]' 'CHANGELOG.md'
assert_json_value '.packages["cli/dispatcher"] | has("exclude-paths")' 'false'
assert_json_value '.packages["cli/dispatcher"].["extra-files"] | length' '1'
assert_json_value '.packages["cli/dispatcher"].["extra-files"][0].path' 'dispatchercontract/dispatcher-contract.json'
assert_json_value '.packages["cli/dispatcher"].["extra-files"][0].jsonpath' '$.dispatcherVersion'
assert_json_value '.packages["cli/dispatcher"]["extra-files"] | length' '1'
assert_json_value '.packages["cli/dispatcher"]["extra-files"][0].path' 'dispatchercontract/dispatcher-contract.json'
assert_json_value '.packages["cli/dispatcher"]["extra-files"][0].jsonpath' '$.dispatcherVersion'

assert_file_contains "$RELEASE_WORKFLOW" 'id: package_release_sync'
assert_file_contains "$RELEASE_WORKFLOW" "steps.package_release_sync.outputs.ready != 'false'"
Expand Down
4 changes: 0 additions & 4 deletions scripts/test-sync-release-please-package-releases.sh
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,7 @@ EOF_MANIFEST

cat > Packages/src/project-runner-pin.json <<EOF_PIN
{
"schemaVersion": 1,
"packageName": "test.package",
"packageVersion": "$version",
"projectRunnerVersion": "$version",
"requiredProtocolVersion": 2,
"minimumDispatcherVersion": "3.0.0"
}
EOF_PIN
Expand Down
Loading