Build on Unity 2021.3 agent by AArnott · Pull Request #1530 · MessagePack-CSharp/MessagePack-CSharp · GitHub
Skip to content

Build on Unity 2021.3 agent#1530

Closed
AArnott wants to merge 21 commits into
MessagePack-CSharp:developfrom
AArnott:fixUnityBuild
Closed

Build on Unity 2021.3 agent#1530
AArnott wants to merge 21 commits into
MessagePack-CSharp:developfrom
AArnott:fixUnityBuild

Conversation

@AArnott

@AArnott AArnott commented Nov 20, 2022

Copy link
Copy Markdown
Collaborator

This should fix the unity build that broke in #1497, and open the way to C# 9 and netstandard2.1 targeting.

@neuecc

neuecc commented Nov 25, 2022

Copy link
Copy Markdown
Member

@AArnott

AArnott commented Nov 28, 2022

Copy link
Copy Markdown
Collaborator Author

Not stalled. Just erroring out.

@neuecc

neuecc commented Nov 28, 2022

Copy link
Copy Markdown
Member

@AArnott
I've tested in local, could you change build command of CI.
removes -nographics -silent-crashes -noUpm will work.

@AArnott

AArnott commented Nov 28, 2022

Copy link
Copy Markdown
Collaborator Author

I had to bring back -noGraphics because otherwise it failed with an error about not having any DISPLAY. And now although the error has gone away, the build appears to hang, which is a symptom I recall from a PR from a year or so ago when we last tried this.
But I have learned a trick about getting DISPLAY to work on linux build agents. If we think the hang is because of that, I can try 'fixing' that. But ultimately if it's a modal dialog box that is being displayed, that won't help us.

@neuecc

neuecc commented Nov 28, 2022

Copy link
Copy Markdown
Member

This command is brought from MemoryPack's CI, which is similarly configured and running on 2021.3.
https://github.com/Cysharp/MemoryPack/actions/runs/3563268776/jobs/5985866386

/opt/unity/Editor/Unity
-batchmode
-logfile
/dev/stdout
-quit
-customBuildName
StandaloneLinux64
-projectPath
/github/workspace/src/MemoryPack.Unity
-buildTarget
StandaloneLinux64
-customBuildTarget
StandaloneLinux64
-customBuildPath
/github/workspace/build/StandaloneLinux64/StandaloneLinux64
-executeMethod
PackageExporter.Export
-androidVersionCode
0
-androidKeystoreName

-androidKeystorePass

-androidKeyaliasName

-androidKeyaliasPass

-androidTargetSdkVersion

It is using https://github.com/game-ci/unity-builder
Maybe this is a using unity docker image https://github.com/game-ci/docker/blob/main/images/ubuntu/base/Dockerfile

@AArnott

AArnott commented Nov 28, 2022

Copy link
Copy Markdown
Collaborator Author

I tried the display emulation, but with -nographics removed it still fails with:

Error opening default X display. You must have a valid X server running.

(Unity:79906): Gtk-WARNING **: 06:32:46.267: cannot open display: 
##[error]Bash exited with code '1'.

I can try the docker image you suggested too.

@AArnott

AArnott commented Nov 28, 2022

Copy link
Copy Markdown
Collaborator Author

Well, building works when I run it on the agent myself, using the same script. I don't yet know why it fails when the build is orchestrated by AzP.

@neuecc

neuecc commented Nov 28, 2022

Copy link
Copy Markdown
Member

remove only -noUpm?

@neuecc

neuecc commented Nov 28, 2022

Copy link
Copy Markdown
Member

-noUpm causes 'UI' does not exist in the namespace 'UnityEngine' error after Unity update.
https://forum.unity.com/threads/command-line-build-fails-after-updating-to-unity-2019-4.937175/
In other words, the only problem is -noUpm, and -nographics may be okay to put on.

@AArnott

AArnott commented Nov 28, 2022

Copy link
Copy Markdown
Collaborator Author

-nographics may be okay to put on.

I figured as much. But it didn't work with that switch (and without -noUpm) either. I think that's when it appeared to hang, but I don't remember. I'll try again.
But according to this it seems (recent versions of?) unity simply always require an X server. The emulator I was trying should work according to that forum, but since I'm running an ubuntu 21 agent, I can't install it any more. I'll have to try upgrading that again.

@AArnott

AArnott commented Nov 28, 2022

Copy link
Copy Markdown
Collaborator Author

@neuecc What if we try switching at least the unity build to github actions to match memorypack? I pushed a change to this PR to do that, but it'll require access to your unity license secret. And it doesn't appear to be running in this PR and I'm not sure why.

@neuecc

neuecc commented Nov 29, 2022

Copy link
Copy Markdown
Member

I've added UNITY_LICENSE_2021 to github secret, I think GitHub Actions will now work.

@AArnott AArnott marked this pull request as ready for review December 1, 2022 22:01
@AArnott

AArnott commented Dec 1, 2022

Copy link
Copy Markdown
Collaborator Author

@neuecc The new github workflow still isn't running. Do you have any control as repo owner over that? Or if we have to merge to develop before it works, and odds are good it won't, are you ok to hash it out together after the merge?

@neuecc

neuecc commented Dec 2, 2022

Copy link
Copy Markdown
Member

ah, it is filter for main branch?
ok to merge but requires add for develop?

@AArnott

AArnott commented Dec 2, 2022

Copy link
Copy Markdown
Collaborator Author

Oh, I forgot to enable the develop branch in the github workflow file. I've fixed that. But I still don't see it showing up in this PR's validations.

@neuecc

neuecc commented Dec 2, 2022

Copy link
Copy Markdown
Member

image

image

Originally, secret using from matrix, change to same way?

  build-unity:
    if: "((github.event_name == 'push' && github.repository_owner == 'Cysharp') || startsWith(github.event.pull_request.head.label, 'Cysharp:'))"
    strategy:
      matrix:
        unity: ["2021.3.11f1"]
        include:
          - unity: 2021.3.11f1
            license: UNITY_LICENSE_2021
    runs-on: ubuntu-latest
    timeout-minutes: 15
    steps:
      - uses: actions/checkout@v3
      # Execute scripts: RuntimeUnitTestToolkit
      # /opt/Unity/Editor/Unity -quit -batchmode -nographics -silent-crashes -logFile -projectPath . -executeMethod UnitTestBuilder.BuildUnitTest /headless /ScriptBackend mono /BuildTarget StandaloneLinux64
      - name: Build UnitTest(Linux64, mono)
        uses: game-ci/unity-builder@v2
        env:
          UNITY_LICENSE: ${{ secrets[matrix.license] }}

@AArnott

AArnott commented Dec 2, 2022

Copy link
Copy Markdown
Collaborator Author

@neuecc It seems this repo may need more than just the UNITY_LICENSE_2021 secret. Per this docs, you also need to set UNITY_EMAIL and UNITY_PASSWORD as secrets.
I also wonder based on this doc whether the secret license code must be unique for each repo.
Alternatively, perhaps the problem is that (and security wise this would make sense), I can't submit a workflow file that can access your github secret until you approve that somehow. If that's the case, maybe this licensing error is because I don't have access yet.

@AArnott

AArnott commented Dec 2, 2022

Copy link
Copy Markdown
Collaborator Author

Per this doc, builds from repository forks don't get access to your secrets (which makes sense). This PR comes from a fork. I'll recreate from within your repo.

@AArnott

AArnott commented Dec 2, 2022

Copy link
Copy Markdown
Collaborator Author

@AArnott AArnott closed this Dec 2, 2022
@AArnott AArnott deleted the fixUnityBuild branch December 2, 2022 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants