Skip to content

Commit 003a4d2

Browse files
authored
feat: Separate CI jobs into workflows (#1989)
1 parent 6573fbc commit 003a4d2

10 files changed

+811
-406
lines changed
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
on:
2+
workflow_call:
3+
inputs:
4+
unity-version:
5+
required: true
6+
type: string
7+
8+
defaults:
9+
run:
10+
shell: pwsh
11+
12+
jobs:
13+
build:
14+
name: ${{ inputs.unity-version }}
15+
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
include:
19+
- platform: Android
20+
check_symbols: false
21+
build_platform: Android-Export
22+
env:
23+
UNITY_PATH: docker exec unity unity-editor
24+
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v3
28+
29+
- name: Free Disk Space (Ubuntu)
30+
uses: jlumbroso/free-disk-space@f68fdb76e2ea636224182cfb7377ff9a1708f9b8
31+
with:
32+
android: true
33+
dotnet: false
34+
haskell: true
35+
large-packages: false
36+
docker-images: false
37+
swap-storage: true
38+
39+
- run: echo "::add-mask::${{ secrets.LICENSE_SERVER_URL }}"
40+
41+
- name: Docker Login
42+
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # pinned v3
43+
with:
44+
registry: ghcr.io
45+
username: ${{ github.actor }}
46+
password: ${{ secrets.GITHUB_TOKEN }}
47+
48+
- name: Start the Unity docker container
49+
run: ./scripts/ci-docker.sh '${{ inputs.unity-version }}' 'android' '${{ secrets.UNITY_LICENSE_SERVER_CONFIG }}'
50+
shell: bash
51+
52+
# Workaround for missing libMonoPosixHelper.so
53+
# See https://github.com/getsentry/sentry-unity/pull/1295
54+
- name: Install mono-devel
55+
if: ${{ inputs.unity-version == '2019' }}
56+
run: |
57+
docker exec --user root unity apt-get update
58+
docker exec --user root unity apt-get -y -q install mono-devel
59+
60+
- name: Download IntegrationTest project
61+
uses: actions/download-artifact@v4
62+
with:
63+
name: smoke-test-${{ inputs.unity-version }}
64+
65+
- name: Extract project archive
66+
run: tar -xvzf test-project.tar.gz
67+
68+
- name: Download UPM package
69+
uses: vaind/download-artifact@e7141b6a94ef28aa3d828b52830cfa1f406a1848
70+
with:
71+
name: ${{ github.sha }}
72+
wait-timeout: 3600
73+
74+
- name: Extract UPM package
75+
run: ./test/Scripts.Integration.Test/extract-package.ps1
76+
77+
- name: Add Sentry to the project
78+
run: ./test/Scripts.Integration.Test/add-sentry.ps1 -UnityPath "${{ env.UNITY_PATH }}"
79+
80+
- name: Configure Sentry
81+
run: ./test/Scripts.Integration.Test/configure-sentry.ps1 -UnityPath "${{ env.UNITY_PATH }}" -Platform ${{ matrix.build_platform }} -CheckSymbols
82+
83+
- name: Build Project
84+
run: ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "${{ env.UNITY_PATH }}" -Platform ${{ matrix.build_platform }} -CheckSymbols:$false -UnityVersion "${{ inputs.unity-version }}"
85+
86+
# We create tar explicitly because upload-artifact is slow for many files.
87+
# TODO verify this is still true with upload-artifact@v4 which improved performance a lot.
88+
- name: Create archive
89+
shell: bash
90+
run: |
91+
# Note: remove local.properties file that contains Android SDK & NDK paths in the Unity installation.
92+
rm -rf samples/IntegrationTest/Build/*_BackUpThisFolder_ButDontShipItWithYourGame
93+
tar -cvzf test-app-runtime.tar.gz samples/IntegrationTest/Build
94+
95+
# Upload runtime initialization build
96+
- name: Upload test app
97+
uses: actions/upload-artifact@v4
98+
with:
99+
name: testapp-android-${{ inputs.unity-version }}-runtime
100+
if-no-files-found: error
101+
path: test-app-runtime.tar.gz
102+
retention-days: 14
103+
104+
- name: Configure Sentry for mobile platforms (build-time initialization)
105+
run: |
106+
$optionsPath = "samples/IntegrationTest/Assets/Scripts/OptionsConfiguration.cs"
107+
$content = Get-Content $optionsPath -Raw
108+
$content = $content -replace 'AndroidNativeInitializationType = NativeInitializationType.Runtime', 'AndroidNativeInitializationType = NativeInitializationType.BuildTime'
109+
Set-Content $optionsPath $content
110+
111+
- name: Build Project for mobile platforms (build-time initialization)
112+
run: ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "${{ env.UNITY_PATH }}" -Platform ${{ matrix.build_platform }} -CheckSymbols:$false -UnityVersion "${{ inputs.unity-version }}"
113+
114+
- name: Create archive (build-time initialization)
115+
shell: bash
116+
run: |
117+
rm -rf samples/IntegrationTest/Build/*_BackUpThisFolder_ButDontShipItWithYourGame
118+
tar -cvzf test-app-buildtime.tar.gz samples/IntegrationTest/Build
119+
120+
# Upload build-time initialization build
121+
- name: Upload test app (build-time initialization)
122+
uses: actions/upload-artifact@v4
123+
with:
124+
name: testapp-android-${{ inputs.unity-version }}-buildtime
125+
if-no-files-found: error
126+
path: test-app-buildtime.tar.gz
127+
retention-days: 14
128+
129+
- name: Upload IntegrationTest project on failure
130+
if: ${{ failure() }}
131+
uses: actions/upload-artifact@v4
132+
with:
133+
name: failed-project-android-${{ inputs.unity-version }}
134+
path: |
135+
samples/IntegrationTest
136+
!samples/IntegrationTest/Build/*_BackUpThisFolder_ButDontShipItWithYourGame
137+
# Lower retention period - we only need this to retry CI.
138+
retention-days: 14
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
on:
2+
workflow_call:
3+
inputs:
4+
unity-version:
5+
required: true
6+
type: string
7+
init-type:
8+
required: true
9+
type: string
10+
11+
defaults:
12+
run:
13+
shell: pwsh
14+
15+
jobs:
16+
compile:
17+
name: ${{ inputs.unity-version }} ${{ inputs.init-type }}
18+
runs-on: 'ubuntu-latest-4-cores'
19+
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v3
23+
24+
- name: Download app project
25+
uses: actions/download-artifact@v4
26+
with:
27+
name: testapp-android-${{ inputs.unity-version }}-${{ inputs.init-type }}
28+
29+
- name: Extract app project
30+
run: tar -xvzf test-app-${{ inputs.init-type }}.tar.gz
31+
32+
- name: Setup Android
33+
uses: android-actions/setup-android@7c5672355aaa8fde5f97a91aa9a99616d1ace6bc # pin@v2
34+
35+
- name: Setup NDK
36+
uses: nttld/setup-ndk@8c3b609ff4d54576ea420551943fd34b4d03b0dc # pin@v1
37+
id: setup-ndk
38+
with:
39+
# See supported version in https://docs.unity3d.com/6000.0/Documentation/Manual/android-sdksetup.html
40+
ndk-version: ${{ inputs.unity-version == '2019' && 'r19' || 'r23b' }}
41+
add-to-path: false
42+
43+
- name: Setup Java for Unity
44+
run: ./scripts/ci-setup-java.ps1 -UnityVersion "${{ inputs.unity-version }}"
45+
46+
# We modify the exported gradle project to deal with the different build-environment
47+
# I.e. we're fixing the paths for SDK & NDK that have been hardcoded to point at the Unity installation
48+
- name: Modify gradle project
49+
run: |
50+
./test/Scripts.Integration.Test/modify-gradle-project.ps1 `
51+
-AndroidSdkRoot $env:ANDROID_SDK_ROOT `
52+
-NdkPath ${{ steps.setup-ndk.outputs.ndk-path }} `
53+
-UnityVersion ${{ inputs.unity-version }}
54+
55+
- name: Android smoke test
56+
# Skipping Android on Unity 2022 for now
57+
run: |
58+
if ("${{ inputs.unity-version }}" -ne "2022")
59+
{
60+
./scripts/smoke-test-android.ps1 Build -IsIntegrationTest -UnityVersion "${{ inputs.unity-version }}"
61+
}
62+
timeout-minutes: 10
63+
env:
64+
JAVA_HOME: ${{ env.JAVA_HOME }}
65+
66+
- name: Upload integration-test project on failure
67+
if: ${{ failure() }}
68+
uses: actions/upload-artifact@v4
69+
with:
70+
name: failed-project-android-${{ inputs.unity-version }}-${{ inputs.init-type }}-compiled
71+
path: |
72+
samples/IntegrationTest
73+
!samples/IntegrationTest/Build/*_BackUpThisFolder_ButDontShipItWithYourGame
74+
# Lower retention period - we only need this to retry CI.
75+
retention-days: 14
76+
77+
- name: Upload app
78+
uses: actions/upload-artifact@v4
79+
# Skipping Android on Unity 2022 for now
80+
if: ${{ inputs.unity-version != '2022' }}
81+
with:
82+
name: testapp-android-compiled-${{ inputs.unity-version }}-${{ inputs.init-type }}
83+
# Collect app but ignore the files that are not required for the test.
84+
path: |
85+
samples/IntegrationTest/Build/*.apk
86+
# Lower retention period - we only need this to retry CI.
87+
retention-days: 14

.github/workflows/android-smoke-test.yml renamed to .github/workflows/android-smoke-test-run.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,29 @@ on:
1616
description: "Smoke test status"
1717
value: ${{ jobs.run.outputs.status }}
1818

19+
defaults:
20+
run:
21+
shell: pwsh
22+
1923
jobs:
2024
run:
21-
name: Android Smoke Test
25+
name: ${{ inputs.unity-version }} ${{ inputs.init-type }}
2226
runs-on: ubuntu-latest
2327
env:
2428
ARTIFACTS_PATH: samples/IntegrationTest/test-artifacts/
2529
HOMEBREW_NO_INSTALL_CLEANUP: 1
26-
defaults:
27-
run:
28-
shell: pwsh
2930
# Map the job outputs to step outputs
3031
outputs:
3132
status: ${{ steps.smoke-test.outputs.status }}
33+
3234
steps:
3335
- name: Checkout
3436
uses: actions/checkout@v4
3537

3638
- name: Download test app artifact
3739
uses: actions/download-artifact@v4
3840
with:
39-
name: testapp-Android-compiled-${{ inputs.unity-version }}-${{ inputs.init-type }}
41+
name: testapp-android-compiled-${{ inputs.unity-version }}-${{ inputs.init-type }}
4042
path: samples/IntegrationTest/Build
4143

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

0 commit comments

Comments
 (0)