Skip to content

feat: Separate CI jobs into workflows #1989

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 138 additions & 0 deletions .github/workflows/android-smoke-test-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
on:
workflow_call:
inputs:
unity-version:
required: true
type: string

defaults:
run:
shell: pwsh

jobs:
build:
name: ${{ inputs.unity-version }}
runs-on: ubuntu-latest
strategy:
matrix:
include:
- platform: Android
check_symbols: false
build_platform: Android-Export
env:
UNITY_PATH: docker exec unity unity-editor

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@f68fdb76e2ea636224182cfb7377ff9a1708f9b8
with:
android: true
dotnet: false
haskell: true
large-packages: false
docker-images: false
swap-storage: true

- run: echo "::add-mask::${{ secrets.LICENSE_SERVER_URL }}"

- name: Docker Login
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # pinned v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Start the Unity docker container
run: ./scripts/ci-docker.sh '${{ inputs.unity-version }}' 'android' '${{ secrets.UNITY_LICENSE_SERVER_CONFIG }}'
shell: bash

# Workaround for missing libMonoPosixHelper.so
# See https://github.com/getsentry/sentry-unity/pull/1295
- name: Install mono-devel
if: ${{ inputs.unity-version == '2019' }}
run: |
docker exec --user root unity apt-get update
docker exec --user root unity apt-get -y -q install mono-devel

- name: Download IntegrationTest project
uses: actions/download-artifact@v4
with:
name: smoke-test-${{ inputs.unity-version }}

- name: Extract project archive
run: tar -xvzf test-project.tar.gz

- name: Download UPM package
uses: vaind/download-artifact@e7141b6a94ef28aa3d828b52830cfa1f406a1848
with:
name: ${{ github.sha }}
wait-timeout: 3600

- name: Extract UPM package
run: ./test/Scripts.Integration.Test/extract-package.ps1

- name: Add Sentry to the project
run: ./test/Scripts.Integration.Test/add-sentry.ps1 -UnityPath "${{ env.UNITY_PATH }}"

- name: Configure Sentry
run: ./test/Scripts.Integration.Test/configure-sentry.ps1 -UnityPath "${{ env.UNITY_PATH }}" -Platform ${{ matrix.build_platform }} -CheckSymbols

- name: Build Project
run: ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "${{ env.UNITY_PATH }}" -Platform ${{ matrix.build_platform }} -CheckSymbols:$false -UnityVersion "${{ inputs.unity-version }}"

