Skip to content

Commit

Permalink
feat: Add jobs for building and testing
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-oakes committed Mar 26, 2019
1 parent 81f8f67 commit 2f24401
Show file tree
Hide file tree
Showing 5 changed files with 190 additions and 46 deletions.
21 changes: 13 additions & 8 deletions src/commands/ios_build_project.yml → src/commands/ios_build.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
description: Builds the iOS app at the given path with the given build scheme and configuration. This should be run only after installing NPM dependencies. If you are using Cocoapods then please use the "ios_build_workspace" command.
description: Builds the iOS app at the given path with the given build scheme and configuration. This should be run only after installing NPM dependencies.

parameters:
project_type:
description: If the iOS app is built using a project file (*.xcodeproj) or a workspace.
type: enum
enum: ["project", "workspace"]
default: "project"
project_path:
description: The path to the Xcode project (*.xcodeproj) you want to build, relative to the root of the repository.
description: The path to the Xcode project (*.xcodeproj) or the Xcode workspace (*.xcworkspace) that you want to build, relative to the root of the repository.
type: string
build_configuration:
description: The build configuration to use. This is normally either "Debug" or "Release" but you may have custom build configuration configured for your app.
type: string
default: "Debug"
derived_data_path:
description: The path to the directory to place the derived data, relative to the root of the repository.
type: string
Expand All @@ -12,10 +21,6 @@ parameters:
description: The type of device you want to build for.
type: string
default: "iPhone X"
configuration:
description: The build configuration to use. This is normally either "Debug" or "Release" but you may have custom build configuration configured for your app.
type: string
default: "Debug"
scheme:
description: The scheme to use.
type: string
Expand All @@ -27,8 +32,8 @@ steps:
- ios-build-cache-{{ arch }}-{{ checksum "~/.tmp/checksumfiles/package.json" }}-{{ .Environment.CACHE_VERSION }}

- run:
name: Build iOS Project
command: "export RCT_NO_LAUNCH_PACKAGER=true && xcodebuild -project <<parameters.project_path>> -destination 'platform=iOS Simulator,name=<<parameters.device>>' -scheme <<parameters.scheme>> -parallelizeTargets -configuration <<parameters.configuration>> -derivedDataPath <<parameters.derived_data_path>> -UseModernBuildSystem=YES | xcpretty -k"
name: Build iOS App
command: "export RCT_NO_LAUNCH_PACKAGER=true && xcodebuild -<<parameters.project_type>> <<parameters.project_path>> -destination 'platform=iOS Simulator,name=<<parameters.device>>' -scheme <<parameters.scheme>> -parallelizeTargets -configuration <<parameters.build_configuration>> -derivedDataPath <<parameters.derived_data_path>> -UseModernBuildSystem=YES | xcpretty -k"

- save_cache:
name: Saving iOS Build Cache
Expand Down
38 changes: 0 additions & 38 deletions src/commands/ios_build_workspace.yml

This file was deleted.

62 changes: 62 additions & 0 deletions src/jobs/android_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
description: Builds the Android app at the given path with the given build types.

executor: linux_android

parameters:
# For this job
checkout:
description: Boolean for whether or not to checkout as a first step. Default is false.
type: boolean
default: false
attach_workspace:
description: Boolean for whether or not to attach to an existing workspace. Default is true.
type: boolean
default: true
workspace_root:
description: Workspace root path that is either an absolute path or a path relative to the working directory. Defaults to '.' (the working directory).
type: string
default: .
persist_to_workspace:
description: Should this job persist files to a workspace? Defaults to true
type: boolean
default: true
store_artifacts:
description: Store this job store files as job artifacts? Defaults to true
type: boolean
default: true
# For the build command
project_path:
description: The path to the root of the Android project you want to build, relative to the root of the repository.
type: string
default: "./android"
build_type:
description: The build type to build. This is normally either "debug" or "release" but you may have custom build types configured for your app.
type: string
default: "debug"

