From 59e82063255716ac6555e9027977b0ebcd55f47d Mon Sep 17 00:00:00 2001 From: Jian Chen Date: Mon, 20 Jan 2025 11:29:30 -0800 Subject: [PATCH] Reformat --- .../templates/react-native-ci.yml | 407 +++++++++--------- 1 file changed, 199 insertions(+), 208 deletions(-) diff --git a/tools/ci_build/github/azure-pipelines/templates/react-native-ci.yml b/tools/ci_build/github/azure-pipelines/templates/react-native-ci.yml index c30e6d97f1f40..b6afdb6fc30e9 100644 --- a/tools/ci_build/github/azure-pipelines/templates/react-native-ci.yml +++ b/tools/ci_build/github/azure-pipelines/templates/react-native-ci.yml @@ -42,6 +42,205 @@ stages: enable_code_sign: '${{parameters.enable_code_sign}}' pool_name: '${{parameters.PoolName}}' packageName: 'onnxruntime-android' +- stage: ReactNative_CI_Android + displayName: ReactNative_CI_Android + dependsOn: + - Build_Android_Packages + jobs: + - job: ReactNative_CI_Android + pool: + vmImage: 'macOS-13' + variables: + runCodesignValidationInjection: false + timeoutInMinutes: 90 + steps: + - task: UsePythonVersion@0 + displayName: Use python 3.12 + inputs: + versionSpec: "3.12" + addToPath: true + architecture: "x64" + + - task: JavaToolInstaller@0 + displayName: Use jdk 17 + inputs: + versionSpec: '17' + jdkArchitectureOption: 'x64' + jdkSourceOption: 'PreInstalled' + + - task: NodeTool@0 + inputs: + versionSpec: '20.x' + + - script: + brew install coreutils ninja npm yarn + displayName: Install coreutils, ninja, npm, and yarn + + - script: + yarn global add detox-cli + displayName: Install detox cli tools + + - script: + brew tap wix/brew + displayName: brew tap wix/brew + + - task: DownloadPipelineArtifact@2 + inputs: + buildType: 'current' + artifactName: 'onnxruntime-android-full-aar' + targetPath: '$(Build.BinariesDirectory)/android-full-aar' + displayName: Download Android AAR artifacts + + - task: CopyFiles@2 + inputs: + sourceFolder: $(Build.BinariesDirectory)/android-full-aar + contents: onnxruntime-android-*.aar + targetFolder: $(Build.SourcesDirectory)/js/react_native/android/libs + displayName: Copy Android package to React Native directory + + - script: | + npm ci + workingDirectory: '$(Build.SourcesDirectory)/js' + displayName: npm ci js + + - script: | + npm ci + workingDirectory: '$(Build.SourcesDirectory)/js/common' + displayName: npm ci js/common + + - script: | + yarn + workingDirectory: '$(Build.SourcesDirectory)/js/react_native' + displayName: yarn js/react_native + + - task: PowerShell@2 + inputs: + filePath: '$(Build.SourcesDirectory)/tools/ci_build/github/js/pack-npm-packages.ps1' + arguments: '"-dev.$(Get-Date -Format yyyyMMdd)-$(git rev-parse --short HEAD)" $(Build.SourcesDirectory) react_native' + workingDirectory: '$(Build.SourcesDirectory)' + errorActionPreference: stop + env: + ORT_JS_PACK_MODE: e2e + displayName: Pack NPM packages + + - script: | + mv $(Build.SourcesDirectory)/js/common/onnxruntime-common*.tgz onnxruntime-common.tgz + yarn add --no-lockfile file:./onnxruntime-common.tgz + mv $(Build.SourcesDirectory)/js/react_native/onnxruntime-react-native*.tgz onnxruntime-react-native.tgz + yarn add --no-lockfile file:./onnxruntime-react-native.tgz + yarn + workingDirectory: '$(Build.SourcesDirectory)/js/react_native/e2e' + displayName: Bootstrap Android and iOS e2e tests + + - script: | + yarn add --dev jest-junit + workingDirectory: '$(Build.SourcesDirectory)/js/react_native/e2e' + displayName: install jest junit reporter js/react_native/e2e + + - script: | + keytool -genkey -v -keystore debug.keystore -alias androiddebugkey -storepass android \ + -keypass android -keyalg RSA -keysize 2048 -validity 999999 -dname "CN=Android Debug,O=Android,C=US" + workingDirectory: '$(Build.SourcesDirectory)/js/react_native/e2e/android' + displayName: Generate a debug keystore + + - task: CopyFiles@2 + inputs: + sourceFolder: $(Build.BinariesDirectory)/android-full-aar + contents: onnxruntime-*.aar + targetFolder: $(Build.SourcesDirectory)/js/react_native/e2e/android/app/libs + displayName: Copy Android package to Android e2e test directory + + - script: | + detox build --configuration android.emu.release + workingDirectory: '$(Build.SourcesDirectory)/js/react_native/e2e' + displayName: Build React Native Detox Android e2e Tests + + # + # Unit tests and E2E tests with Android emulator + # + - template: use-android-emulator.yml + parameters: + create: true + start: true + + - template: android-dump-logs-from-steps.yml + parameters: + steps: + - task: Gradle@3 + inputs: + gradleWrapperFile: '$(Build.SourcesDirectory)/js/react_native/android/gradlew' + workingDirectory: '$(Build.SourcesDirectory)/js/react_native/android' + options: '--stacktrace' + tasks: 'connectedDebugAndroidTest' + publishJUnitResults: true + testResultsFiles: '**/TEST-*.xml' + testRunTitle: 'React Native Android Instrumented Test results' + sonarQubeRunAnalysis: false + spotBugsAnalysis: false + displayName: Run React Native Android Instrumented Tests + + - script: | + JEST_JUNIT_OUTPUT_FILE=$(Build.SourcesDirectory)/js/react_native/e2e/android-test-results.xml \ + detox test --record-logs all \ + --configuration android.emu.release \ + --loglevel trace \ + --take-screenshots failing + workingDirectory: '$(Build.SourcesDirectory)/js/react_native/e2e' + displayName: Run React Native Detox Android e2e Tests + + - template: use-android-emulator.yml + parameters: + stop: true + + - task: PublishTestResults@2 + inputs: + testResultsFiles: '$(Build.SourcesDirectory)/js/react_native/e2e/android-test-results.xml' + failTaskOnFailedTests: true + testRunTitle: 'React Native Detox Android e2e Test Results' + condition: succeededOrFailed() + displayName: Publish React Native Detox Android e2e Test Results + + - script: | + git restore . + workingDirectory: '$(Build.SourcesDirectory)/js' + displayName: Restore git changes + + - task: PowerShell@2 + inputs: + filePath: '$(Build.SourcesDirectory)/tools/ci_build/github/js/pack-npm-packages.ps1' + arguments: '"${{parameters.NpmPackagingMode}}" $(Build.SourcesDirectory) react_native' + workingDirectory: '$(Build.SourcesDirectory)' + errorActionPreference: stop + displayName: Pack NPM packages + + - task: CopyFiles@2 + inputs: + sourceFolder: $(Build.SourcesDirectory)/js/common + contents: onnxruntime-common*.tgz + targetFolder: $(Build.ArtifactStagingDirectory) + displayName: 'Create Artifacts onnxruntime-common' + + - task: CopyFiles@2 + inputs: + sourceFolder: $(Build.SourcesDirectory)/js/react_native + contents: onnxruntime-react-native*.tgz + targetFolder: $(Build.ArtifactStagingDirectory) + displayName: Create Artifacts onnxruntime-react-native + + - task: PublishPipelineArtifact@1 + inputs: + artifact: android_e2e_test_logs_$(Build.BuildId)_$(Build.BuildNumber)_$(System.JobAttempt) + targetPath: '$(Build.SourcesDirectory)/js/react_native/e2e/artifacts' + condition: succeededOrFailed() + displayName: Publish React Native Detox E2E test logs + + - task: PublishPipelineArtifact@0 + inputs: + artifactName: '${{parameters.PackageName}}' + targetPath: '$(Build.ArtifactStagingDirectory)' + displayName: Publish Pipeline Artifact + + - template: explicitly-defined-final-tasks.yml - stage: Build_iOS_Packages displayName: Build_iOS_Packages @@ -160,16 +359,6 @@ stages: ORT_JS_PACK_MODE: e2e displayName: Pack NPM packages - - task: PowerShell@2 - inputs: - filePath: '$(Build.SourcesDirectory)/tools/ci_build/github/js/pack-npm-packages.ps1' - arguments: '"-dev.$(Get-Date -Format yyyyMMdd)-$(git rev-parse --short HEAD)" $(Build.SourcesDirectory) react_native' - workingDirectory: '$(Build.SourcesDirectory)' - errorActionPreference: stop - env: - ORT_JS_PACK_MODE: e2e - displayName: Pack NPM packages - - script: | mv $(Build.SourcesDirectory)/js/common/onnxruntime-common*.tgz onnxruntime-common.tgz yarn add --no-lockfile file:./onnxruntime-common.tgz @@ -275,202 +464,4 @@ stages: - template: explicitly-defined-final-tasks.yml -- stage: ReactNative_CI_Android - displayName: ReactNative_CI_Android - dependsOn: - - Build_Android_Packages - jobs: - - job: ReactNative_CI_Android - pool: - vmImage: 'macOS-13' - variables: - runCodesignValidationInjection: false - timeoutInMinutes: 90 - steps: - - task: UsePythonVersion@0 - displayName: Use python 3.12 - inputs: - versionSpec: "3.12" - addToPath: true - architecture: "x64" - - - task: JavaToolInstaller@0 - displayName: Use jdk 17 - inputs: - versionSpec: '17' - jdkArchitectureOption: 'x64' - jdkSourceOption: 'PreInstalled' - - - task: NodeTool@0 - inputs: - versionSpec: '20.x' - - - script: - brew install coreutils ninja npm yarn - displayName: Install coreutils, ninja, npm, and yarn - - - script: - yarn global add detox-cli - displayName: Install detox cli tools - - - script: - brew tap wix/brew - displayName: brew tap wix/brew - - - task: DownloadPipelineArtifact@2 - inputs: - buildType: 'current' - artifactName: 'onnxruntime-android-full-aar' - targetPath: '$(Build.BinariesDirectory)/android-full-aar' - displayName: Download Android AAR artifacts - - - task: CopyFiles@2 - inputs: - sourceFolder: $(Build.BinariesDirectory)/android-full-aar - contents: onnxruntime-android-*.aar - targetFolder: $(Build.SourcesDirectory)/js/react_native/android/libs - displayName: Copy Android package to React Native directory - - - script: | - npm ci - workingDirectory: '$(Build.SourcesDirectory)/js' - displayName: npm ci js - - - script: | - npm ci - workingDirectory: '$(Build.SourcesDirectory)/js/common' - displayName: npm ci js/common - - - script: | - yarn - workingDirectory: '$(Build.SourcesDirectory)/js/react_native' - displayName: yarn js/react_native - - task: PowerShell@2 - inputs: - filePath: '$(Build.SourcesDirectory)/tools/ci_build/github/js/pack-npm-packages.ps1' - arguments: '"-dev.$(Get-Date -Format yyyyMMdd)-$(git rev-parse --short HEAD)" $(Build.SourcesDirectory) react_native' - workingDirectory: '$(Build.SourcesDirectory)' - errorActionPreference: stop - env: - ORT_JS_PACK_MODE: e2e - displayName: Pack NPM packages - - - script: | - mv $(Build.SourcesDirectory)/js/common/onnxruntime-common*.tgz onnxruntime-common.tgz - yarn add --no-lockfile file:./onnxruntime-common.tgz - mv $(Build.SourcesDirectory)/js/react_native/onnxruntime-react-native*.tgz onnxruntime-react-native.tgz - yarn add --no-lockfile file:./onnxruntime-react-native.tgz - yarn - workingDirectory: '$(Build.SourcesDirectory)/js/react_native/e2e' - displayName: Bootstrap Android and iOS e2e tests - - - script: | - yarn add --dev jest-junit - workingDirectory: '$(Build.SourcesDirectory)/js/react_native/e2e' - displayName: install jest junit reporter js/react_native/e2e - - - script: | - keytool -genkey -v -keystore debug.keystore -alias androiddebugkey -storepass android \ - -keypass android -keyalg RSA -keysize 2048 -validity 999999 -dname "CN=Android Debug,O=Android,C=US" - workingDirectory: '$(Build.SourcesDirectory)/js/react_native/e2e/android' - displayName: Generate a debug keystore - - - task: CopyFiles@2 - inputs: - sourceFolder: $(Build.BinariesDirectory)/android-full-aar - contents: onnxruntime-*.aar - targetFolder: $(Build.SourcesDirectory)/js/react_native/e2e/android/app/libs - displayName: Copy Android package to Android e2e test directory - - - script: | - detox build --configuration android.emu.release - workingDirectory: '$(Build.SourcesDirectory)/js/react_native/e2e' - displayName: Build React Native Detox Android e2e Tests - - # - # Unit tests and E2E tests with Android emulator - # - - template: use-android-emulator.yml - parameters: - create: true - start: true - - - template: android-dump-logs-from-steps.yml - parameters: - steps: - - task: Gradle@3 - inputs: - gradleWrapperFile: '$(Build.SourcesDirectory)/js/react_native/android/gradlew' - workingDirectory: '$(Build.SourcesDirectory)/js/react_native/android' - options: '--stacktrace' - tasks: 'connectedDebugAndroidTest' - publishJUnitResults: true - testResultsFiles: '**/TEST-*.xml' - testRunTitle: 'React Native Android Instrumented Test results' - sonarQubeRunAnalysis: false - spotBugsAnalysis: false - displayName: Run React Native Android Instrumented Tests - - - script: | - JEST_JUNIT_OUTPUT_FILE=$(Build.SourcesDirectory)/js/react_native/e2e/android-test-results.xml \ - detox test --record-logs all \ - --configuration android.emu.release \ - --loglevel trace \ - --take-screenshots failing - workingDirectory: '$(Build.SourcesDirectory)/js/react_native/e2e' - displayName: Run React Native Detox Android e2e Tests - - - template: use-android-emulator.yml - parameters: - stop: true - - - task: PublishTestResults@2 - inputs: - testResultsFiles: '$(Build.SourcesDirectory)/js/react_native/e2e/android-test-results.xml' - failTaskOnFailedTests: true - testRunTitle: 'React Native Detox Android e2e Test Results' - condition: succeededOrFailed() - displayName: Publish React Native Detox Android e2e Test Results - - - script: | - git restore . - workingDirectory: '$(Build.SourcesDirectory)/js' - displayName: Restore git changes - - - task: PowerShell@2 - inputs: - filePath: '$(Build.SourcesDirectory)/tools/ci_build/github/js/pack-npm-packages.ps1' - arguments: '"${{parameters.NpmPackagingMode}}" $(Build.SourcesDirectory) react_native' - workingDirectory: '$(Build.SourcesDirectory)' - errorActionPreference: stop - displayName: Pack NPM packages - - - task: CopyFiles@2 - inputs: - sourceFolder: $(Build.SourcesDirectory)/js/common - contents: onnxruntime-common*.tgz - targetFolder: $(Build.ArtifactStagingDirectory) - displayName: 'Create Artifacts onnxruntime-common' - - - task: CopyFiles@2 - inputs: - sourceFolder: $(Build.SourcesDirectory)/js/react_native - contents: onnxruntime-react-native*.tgz - targetFolder: $(Build.ArtifactStagingDirectory) - displayName: Create Artifacts onnxruntime-react-native - - - task: PublishPipelineArtifact@1 - inputs: - artifact: android_e2e_test_logs_$(Build.BuildId)_$(Build.BuildNumber)_$(System.JobAttempt) - targetPath: '$(Build.SourcesDirectory)/js/react_native/e2e/artifacts' - condition: succeededOrFailed() - displayName: Publish React Native Detox E2E test logs - - - task: PublishPipelineArtifact@0 - inputs: - artifactName: '${{parameters.PackageName}}' - targetPath: '$(Build.ArtifactStagingDirectory)' - displayName: Publish Pipeline Artifact - - - template: explicitly-defined-final-tasks.yml