game-ci / unity-test-runner

Run tests for any Unity project
https://github.com/marketplace/actions/unity-test-runner
MIT License
206 stars 135 forks source link

Add support for Scoped Registries #261

Closed nvandessel closed 5 months ago

nvandessel commented 6 months ago

Changes

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.

Checklist

github-actions[bot] commented 6 months ago

Cat Gif

github-actions[bot] commented 6 months ago

Cat Gif

nvandessel commented 6 months ago

@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 commented 6 months ago

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 commented 6 months ago

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 commented 6 months ago

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 commented 5 months ago

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

GabLeRoux commented 5 months ago

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 🙌