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

Feature: Add Caching for Package Testing #226

Open
trudeaua21 opened this issue Jun 10, 2023 · 0 comments
Open

Feature: Add Caching for Package Testing #226

trudeaua21 opened this issue Jun 10, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@trudeaua21
Copy link
Contributor

Context

Package testing is done by the following series of steps:

  1. creating a Unity Project
  2. Adding the Unity Package being tested to that project
  3. Running tests on the Unity Project.

It would be nice to somehow cache the Unity Project after the first run of the action so that it doesn't have to be remade each time the action is run.

Suggested solution

Leveraging GitHub's existing cache library on NPM seems like it would be the right way to go here.

I haven't really worked with the feature itself in a while, so this may have some mistakes, but I think that the following non-exhaustive list of changes would be a good start for a solution to the problem:

  1. In src/main.ts, use @actions/cache to check/restore the cache for the Unity Project which the test runner creates.
  2. In src/main.ts, add an argument to Docker.run called cachedProjectPath or something like that, which will be blank if the cache was not found, and the path to the Unity Project which was restored from the cache if the cache was found. Ensure that the new argument is set up properly to be available to the bash scripts.
  3. In dist/run_tests.sh, wrap the creation of the Unity Project (the unity-editor -batchmode -createProject call) in a conditional that checks for the cachedProjectPath variable. If it's blank, do what we do now - create a new Unity project and add the package to the project's dependencies. If the cached project path is present, re-add the package to the cached project's dependencies (or otherwise check that the project is depending on the package correctly).
  4. Have the tests run as normal
  5. If the cache wasn't found, cache the Unity project that was newly created.

I say that those steps are non-exhaustive, as it ignores certain implementation details, included but not limited to:

  • How the cache key is set up for hits and misses. We should certainly take Unity version into account here, but there may be more considerations past that.

Considered alternatives

An alternative could be to somehow factor out the creation of the Unity Project (step 1 in the context section above) to its own workflow step before the test runner runs. Then, that project could be independently cached with the cache action, and somehow passed in to the test runner.

Despite the fact that this kind of gives more control to the user, I think that this would be a worse solution though, as it still requires a good bit of work for way worse UX for the average user.

Additional details

There has been at least two people who have requested this feature, as can be seen here and here.

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

No branches or pull requests

2 participants