steps:
- when:
condition: <<parameters.checkout>>
steps:
- checkout
- when:
condition: <<parameters.attach_workspace>>
steps:
- attach_workspace:
at: <<parameters.workspace_root>>
- yarn_install
- android_build:
project_path: <<parameters.project_path>>
build_type: <<parameters.build_type>>
- when:
condition: <<parameters.persist_to_workspace>>
steps:
- persist_to_workspace:
root: .
paths:
- <<parameters.project_path>>/app/build/outputs/apk
- when:
condition: <<parameters.store_artifacts>>
steps:
- store_artifacts:
path: <<parameters.project_path>>/app/build/outputs/apk
45 changes: 45 additions & 0 deletions src/jobs/android_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
description: Tests the Android app on the given device, with the given Detox configuration. You should have already built the correct Android APK (including the androidTest APK) and have both persisted to the worksapce.

executor: macos

parameters:
# For this job
workspace_root:
description: Workspace root path that is either an absolute path or a path relative to the working directory. Defaults to '.' (the working directory).
type: string
default: .
# For the start emulator command
device_name:
description: The name of the AVD. You use this name to tell which device to run tests on. Defaults to 'TestingAVD'.
type: string
default: "TestingAVD"
platform_version:
description: The version of android to run on the emulator. Defaults to 'android-28'.
type: string
default: "android-28"
build_tools_version:
description: The version of the Android build tools to install. Defaults to '28.0.3'.
type: string
default: "28.0.3"
logcat_grep:
description: ADB logs will be shown in the "Start Android Emulator" commands, but we filter it using grep to avoid noise. You can specify additional strigns to grep for. Make sure you escape special characters. Defaults to 'com.reactnativecommunity'.
type: string
default: "com.reactnativecommunity"
# For the detox command
detox_configuration:
description: The Detox configuration to test. Defaults to 'android.emu.release'.
type: string
default: "android.emu.release"

steps:
- attach_workspace:
at: <<parameters.workspace_root>>
- setup_macos_executor
- yarn_install
- android_emulator_start:
device_name: <<parameters.device_name>>
platform_version: <<parameters.platform_version>>
build_tools_version: <<parameters.build_tools_version>>
logcat_grep: <<parameters.logcat_grep>>
- detox_test:
configuration: <<parameters.detox_configuration>>
70 changes: 70 additions & 0 deletions src/jobs/ios_build_and_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
description: Builds the iOS app at the given path with the given build scheme and configuration and then runs the tests with the Detox configuration given.

executor: macos

parameters:
# For this job
checkout:
description: Boolean for whether or not to checkout as a first step. Default is false.
type: boolean
default: false
attach_workspace:
description: Boolean for whether or not to attach to an existing workspace. Default is true.
type: boolean
default: true
workspace_root:
description: Workspace root path that is either an absolute path or a path relative to the working directory. Defaults to '.' (the working directory).
type: string
default: .
# For the iOS build command
project_type:
description: If the iOS app is built using a project file (*.xcodeproj) or a workspace.
type: enum
enum: ["project", "workspace"]
default: "project"
project_path:
description: The path to the Xcode project (*.xcodeproj) or the Xcode workspace (*.xcworkspace) that you want to build, relative to the root of the repository.
type: string
build_configuration:
description: The build configuration to use. This is normally either "Debug" or "Release" but you may have custom build configuration configured for your app.
type: string
default: "Debug"
derived_data_path:
description: The path to the directory to place the derived data, relative to the root of the repository.
type: string
default: "ios/build"
device:
description: The type of device you want to build for.
type: string
default: "iPhone X"
scheme:
description: The scheme to use.
type: string
# For the Detox test command
detox_configuration:
description: The Detox configuration to test.
type: string
default: "ios.sim.release"

steps:
- when:
condition: <<parameters.checkout>>
steps:
- checkout
- when:
condition: <<parameters.attach_workspace>>
steps:
- attach_workspace:
at: <<parameters.workspace_root>>
- setup_macos_executor
- ios_simulator_start:
device: <<parameters.device>>
- yarn_install
- ios_build:
project_path: <<parameters.project_path>>
derived_data_path: <<parameters.derived_data_path>>
device: <<parameters.device>>
build_configuration: <<parameters.build_configuration>>
scheme: <<parameters.scheme>>
- detox_test:
configuration: <<parameters.detox_configuration>>

0 comments on commit 2f24401

Please sign in to comment.