diff --git a/.github/workflows/build-test-distribute.yml b/.github/workflows/build-test-distribute.yml index add332c87a3e..0c54f6fe5c0e 100644 --- a/.github/workflows/build-test-distribute.yml +++ b/.github/workflows/build-test-distribute.yml @@ -14,6 +14,10 @@ on: - cron: '0 17 * * *' # Run every day at 17:00 UTC #- cron: '0 6 * * *' # Run every day at 6 AM UTC +permissions: + id-token: write + contents: read + jobs: # NOTE: all output values are strings # use the ${{ needs.config.outputs.bool-param == 'true' }} construction to check boolean values @@ -248,6 +252,23 @@ jobs: path: MeshLib.nupkg retention-days: 1 + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: arn:aws:iam::259351611210:role/GitHubMeshLibAwsCredsRole + aws-region: us-east-1 + + - name: Upload NuGet Package to S3 + shell: powershell + run: aws s3 cp MeshLib.nupkg 's3://test-artifacts-git/MeshLib.nupkg' --quiet + + windows-unity-test: + needs: + - create-nuget-package + - windows-build-test + if: ${{ github.event_name == 'schedule' }} // triggered by schedule + uses: ./.github/workflows/unity-nuget-test.yml + upload-distributions: if: ${{ !cancelled() && needs.config.outputs.upload_artifacts == 'true' }} timeout-minutes: 10 diff --git a/.github/workflows/sign-upload-nuget.yml b/.github/workflows/sign-upload-nuget.yml index 273fa3549961..9c7eba16bb87 100644 --- a/.github/workflows/sign-upload-nuget.yml +++ b/.github/workflows/sign-upload-nuget.yml @@ -4,7 +4,6 @@ on: release: types: [ published ] workflow_dispatch: - jobs: setup: diff --git a/.github/workflows/unity-nuget-test.yml b/.github/workflows/unity-nuget-test.yml index 60d110e613e1..26ddc1a3c723 100644 --- a/.github/workflows/unity-nuget-test.yml +++ b/.github/workflows/unity-nuget-test.yml @@ -1,3 +1,4 @@ +name: Test Nuget package with Unity on: # Allows you to run this workflow manually from the Actions tab workflow_dispatch: @@ -7,14 +8,87 @@ permissions: id-token: write contents: read +concurrency: + group: unity-test + cancel-in-progress: false + jobs: + start-unity-instance: + name: Start unity instance + runs-on: aws-micro + outputs: + instance_started: ${{ steps.set-output.outputs.instance_started }} + steps: + - name: Configure AWS Credentials (OIDC) + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: arn:aws:iam::259351611210:role/GitHubMeshLibAwsStartStopInstances + aws-region: us-east-1 + - name: Start Instance + run: | + aws ec2 start-instances --instance-ids ${{ vars.UNITY_INSTANCE_ID }} + - name: Wait Instance + run: | + aws ec2 wait instance-status-ok --instance-ids ${{ vars.UNITY_INSTANCE_ID }} + unity-nuget-test: timeout-minutes: 10 + needs: [ start-unity-instance ] runs-on: [ self-hosted, windows, x64, unity, meshinspector ] - steps: - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v4 with: role-to-assume: arn:aws:iam::259351611210:role/EC2Github aws-region: us-east-1 + + - name: Copy nupkg from S3 + shell: powershell + # We use the constant fake version 1.0.0.3468 to simplify test workflow for Install package step + run: aws s3 cp s3://test-artifacts-git/MeshLib.nupkg C:/work/nuget_repo/MeshLib.1.0.0.3468.nupkg --quiet + + - name: rm previous data + shell: powershell + run: | + Remove-Item -Path "C:\work\unity_proj\NugetTestProj\Assets\Packages" -Recurse -Force -ErrorAction SilentlyContinue + Remove-Item -Path "C:\work\results.xml" -ErrorAction SilentlyContinue + Remove-Item -Path "C:\work\batch_log.txt" -ErrorAction SilentlyContinue + + - name: Install nuget package + shell: powershell + run: | + C:\\Users\\Administrator\\.dotnet\\tools\\nugetforunity.exe restore "C:\work\unity_proj\NugetTestProj" + + - name: Run test + shell: powershell + run: | + Start-Process -FilePath "C:\work\unity_editor\6000.0.40f1\Editor\Unity.exe" -ArgumentList "-runTests", "-batchmode", "-projectPath", "C:\work\unity_proj\NugetTestProj", "-testPlatform", "playmode", "-testResults", "C:\work\results.xml", "-logfile", "C:\work\batch_log.txt" -Wait + + + - name: verify xml + shell: powershell + run: | + [xml]$xml = Get-Content "C:\work\results.xml" + if ($xml.'test-run'.failed -eq "0") { Write-Output "All tests passed"; exit 0 } else { Write-Output "Errors in results.xml found"; exit 1} + + - name: upload logs + if: always() + shell: powershell + run: | + aws s3 cp C:\work\batch_log.txt s3://test-artifacts-git/batch_log.txt + aws s3 cp C:\work\results.xml s3://test-artifacts-git/results.xml + + + stop-instance: + runs-on: aws-micro + needs: [ unity-nuget-test ] + if: always() + steps: + - name: Configure AWS Credentials (OIDC) + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: arn:aws:iam::259351611210:role/GitHubMeshLibAwsStartStopInstances + aws-region: us-east-1 + - name: Stop Instance + run: | + aws ec2 stop-instances --instance-ids ${{ vars.UNITY_INSTANCE_ID }} \ No newline at end of file