unity-actions icon indicating copy to clipboard operation
unity-actions copied to clipboard

Move shared typescript code to this repo

Open davidmfinol opened this issue 2 years ago • 4 comments

The typescript unity actions (unity-request-activation-file, unity-activate, unity-test-runner, and unity-builder) have a lot of duplicated code between them. We should move all that duplicated code to this repo, and instead have those repos refer to this repo.

davidmfinol avatar Jan 11 '22 03:01 davidmfinol

Any hint on how to achieve this? There are probably other github actions that are sharing code out there.

  • Should it be a npm package? Allows versions which is nice
  • Or can we use git submodules?
  • Any other idea?

Personally, I prefer npm packages, but I don’t know what are the limitations when using github actions.

GabLeRoux avatar Jan 11 '22 04:01 GabLeRoux

I think having an npm package could work well. What do you think, @webbertakken ?

davidmfinol avatar Jan 11 '22 05:01 davidmfinol

In case we make another module I think the best way forward would be to have a monorepo. Initially GitHub Actions did not support monorepos because actions needed to be self-contained.

I've been thinking about how to sync common code between repositories and can think of the following solutions:

  • Keep them separate and sync them periodically using some repo-compare tool
  • Using an npm module for common functionality
  • Using a docker image as the middle layer
  • Move all actions to one repository
  • Make 1 main action, that has a bigger api that's not published on the marketplace and use composite actions to call just that 1 action to either build, test, activate etc.

I've been holding off on doing any of these because GitHub Actions were early days when I created the actions and I was hoping that monorepo support would become a thing.

About monorepo

In my opinion the monorepo approach would be the most manageable one, as it keeps the context of changes for both core and the action within 1 PR, and makes versioning that much easier.

It's currently possible however the mentioned repo does not have their action published in the Marketplace it seems.

Let's ask GitHub if it's somehow possible to publish multiple actions from the same repo, so that wee could publish game-ci/unity/builder and game-ci/unity/test-runner from the same repo and have a core module in there for the shared code.

Composite vs npm modulee vs docker

If it turns out not to be possible to publish multiple actions from the same repository, we'll have to choose between using an npm module, docker or turn the actions into composite one and call a central action (the central action could still be a monorepo as it doesn't need to be published).

With the eyes on the future, perhaps making a monorepo (core) and using composite actions (our existing builder, test-runner, activate etc) to call its actions might be a good idea - it would allow us to have shared code and keep changes in context of a single PR.

WDYT?

webbertakken avatar Jan 11 '22 11:01 webbertakken

With the eyes on the future, perhaps making a monorepo (core) and using composite actions (our existing builder, test-runner, activate etc) to call its actions might be a good idea - it would allow us to have shared code and keep changes in context of a single PR.

I like this idea a lot, especially if GitHub comes back and says it's not possible to publish multiple actions from the same repo.

davidmfinol avatar Jan 11 '22 12:01 davidmfinol