Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
80 changes: 77 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
name: Test

on:
schedule:
- cron: "0 11 * * *" # 11am UTC = 3`am PST

pull_request:
types: [ labeled, closed ]

workflow_dispatch:
inputs:
unity_versions:
description: 'Unity version (value: 2018, 2019, 2020. separated by commas)'
unity_version:
description: 'Unity version (value: 2018, 2019, 2020)'
default: '2019'
required: true

Expand All @@ -13,7 +19,75 @@ env:
artifactRetentionDays: 2

jobs:
check_and_prepare:
runs-on: ubuntu-latest
outputs:
unity_version: ${{ steps.set_outputs.outputs.unity_version }}
steps:
- id: set_outputs
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "unity_version=${{ github.event.inputs.unity_version }}" >> $GITHUB_OUTPUT
else
# inputs are not available for non "workflow_dispatch" events. Therefore, set default value here.
echo "unity_version=2019" >> $GITHUB_OUTPUT
fi

- name: Print output
run: |
echo outputs.unity_version : ${{ steps.set_outputs.outputs.unity_version }}

test_on_macos:
name: test-macOS-unity${{ needs.check_and_prepare.outputs.unity_version }}
runs-on: macos-latest
needs: [check_and_prepare]
strategy:
fail-fast: false
steps:
- run: echo "Hello World"
- uses: actions/checkout@v3

- id: build_setup
uses: ./gha/build_setup
timeout-minutes: 30
with:
unity_version: ${{ needs.check_and_prepare.outputs.unity_version }}
platform: macOS
python_version: ${{ env.pythonVersion }}
unity_username: ${{ secrets.UNITY_USERNAME }}
unity_password: ${{ secrets.UNITY_PASSWORD }}
unity_serial_id: ${{ secrets.SERIAL_ID }}

- name: Set Unity Env for EDM4U build script
shell: bash
run: echo "UNITY_EXE=${{ env.UNITY_ROOT_DIR }}/Unity.app/Contents/MacOS/Unity" >> $GITHUB_ENV

- run: ./gradlew test -q -PINTERACTIVE_MODE_TESTS_ENABLED=0 -PEXCLUDE_TEST_TYPES=NUnit -PEXCLUDE_TEST_MODULES=PackageManager

- name: Print test log
if: always()
shell: bash
run: cat test_output/test*IntegrationTestsBatchMode/*.log

- name: Obtain Failed tests
if: always()
shell: bash
continue-on-error: true
run: |
cat test_output/test*/*_test.log | grep "^Test .* PASSED$"
cat test_output/test*/*_test.log | grep "^Test .* FAILED$"
cat test_output/test*/*_test.log | grep "^Test .* SKIPPED$"

- name: Return Unity license
if: always()
uses: firebase/firebase-unity-sdk/gha/unity@main
with:
version: ${{ inputs.unity_version }}
release_license: "true"

- name: Upload build logs
uses: actions/upload-artifact@v3
if: ${{ !cancelled() }}
with:
name: logs
path: test_output/test*/*.log
retention-days: ${{ env.artifactRetentionDays }}
63 changes: 34 additions & 29 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -1716,51 +1716,56 @@ task testDownloadArtifacts(type: GradleBuild) { task ->
finalizedBy "reportAllTestsResult"
}


/*
* Evaluate previously-ran test result
*
* @param testTask Task for previously-ran test
*/
void ReportTestStarted(Task testTask) {
println sprintf("::debug::Test %s STARTED", testTask.name)
}

/*
* Evaluate previously-ran test result
*
* @param testTask Task for previously-ran test
*/
void EvaluateTestResult(Task testTask) {
Boolean succeeded = false
if (testTask.class.simpleName.startsWith("Exec")) {
if (testTask.execResult.exitValue != 0) {
String errorMsg = sprintf("Test %s FAILED", testTask.name)
println sprintf("::error::%s", errorMsg)
project.ext.testSessions.add(new TestSession(
name: testTask.name,
type: testTask.ext.testType,
module: testTask.ext.testModule,
isPassed: false))
if (!project.ext.continueOnFailForTestsEnabled) {
throw new GradleException(errorMsg)
}
} else {
println sprintf("::debug::Test %s PASSED", testTask.name, testTask.execResult.exitValue)
project.ext.testSessions.add(new TestSession(
name: testTask.name,
type: testTask.ext.testType,
module: testTask.ext.testModule,
isPassed: true))
if (testTask.execResult.exitValue == 0) {
succeeded = true
}
} else if (testTask.class.simpleName.startsWith("DefaultTask") ||
testTask.class.simpleName.startsWith("GradleBuild")) {
if (testTask.state.didWork && testTask.state.failure == null) {
project.ext.testSessions.add(new TestSession(
name: testTask.name,
type: testTask.ext.testType,
module: testTask.ext.testModule,
isPassed: true))
} else {
project.ext.testSessions.add(new TestSession(
name: testTask.name,
type: testTask.ext.testType,
module: testTask.ext.testModule,
isPassed: false))
succeeded = true
}
} else {
throw new GradleException(
sprintf("Unsupported test class %s", testTask.class.simpleName))
}

if (succeeded) {
println sprintf("::debug::Test %s PASSED", testTask.name)
project.ext.testSessions.add(new TestSession(
name: testTask.name,
type: testTask.ext.testType,
module: testTask.ext.testModule,
isPassed: true))
} else {
String errorMsg = sprintf("Test %s FAILED", testTask.name)
println sprintf("::error::%s", errorMsg)
project.ext.testSessions.add(new TestSession(
name: testTask.name,
type: testTask.ext.testType,
module: testTask.ext.testModule,
isPassed: false))
if (!project.ext.continueOnFailForTestsEnabled) {
throw new GradleException(errorMsg)
}
}
}

Task reportAllTestsResult = tasks.create (
Expand Down
2 changes: 1 addition & 1 deletion gha/build_setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ runs:
with:
version: ${{ inputs.unity_version }}
# iOS build support is always required to build EDM4U
platforms: "${{ inputs.platform }},iOS"
platforms: "${{ inputs.platform }},iOS,Android"
username: ${{ inputs.unity_username }}
password: ${{ inputs.unity_password }}
serial_ids: ${{ inputs.unity_serial_id }}
Expand Down