Search Unity

CI solutions for open source UPM packages

Discussion in 'Package Manager' started by dlegare-synapse, Dec 13, 2019.

  1. dlegare-synapse

    dlegare-synapse

    Joined:
    Jan 17, 2018
    Posts:
    54
    I've started hosting some small UPM packages on GitHub, and I'm quickly running into problems setting up CI and test automation for my packages. In order to run Unity in a headless environment, you seem to need a username, password, and serial number in order to activate a license on the build machine and run Unity. Having to provide a username and password is fine, but as far as I can tell you only get a serial number with a paid license. This poses a couple of problems for people trying to provide open source packages:
    • Paid licenses cost money, which is a big obstacle for anyone providing free packages. For hobbyist developers and professional devs maintaining packages in their free time, having to pay for licenses just to test their packages on CI.
    • A given license can only be active on two machines at a time. You can return the license once the build finishes, so in practice this limits the number of concurrent builds you can run without paying for more licenses: Even if I'm willing to pay for a license, I can only have two concurrent builds running across all projects that I maintain. Even on a single project, if I want to try to build on macOS, Windows, and Linux in parallel I'm going to run into problems.
    • It's unclear if running a paid license on a remote CI server is even allowed. As far as I know, you're only allowed to activate your license on hardware that you own, which would mean that remote CI solutions like GitHub Actions and Travis CI wouldn't be allowed. If this is the case, it's especially problematic for open source developers who rely on those services.
    In addition to the licensing issues, there's also the problem that you can't test a UPM package in isolation. As far as I can tell, you need a full Unity project in order to load a UPM package and run tests. This means that if you have a UPM package at the root of a Git repo (which is necessary in order to include it as a git dependency in a Unity project) you have to generate a temporary Unity project in order to run test in CI.

    At this point I have two main questions:
    • Does anyone have any examples of successful attempts to run CI for an open source UPM package? I'm curious how people have worked around the above issues in their projects. The only other solution I've seen so far has been to use a Docker container, which seems to work with manual license activation but has been very difficult to setup and seems to be pretty finicky.
    • Are there any plans to add functionality to Unity to make CI for packages easier? For example, it would be great to be able to directly load a package and run its tests without needing a full Unity project setup, especially if doing so didn't require an active license. Such a change would greatly simplify the requirements for doing continuous integration for UPM packages.
     
    Last edited: Dec 16, 2019
  2. Favo-Yang

    Favo-Yang

    Joined:
    Apr 4, 2011
    Posts:
    464
    This is an interesting topic. Two ideas
    - Leverage Unity Cloud Build to offer free plan for open source projects, and even better to make an integrated github apps for CI. After all the unity guys have made lots efforts on improving the cloud build with various additional features.
    - Provide a test only license option.
    Anyway only unity folks can anwser the questions.

    For the project layout. One possible layout is that use the test project as the repo root, put your upm package under `Packages` folder as a local package. For release, use git subtree to create a valid upm branch, then tag it as a release. i.e. https://github.com/mob-sakai/UpmGitExtension/tree/master
     
    dlegare-synapse likes this.
  3. dlegare-synapse

    dlegare-synapse

    Joined:
    Jan 17, 2018
    Posts:
    54
    I like both of those suggestions! Having a test-only license would be a great solution here, since it would allow folks to use any CI system to test their Unity project without changing the licensing requirements around releasing a full game. Providing free builds to open source projects would also be a great way for Unity to provide support for open source projects :D
     
  4. dlegare-synapse

    dlegare-synapse

    Joined:
    Jan 17, 2018
    Posts:
    54
    Alternatively, having a way to activate a free personal license from the command line would be a perfectly acceptable solution. As far as I can tell, using Unity to develop non-commercial open source tools is fine under a personal license, so long as any commercial use of those tools is covered by a paid license. The only thing currently preventing me from running CI for my projects using a personal license is that there doesn't seem to be a way to activate a personal license from the command line.