Skip to content

Instantly share code, notes, and snippets.

View horie1024's full-sized avatar

Ryosuke Horie horie1024

  • ZOZO, Inc.
  • Japan
View GitHub Profile
general:
branches:
only:
- master
machine:
java:
version: openjdk7
environment:
ANDROID_HOME: /usr/local/android-sdk-linux
dependencies:
require 'aws-sdk'
devicefarm = Aws::DeviceFarm::Client.new(
region: 'us-west-2',
credentials: Aws::Credentials.new("YOUR_ACCESS_KEY_ID", "YOUR_SECRET_ACCESS_KEY"),
)
resp = devicefarm.list_device_pools({
arn: "プロジェクトのARN"
})
# DevicePoolのARN(後ほど使用)
# Defaultを使用するのでdevice_pools[0]を使用
device_pool_arn = resp.device_pools[0].arn
resp = devicefarm.create_upload({
project_arn: "プロジェクトのARN",
name: "app.apk",
type: "ANDROID_APP",
content_type: "application/octet-stream"
})
# Pre-Signed URLの取得
pre_signed_url = resp.upload.url
url = URI.parse(pre_signed_url)
apk = File.open("YOUR_APK_PATH", "rb").read
Net::HTTP.start(url.host) do |http|
http.send_request("PUT", url.request_uri, apk, {"content-type" => "application/octet-stream"})
end
resp = devicefarm.create_upload({
project_arn: "プロジェクトのARN",
name: "features.zip",
type: "CALABASH_TEST_PACKAGE",
content_type: "application/octet-stream"
})
# Pre-Signed URLの取得
pre_signed_url = resp.upload.url
devicefarm.schedule_run({
project_arn: "プロジェクトのARN",
app_arn: apk_arn,
device_pool_arn: device_pool_arn,
test: {
type: 'CALABASH',
test_package_arn: calabash_package_arn
}
})
10.times do
resp_apk = devicefarm.get_upload({
arn: apk_arn
})
resp_test_package = devicefarm.get_upload({
arn: calabash_package_arn
})
if resp_apk.upload.status == "SUCCEEDED" &&
general:
branches:
only:
- master
machine:
java:
version: openjdk7
ruby:
version: 2.2.0
environment:
#!/bin/sh
./gradlew assembleDebug
zip -r features.zip features
ruby scripts/devicefarm.rb