game-ci / unity-orb

Build and test Unity projects for several platforms using CircleCI.
https://circleci.com/developer/orbs/orb/game-ci/unity
MIT License
7 stars 12 forks source link

Linecoverage: No such file or directory #63

Open FrancoisGo opened 7 months ago

FrancoisGo commented 7 months ago

Bug description

When running editmode tests on circle ci I got this error : grep: Linecoverage: No such file or directory When looking in the circle ci orb I saw this line 718 : grep "$unity_project_full_path"/"$PARAM_TEST_PLATFORM"-coverage/Report/Summary.xml Linecoverage But if I'm right the grep command doesn't work like this it should be grep "string" path

How to reproduce

Run test on circle ci in editmode. Here is my circle ci job :

  test:
    executor:
      name: 'unity/ubuntu'
      target_platform: 'android'
      editor_version: '2022.3.11f1'
      resource_class: 'large'
    steps:
      - custom_checkout
      - unity/prepare-env:
          project-path: '******'
      - unity/test:
          project-path: '******'
          test-platform: 'editmode'
          custom-parameters: '-buildTarget "Android" -disable-assembly-updater -coverageOptions "useProjectSettings"'
FrancoisGo commented 7 months ago

When trying to fix it I got an error with the line after in the orb : mv "$unity_project_full_path"/"$PARAM_TEST_PLATFORM"-coverage/"$CIRCLE_PROJECT_REPONAME"-opencov/*Mode/TestCoverageResults_*.xml "$unity_project_full_path"/"$PARAM_TEST_PLATFORM"-coverage/coverage.xml Because in our case we have two TestCoverageResults files. And it tries to move two files in the coverage.xml.

FrancoisGo commented 7 months ago

To remove the errors I decided to remove the code coverage package from my project to avoid issues in the editmode tests. But after fixing the editmode tests I got an issue with the playmode tests saying there is no graphic device. The cause was the -nographic argument passed to the unity editor batch command line 695 in the circle ci orb.

FrancoisGo commented 7 months ago

After adding back the code coverage package and fixing the previous issues I got another one with the move command because our Unity project doesn't have the same name as the repository. So the variable $CIRCLE_PROJECT_REPONAME in the path causes us an error.

Here is a fix I use :

if grep -q "$code_coverage_package" "$package_manifest_path"; then
                      apt-get install -y xml-twig-tools
                      grep Linecoverage "$unity_project_full_path"/"$PARAM_TEST_PLATFORM"-coverage/Report/Summary.xml
                      xml_grep --pretty_print indented --wrap Modules --descr '' --cond "Module" "$unity_project_full_path"/"$PARAM_TEST_PLATFORM"-coverage/*-opencov/*Mode/TestCoverageResults_*.xml > "$unity_project_full_path"/"$PARAM_TEST_PLATFORM"-coverage/coverage.xml
                      rm -r "$unity_project_full_path"/"$PARAM_TEST_PLATFORM"-coverage/*-opencov/

Also at the end of the command I added this to store the coverage result in the artifactory :

- store_artifacts:
            path: << parameters.project-path >>/<< parameters.test-platform >>-coverage
            destination: coverage

I also removed the -nographic of the unity params. Now I pass it with the custom param for the edit mode tests and the play mode tests are working fine.

FrancoisGo commented 6 months ago

I don't know why my private repository merge is in this ticket but it's a not a fix to this issue. Because here I'm still waiting the update of the unity circle ci orb with all the fix up there. So please can you reopen this issue and update this orb ?