|
| 1 | +name: Build mobile unit-test artifacts |
| 2 | +description: Build a component's platform test project and publish its artifacts. |
| 3 | + |
| 4 | +inputs: |
| 5 | + component: |
| 6 | + required: true |
| 7 | + description: Component whose test project is built (JsRuntimeHost) |
| 8 | + platform: |
| 9 | + required: true |
| 10 | + description: Android or iOS |
| 11 | + js-engine: |
| 12 | + default: JavaScriptCore |
| 13 | + description: JavaScript engine used by this platform configuration |
| 14 | + deployment-target: |
| 15 | + default: '26.0' |
| 16 | + description: Minimum iOS simulator version |
| 17 | + |
| 18 | +runs: |
| 19 | + using: composite |
| 20 | + steps: |
| 21 | + # Each component/platform pair names its existing Gradle or CMake test project |
| 22 | + # and outputs; the shared steps below configure, build, package and upload them. |
| 23 | + - name: Select ${{ inputs.component }} ${{ inputs.platform }} test project |
| 24 | + id: project |
| 25 | + shell: bash |
| 26 | + env: |
| 27 | + COMPONENT: ${{ inputs.component }} |
| 28 | + PLATFORM: ${{ inputs.platform }} |
| 29 | + JS_ENGINE: ${{ inputs.js-engine }} |
| 30 | + run: | |
| 31 | + case "$COMPONENT/$PLATFORM" in |
| 32 | + JsRuntimeHost/Android) |
| 33 | + project=Dependencies/JsRuntimeHost/Tests/UnitTests/Source/Android |
| 34 | + echo "gradle-project=$project" >> "$GITHUB_OUTPUT" |
| 35 | + ;; |
| 36 | + JsRuntimeHost/iOS) |
| 37 | + build=build/mobile-tests-JsRuntimeHost |
| 38 | + echo "cmake-source=Dependencies/JsRuntimeHost" >> "$GITHUB_OUTPUT" |
| 39 | + echo "cmake-build=$build" >> "$GITHUB_OUTPUT" |
| 40 | + echo "cmake-args=-DNAPI_JAVASCRIPT_ENGINE=$JS_ENGINE -DJSRUNTIMEHOST_TESTS=ON" >> "$GITHUB_OUTPUT" |
| 41 | + echo "cmake-target=UnitTests" >> "$GITHUB_OUTPUT" |
| 42 | + echo "app=$build/Tests/UnitTests/RelWithDebInfo-iphonesimulator/UnitTests.app" >> "$GITHUB_OUTPUT" |
| 43 | + ;; |
| 44 | + *) |
| 45 | + echo "::error::No $PLATFORM test project is defined for $COMPONENT" |
| 46 | + exit 1 |
| 47 | + ;; |
| 48 | + esac |
| 49 | + - name: Build and package Android ${{ inputs.component }} unit tests |
| 50 | + if: inputs.platform == 'Android' |
| 51 | + shell: bash |
| 52 | + env: |
| 53 | + PROJECT: ${{ steps.project.outputs.gradle-project }} |
| 54 | + JS_ENGINE: ${{ inputs.js-engine }} |
| 55 | + DESTINATION: test-artifacts/${{ inputs.component }} |
| 56 | + run: | |
| 57 | + bash .github/scripts/build-android-tests.sh "$PROJECT" "$JS_ENGINE" "$DESTINATION" |
| 58 | + - name: Configure iOS simulator ${{ inputs.component }} unit tests |
| 59 | + if: inputs.platform == 'iOS' |
| 60 | + shell: bash |
| 61 | + env: |
| 62 | + SOURCE: ${{ steps.project.outputs.cmake-source }} |
| 63 | + BUILD: ${{ steps.project.outputs.cmake-build }} |
| 64 | + PROJECT_ARGS: ${{ steps.project.outputs.cmake-args }} |
| 65 | + DEPLOYMENT_TARGET: ${{ inputs.deployment-target }} |
| 66 | + run: | |
| 67 | + cmake -S "$SOURCE" -B "$BUILD" -G Xcode \ |
| 68 | + -DIOS=ON -DPLATFORM=SIMULATORARM64 \ |
| 69 | + "-DDEPLOYMENT_TARGET=$DEPLOYMENT_TARGET" $PROJECT_ARGS |
| 70 | + - name: Build iOS simulator ${{ inputs.component }} unit tests |
| 71 | + if: inputs.platform == 'iOS' |
| 72 | + shell: bash |
| 73 | + env: |
| 74 | + BUILD: ${{ steps.project.outputs.cmake-build }} |
| 75 | + TARGET: ${{ steps.project.outputs.cmake-target }} |
| 76 | + run: | |
| 77 | + cmake --build "$BUILD" --config RelWithDebInfo --target "$TARGET" -- \ |
| 78 | + -sdk iphonesimulator -destination 'generic/platform=iOS Simulator' \ |
| 79 | + CODE_SIGNING_ALLOWED=NO |
| 80 | + - name: Package iOS unit-test artifacts |
| 81 | + if: inputs.platform == 'iOS' |
| 82 | + shell: bash |
| 83 | + env: |
| 84 | + DESTINATION: test-artifacts/${{ inputs.component }} |
| 85 | + APP: ${{ steps.project.outputs.app }} |
| 86 | + run: | |
| 87 | + mkdir -p "$DESTINATION" |
| 88 | + tar -czf "$DESTINATION/app.tar.gz" -C "$(dirname "$APP")" "$(basename "$APP")" |
| 89 | + - uses: actions/upload-artifact@v6 |
| 90 | + with: |
| 91 | + name: UnitTests-${{ inputs.platform }}-${{ inputs.component }}-${{ inputs.js-engine }} |
| 92 | + path: test-artifacts/${{ inputs.component }} |
| 93 | + if-no-files-found: error |
0 commit comments