# We create tar explicitly because upload-artifact is slow for many files.
# TODO verify this is still true with upload-artifact@v4 which improved performance a lot.
- name: Create archive
shell: bash
run: |
# Note: remove local.properties file that contains Android SDK & NDK paths in the Unity installation.
rm -rf samples/IntegrationTest/Build/*_BackUpThisFolder_ButDontShipItWithYourGame
tar -cvzf test-app-runtime.tar.gz samples/IntegrationTest/Build

# Upload runtime initialization build
- name: Upload test app
uses: actions/upload-artifact@v4
with:
name: testapp-android-${{ inputs.unity-version }}-runtime
if-no-files-found: error
path: test-app-runtime.tar.gz
retention-days: 14

- name: Configure Sentry for mobile platforms (build-time initialization)
run: |
$optionsPath = "samples/IntegrationTest/Assets/Scripts/OptionsConfiguration.cs"
$content = Get-Content $optionsPath -Raw
$content = $content -replace 'AndroidNativeInitializationType = NativeInitializationType.Runtime', 'AndroidNativeInitializationType = NativeInitializationType.BuildTime'
Set-Content $optionsPath $content

- name: Build Project for mobile platforms (build-time initialization)
run: ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "${{ env.UNITY_PATH }}" -Platform ${{ matrix.build_platform }} -CheckSymbols:$false -UnityVersion "${{ inputs.unity-version }}"

- name: Create archive (build-time initialization)
shell: bash
run: |
rm -rf samples/IntegrationTest/Build/*_BackUpThisFolder_ButDontShipItWithYourGame
tar -cvzf test-app-buildtime.tar.gz samples/IntegrationTest/Build

# Upload build-time initialization build
- name: Upload test app (build-time initialization)
uses: actions/upload-artifact@v4
with:
name: testapp-android-${{ inputs.unity-version }}-buildtime
if-no-files-found: error
path: test-app-buildtime.tar.gz
retention-days: 14

- name: Upload IntegrationTest project on failure
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: failed-project-android-${{ inputs.unity-version }}
path: |
samples/IntegrationTest
!samples/IntegrationTest/Build/*_BackUpThisFolder_ButDontShipItWithYourGame
# Lower retention period - we only need this to retry CI.
retention-days: 14
87 changes: 87 additions & 0 deletions .github/workflows/android-smoke-test-compile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
on:
workflow_call:
inputs:
unity-version:
required: true
type: string
init-type:
required: true
type: string

defaults:
run:
shell: pwsh

jobs:
compile:
name: ${{ inputs.unity-version }} ${{ inputs.init-type }}
runs-on: 'ubuntu-latest-4-cores'

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Download app project
uses: actions/download-artifact@v4
with:
name: testapp-android-${{ inputs.unity-version }}-${{ inputs.init-type }}

- name: Extract app project
run: tar -xvzf test-app-${{ inputs.init-type }}.tar.gz

- name: Setup Android
uses: android-actions/setup-android@7c5672355aaa8fde5f97a91aa9a99616d1ace6bc # pin@v2

- name: Setup NDK
uses: nttld/setup-ndk@8c3b609ff4d54576ea420551943fd34b4d03b0dc # pin@v1
id: setup-ndk
with:
# See supported version in https://docs.unity3d.com/6000.0/Documentation/Manual/android-sdksetup.html
ndk-version: ${{ inputs.unity-version == '2019' && 'r19' || 'r23b' }}
add-to-path: false

- name: Setup Java for Unity
run: ./scripts/ci-setup-java.ps1 -UnityVersion "${{ inputs.unity-version }}"

# We modify the exported gradle project to deal with the different build-environment
# I.e. we're fixing the paths for SDK & NDK that have been hardcoded to point at the Unity installation
- name: Modify gradle project
run: |
./test/Scripts.Integration.Test/modify-gradle-project.ps1 `
-AndroidSdkRoot $env:ANDROID_SDK_ROOT `
-NdkPath ${{ steps.setup-ndk.outputs.ndk-path }} `
-UnityVersion ${{ inputs.unity-version }}

- name: Android smoke test
# Skipping Android on Unity 2022 for now
run: |
if ("${{ inputs.unity-version }}" -ne "2022")
{
./scripts/smoke-test-android.ps1 Build -IsIntegrationTest -UnityVersion "${{ inputs.unity-version }}"
}
timeout-minutes: 10
env:
JAVA_HOME: ${{ env.JAVA_HOME }}

- name: Upload integration-test project on failure
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: failed-project-android-${{ inputs.unity-version }}-${{ inputs.init-type }}-compiled
path: |
samples/IntegrationTest
!samples/IntegrationTest/Build/*_BackUpThisFolder_ButDontShipItWithYourGame
# Lower retention period - we only need this to retry CI.
retention-days: 14

- name: Upload app
uses: actions/upload-artifact@v4
# Skipping Android on Unity 2022 for now
if: ${{ inputs.unity-version != '2022' }}
with:
name: testapp-android-compiled-${{ inputs.unity-version }}-${{ inputs.init-type }}
# Collect app but ignore the files that are not required for the test.
path: |
samples/IntegrationTest/Build/*.apk
# Lower retention period - we only need this to retry CI.
retention-days: 14
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,29 @@ on:
description: "Smoke test status"
value: ${{ jobs.run.outputs.status }}

defaults:
run:
shell: pwsh

jobs:
run:
name: Android Smoke Test
name: ${{ inputs.unity-version }} ${{ inputs.init-type }}
runs-on: ubuntu-latest
env:
ARTIFACTS_PATH: samples/IntegrationTest/test-artifacts/
HOMEBREW_NO_INSTALL_CLEANUP: 1
defaults:
run:
shell: pwsh
# Map the job outputs to step outputs
outputs:
status: ${{ steps.smoke-test.outputs.status }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Download test app artifact
uses: actions/download-artifact@v4
with:
name: testapp-Android-compiled-${{ inputs.unity-version }}-${{ inputs.init-type }}
name: testapp-android-compiled-${{ inputs.unity-version }}-${{ inputs.init-type }}
path: samples/IntegrationTest/Build

# See https://github.blog/changelog/2023-02-23-hardware-accelerated-android-virtualization-on-actions-windows-and-linux-larger-hosted-runners/
Expand Down
Loading