Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(manager): Adds Unity3D #28189

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

ViMaSter
Copy link
Contributor

Changes

Adds a manager for updating the runtime of a project using the Unity game engine.

Context

See #27219, closes #27295.

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please select one)

I have verified these changes via:

Comment on lines +8 to +13
packageRules: [
{
groupName: 'Unity Editor',
matchPackageNames: ['m_EditorVersion', 'm_EditorVersionWithRevision'],
},
],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be rather part of a preset, as it is hard to find out what is happening if the config is set here.

If we are talking about the same version in different places you can set depName to the same value. This will by default result too in a single PR

return null;
}

if (version !== version.trim()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this necessary? 🤔

'm_EditorVersion',
];
const parseLine = (line: string): PackageDependency | null => {
const matches = regEx(/^(?<depName>.+): (?<currentValue>.+)/g).exec(line);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move the regex definition to the module scope.

lib/modules/manager/unity3d/extract.ts Outdated Show resolved Hide resolved
Comment on lines +43 to +45
if (!fileMatchRegex.every((regex: string) => regEx(regex).test(fileName))) {
return { deps: [] };
}
Copy link
Collaborator

@secustor secustor Mar 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't necessary, extractPackageFile will only be called on fitting file names

Comment on lines 28 to 35
autoReplaceStringTemplate:
'{{depName}}{{#if newValue}}:{{newValue}}{{/if}}',
currentDigest: undefined,
currentValue: version,
datasource: 'unity3d',
depName: key,
depType: 'final',
replaceString: matches[0],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
autoReplaceStringTemplate:
'{{depName}}{{#if newValue}}:{{newValue}}{{/if}}',
currentDigest: undefined,
currentValue: version,
datasource: 'unity3d',
depName: key,
depType: 'final',
replaceString: matches[0],
currentValue: version,
datasource: 'unity3d',
depName: key,
depType: 'final',

These vales are set by default.

Also why final as depType, if there is only one?

Comment on lines +48 to +54
deps: content
.split('\n')
.map((line) => line.trim())
.filter((line) => line.length > 0)
.map(parseLine)
.filter((dep) => dep !== null) as PackageDependency[],
};
Copy link
Collaborator

@secustor secustor Mar 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and return null for empty deps

Copy link
Member

@viceice viceice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

☝️

@@ -24,6 +24,7 @@ const Categories = [
'rust',
'swift',
'terraform',
'unity3d',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 is it really worth to have an own category? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unity has a different package manager (Unity Package Manager) for its sub-dependencies and while I've read #19300, I haven't got it working using the proposed NPM workaround: There's a lock file different from normal NPM lock files that would have to be generated and currently isn't. This might be something worth adding under the unity3d umbrella.

Let me know if you find any existing ones more appropriate.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to add the category then, if support for this manager is added too.

Please remove it for now.

@@ -0,0 +1,2 @@
m_EditorVersion: 2023.3.0b5
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please inline those small fixtures, use codeBlock string template helper for indention

Comment on lines +48 to +54
deps: content
.split('\n')
.map((line) => line.trim())
.filter((line) => line.length > 0)
.map(parseLine)
.filter((dep) => dep !== null) as PackageDependency[],
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and return null for empty deps

ViMaSter and others added 2 commits March 31, 2024 22:51
Co-authored-by: Sebastian Poxhofer <secustor@users.noreply.github.com>
Co-authored-by: Sebastian Poxhofer <secustor@users.noreply.github.com>
]);
});

it('skips if casing is incorrect', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should Renovate raise a warning about the malformed casing? Or should Unity warn about malformed files?

expect(res).toBeEmpty();
});

it('skips abnormal spacing', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question about Renovate warning or Unity warning here.

@@ -0,0 +1,10 @@
Handles version numbers inside `ProjectSettings/ProjectVersion.txt` files used by the Unity game engine.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see two ways to read this:

  • Renovate can read ProjectSettings.txt and ProjectVersion.txt files
  • Renovate can read a ProjectVersion.txt file if its in the ProjectSettings directory

I don't know which interpretation is correct, as I don't use Unity.

Please update the text so it explains precisely what Renovate can update. 🙂

@@ -0,0 +1,10 @@
Handles version numbers inside `ProjectSettings/ProjectVersion.txt` files used by the Unity game engine.

`ProjectSettings/ProjectVersion.txt` always contains two version references in a yml-like syntax; one with and one without a hash, both of which are updated:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`ProjectSettings/ProjectVersion.txt` always contains two version references in a yml-like syntax; one with and one without a hash, both of which are updated:
`ProjectSettings/ProjectVersion.txt` always have two version references in a yml-like syntax; one with and one without a hash, both are updated:

Also, is it YML-like syntax or YAML-syntax? I lean towards YAML-syntax, but not sure. 🙂

m_EditorVersionWithRevision: 2020.3.15f2 (6cf78cb77498)
```

Relies on the corresponding `unity3d` datasource and versioning.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any changes to a datasource directory in this PR? Maybe that was added in a different PR? Or I'm misunderstanding something here. 🙃

In any case, please check if this sentence is correct.

@rarkins
Copy link
Collaborator

rarkins commented May 7, 2024

@ViMaSter do you have time to address the PR review comments?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for Unity editor
5 participants