unity-test-runner icon indicating copy to clipboard operation
unity-test-runner copied to clipboard

Package Testing Hangs if Package Being Tested is the Root Directory of the Repository

Open trudeaua21 opened this issue 1 year ago • 2 comments

Bug description

When testing a package, if the package is the root directory of the repository, the test runner hangs at least as long as the default timeout for GitHub Actions.

By "package is the root directory of the repository", I mean that the repository structure is as follows:

ROOT
-> README.md
-> Editor
-> Runtime
-> Tests
-> package.json
...

The opposite case, where this problem does not occur, is when the package is not the root directory of the repository, meaning that the repository structure is as follows:

ROOT
-> README.md
-> com.example.packagename
---> Editor
---> Runtime
---> Tests
---> package.json

How to reproduce

  1. Take a Unity Package (preferably one which has been successfully tested with the test runner already), and upload it into a GitHub repository of it's own, such that the directory containing the package is the root of the repository.
  2. Run the test runner on the repository, passing a value of . to the projectPath input for the action.
  3. Observe that the test runner hangs.

Expected behavior

It would be expected for a package in the root of the repository to work the same as a package stored in a subdirectory of the root of the respository.

Additional details

A while ago, I dug into this to try to finish it before the completion of the package testing feature, but to no avail. Here are the comments on the original package testing issue and PR which discuss this problem:

Here is my in-depth info dump on the problem

Here is a description of a workaround I performed

trudeaua21 avatar Jun 10 '23 20:06 trudeaua21

Leaving this here for visibility: the workaround I linked to in the issue was a bit hacky, but it got the job done.

Essentially, I just copied the entirety of the root directory of the repository into a subdirectory, then passed that subdirectory in for the projectPath input, which then allowed the package to work correctly.

Here's a direct link to the workflow file where I did this, and below is the specific step in my workflow I used to do the folder copy:

      - name: copy dir to new dir
        run: |
          pwd
          folderName=$(echo "${PWD##*/}")
          rsync -r "$GITHUB_WORKSPACE" "copiedProject" 
          ls -F "copiedProject/$folderName"

# then later give the test runner the projectPath arg with the value ./copiedProject/WhateverYourProjectNameIsHere

All that said, it's not a pretty solution, and maybe not even the best way to do the folder copy itself, since I probably just whipped it up in a hurry back when I was trying to debug this.

trudeaua21 avatar Jun 10 '23 20:06 trudeaua21

Thanks @trudeaua21 - also leaving this solution for moving into a separate folder:

          mkdir -p unity-package
          shopt -s extglob
          mv !(unity-package) unity-package/
          shopt -u extglob

cckelly avatar Jun 19 '24 12:06 cckelly