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

Add support for Scoped Registries #261

Merged
merged 6 commits into from
Mar 14, 2024

Conversation

nvandessel
Copy link
Contributor

@nvandessel nvandessel commented Feb 23, 2024

Changes

  • Adds new arguments to the action named scopedRegistryUrl and registryScopes.
  • Expects to receive a UPM_REGISTRY_TOKEN as an environment variable.
  • These values are used when packageMode is true and we test a Unity package.
  • During testing the following happens.
    • If a scopedRegistryUrl is provided, validation occurs to ensure registryScopes are supplied as well
    • The test project is built to test our package, and opened to generate a manifest.json (existing functionality)
    • While adding the package under test to the manifest.json we also add the scoped registry and its scopes
    • If a UPM_REGISTRY_TOKEN is found, then a .upmconfig.toml is created at the $HOME directory
  • Further information on scoped registries can be found in the Unity docs.

Related Issues

Related PRs

Successful Workflow Run Link

PRs don't have access to secrets so you will need to provide a link to a successful run
of the workflows from your own repo.

  • Successful run on public registry
  • Successful run on private registry
    • Note, I've removed the logs from the above run to avoid exposing any information about the private registry (mainly the URL), simply out of an abundance of caution. While I am passing the URL through GH secrets, Unity will still output the URL when showing which registry packages were resolved from.

Checklist

  • Read the contribution guide and accept the code of conduct
  • Docs (If new inputs or outputs have been added or changes to behavior that should be documented. Please make a PR
    in the documentation repo)
  • Readme (updated or not needed)
  • Tests (added, updated or not needed)
    • I did not add any tests, but I did add the additional com.dependencyexample.testpackage to the same directory as the existing package. By default it is setup to have a dependency from a popular OpenUPM package UniTask, and is tested via the added job testPackageRunnerWithScopeRegistry.

Copy link

Cat Gif

@nvandessel nvandessel closed this Feb 23, 2024
@nvandessel nvandessel reopened this Feb 28, 2024
Copy link

Cat Gif

@nvandessel
Copy link
Contributor Author

@webbertakken @GabLeRoux @davidmfinol

Hey guys, wasn't sure who to tag so... :)
I'd like to start tackling this problem, I've already setup what I think is the basic support for public scoped registries, however I was hoping to include the work to support private scoped registries as well. There's a few ways that we could solve this and so I wanted to open it up to discussion.

I'd like to try and support as many UPM registries types as possible. The only one I've personally used is Verdaccio (which I believe OpenUPM is also using as their backend registry), however I'd like to not be limited. In addition the authentication method with UPM registries is largely dependent on how you have decided to set it up as a user/organization.

Ultimately the most important thing is that Unity requires a .upmconfig.toml located at a specific location dependent on your OS, which if it finds will utilize a token supplied there for authenticating with private scoped registries. I'd like to suggest that as a solution to support these private registries, we require that a consumer of the action sets a GH secret which is their private registry auth token, then during the execution of the action we pass that to run_tests.sh shell script which can determine if the value has been provided and setup the toml for us if it has.

Curious to get your thoughts on this!

Also, shoutout to @trudeaua21 for all the work you put into supporting package testing!

@nvandessel
Copy link
Contributor Author

Also, open to adjust the existing implementation, I didn't want to bloat things too much so just duplicated the existing test package in it's directory and renamed it to be explicit that it was for testing dependencies. I used a popular OpenUPM package UniTask as a dependency to force the test Project to resolve it. You can see it successfully do that in the logs of this run here.

@nvandessel nvandessel marked this pull request as ready for review February 29, 2024 00:38
@nvandessel
Copy link
Contributor Author

I've implemented the solution I discussed above, supplying the registry token via a GitHub Actions Secret and creating the .upmconfig.toml on the fly. Everything looks to be working for both public and private scoped registries!

Looking forward to getting some feedback!

@nvandessel
Copy link
Contributor Author

nvandessel commented Feb 29, 2024

Discovered an issue in how multiple scopes were being parsed and injected into the manifest.json, I've fixed the issue and here's an example run showing it working: fix: multiple scopes

Also added an additional job to the main.yml to capture this case.

@nvandessel
Copy link
Contributor Author

@webbertakken or @GabLeRoux, would love to get some feedback on this! 🙏

@GabLeRoux
Copy link
Member

Wow, that is some amazing work here. I've only did a first pass, read descriptions and comments and gave a quick look at the modified files and it looks good so far. Thanks for this great contribution! I've added a reminder to go in details through the provided code tonight.

I personally don't own a package for Unity at this time, nor one that would have external dependencies, but I do understand the feature request so I'll dig into this and add a review asap 👍

Nice one 🙌

@webbertakken webbertakken merged commit 9d8ff06 into game-ci:main Mar 14, 2024
@nvandessel nvandessel deleted the feature/scoped-registries branch May 31, 2024 18:02
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.

Feature: Support Package Testing for Packages with Dependencies Outside of the Unity Registry
3 participants