Last active
August 29, 2015 14:06
-
-
Save erlichmen/9308ad14c9b23e867e5a to your computer and use it in GitHub Desktop.
Testfairy ant
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!-- custom rules with testfairy standalone --> | |
<project name="custom_rules" default="help"> | |
<import file="testfairy/testfairy_build.xml"/> | |
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!-- custom rules with testfairy and crashlytics together --> | |
<project name="custom_rules" default="help"> | |
<import file="crashlytics/crashlytics_build_base.xml"/> | |
<import file="testfairy/testfairy_build_base.xml"/> | |
<target name="-pre-build" depends="android_rules.-pre-build, crashlytics-pre-build" /> | |
<target name="-code-gen" depends="crashlytics-code-gen, android_rules.-code-gen" /> | |
<target name="-post-package" depends="android_rules.-post-package, crashlytics-post-package, -testfairy-post-package" /> | |
<target name="-post-build" depends="android_rules.-post-build, -testfairy-post-build" /> | |
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<project name="testfairy_targets"> | |
<import file="testfairy_build_base.xml"/> | |
<!-- | |
Override Android's -post-package target to invoke the testfairy post-package target. | |
--> | |
<target name="-post-package" depends="android_rules.-post-package, -testfairy-post-package" /> | |
<target name="-post-build" depends="android_rules.-post-build, -testfairy-post-build" /> | |
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<project name="testfairy_targets_base" > | |
<property | |
name="testfairy.server_endpoint" | |
value="https://app.testfairy.com" /> | |
<property | |
name="testfairy.api_key" | |
value="" /> | |
<property | |
name="testfairy.testers_groups" | |
value="" /> | |
<property | |
name="testfairy.auto_update" | |
value="off" /> | |
<property | |
name="testfairy.notify" | |
value="on" /> | |
<target name="-check-testfairy-deploy-signed"> | |
<condition property="testfairy.can.upload.signed"> | |
<and> | |
<isTrue value="${has.keystore}"/> | |
<isTrue value="${testfairy.upload.unsinged}"/> | |
</and> | |
</condition> | |
</target> | |
<target name="-testfairy-deploy-signed" depends="-check-testfairy-deploy-signed" if="testfairy.can.upload.signed" unless="testfairy.disabled"> | |
<if> | |
<condition> | |
<not> | |
<resourceexists> | |
<file file="${out.final.file}" /> | |
</resourceexists> | |
</not> | |
</condition> | |
<then> | |
<fail message="testfairy: File ${out.final.file} does not exist." /> | |
</then> | |
</if> | |
<property | |
name="testfairy.upload.signed.endpoint" | |
value="${testfairy.server_endpoint}/api/upload-signed" /> | |
<echo level="info" >Uploading signed ${out.final.file} to TestFairy...</echo> | |
<exec executable="curl"> | |
<arg value="--silent" /> | |
<arg value="${testfairy.upload.signed.endpoint}" /> | |
<arg value="--form" /> | |
<arg value="api_key=${testfairy.api_key}" /> | |
<arg value="--form" /> | |
<arg value="apk_file=@${out.final.file}" /> | |
<arg value="--form" /> | |
<arg value="testers_groups=${testfairy.testers_groups}" /> | |
<arg value="--form" /> | |
<arg value="auto-update=${testfairy.auto_update}" /> | |
<arg value="--form" /> | |
<arg value="notify=${testfairy.notify}" /> | |
<redirector | |
errorproperty="testfairy.upload.signed.error" | |
outputproperty="testfairy.upload.signed.json" > | |
<outputmapper | |
to="testfairy.upload.signed.json" | |
type="merge" /> | |
<errormapper | |
to="testfairy.upload.signed.error" | |
type="merge" /> | |
</redirector> | |
</exec> | |
<echo level="verbose" >Uploading signed result ${testfairy.upload.signed.json}</echo> | |
<script language="javascript" > | |
// Evaluate the JSON. | |
var struct = eval("(" + project.getProperty("testfairy.upload.signed.json") + ")"); | |
// Set each property in the project environment. | |
var i, propertyName; | |
for (i in struct) { | |
propertyName = "testfairy.upload.signed.result." + i; | |
project.setProperty(propertyName, struct[i]); | |
} | |
</script> | |
<if> | |
<condition> | |
<not> | |
<equals | |
arg1="${testfairy.upload.signed.result.status}" | |
arg2="ok" /> | |
</not> | |
</condition> | |
<then> | |
<fail message="testfairy: Upload failed ${testfairy.upload.signed.result.message}." /> | |
</then> | |
</if> | |
</target> | |
<target name="-check-testfairy-deploy-unsigned" unless="testfairy.disabled"> | |
<condition property="testfairy.can.upload.unsigned"> | |
<and> | |
<isTrue value="${has.keystore}"/> | |
</and> | |
</condition> | |
</target> | |
<target name="-testfairy-deploy-unsigned" depends="-check-testfairy-deploy-unsigned" if="testfairy.can.upload.unsigned"> | |
<if> | |
<condition> | |
<not> | |
<resourceexists> | |
<file file="${out.packaged.file}" /> | |
</resourceexists> | |
</not> | |
</condition> | |
<then> | |
<fail message="testfairy: File ${out.packaged.file} does not exist." /> | |
</then> | |
</if> | |
<property | |
name="testfairy.upload.endpoint" | |
value="${testfairy.server_endpoint}/api/upload" /> | |
<property | |
name="testfairy.upload.icon_watermark" | |
value="on" /> | |
<property | |
name="testfairy.upload.enable_video_recording" | |
value="on" /> | |
<property | |
name="testfairy.upload.metrics" | |
value="cpu,network,logcat" /> | |
<property | |
name="testfairy.upload.max_recording_duration" | |
value="10m" /> | |
<echo level="info" > | |
Uploading ${out.packaged.file} to TestFairy... | |
</echo> | |
<basename property="out.final.filename" file="${out.final.file}"/> | |
<exec executable="curl"> | |
<arg value="--silent" /> | |
<arg value="${testfairy.upload.endpoint}" /> | |
<arg value="--form" /> | |
<arg value="api_key=${testfairy.api_key}" /> | |
<arg value="--form" /> | |
<arg value="apk_file=@${out.packaged.file};filename=${out.final.filename}" /> | |
<arg value="--form" /> | |
<arg value="icon-watermark=${testfairy.upload.icon_watermark}" /> | |
<arg value="--form" /> | |
<arg value="video=${testfairy.upload.enable_video_recording}" /> | |
<arg value="--form" /> | |
<arg value="max-duration=${testfairy.upload.max_recording_duration}" /> | |
<arg value="--form" /> | |
<arg value="metrics=${testfairy.upload.metrics}" /> | |
<arg value="--form" /> | |
<arg value="testers_groups=${testfairy.testers_groups}" /> | |
<arg value="--form" /> | |
<arg value="comment=${testfairy.comment}" /> | |
<redirector | |
errorproperty="testfairy.upload.error.json" | |
outputproperty="testfairy.upload.json" > | |
<outputmapper | |
to="testfairy.upload.json" | |
type="merge" /> | |
<errormapper | |
to="testfairy.upload.error.json" | |
type="merge" /> | |
</redirector> | |
</exec> | |
<echo level="verbose" >Uploading result ${testfairy.upload.json}</echo> | |
<script language="javascript" > | |
// Evaluate the JSON. | |
var struct = eval("(" + project.getProperty("testfairy.upload.json") + ")"); | |
// Set each property in the project environment. | |
var i, propertyName; | |
for (i in struct) { | |
propertyName = "testfairy.upload.result." + i; | |
project.setProperty(propertyName, struct[i]); | |
} | |
</script> | |
<if> | |
<condition> | |
<not> | |
<equals | |
arg1="${testfairy.upload.result.status}" | |
arg2="ok" /> | |
</not> | |
</condition> | |
<then> | |
<fail message="testfairy: Upload failed ${testfairy.upload.result.message}." /> | |
</then> | |
</if> | |
<echo level="info" >Downloading instrumented apk from ${testfairy.upload.result.instrumented_url}</echo> | |
<exec executable="curl"> | |
<arg value="--silent" /> | |
<arg value="--location" /> | |
<arg value="--write-out" /> | |
<arg value="%{http_code}" /> | |
<arg value="--output" /> | |
<arg value="${out.packaged.file}" /> | |
<arg value="${testfairy.upload.result.instrumented_url}" /> | |
<redirector | |
errorproperty="testfairy.download.error.out" | |
outputproperty="testfairy.download.out" > | |
<outputmapper | |
to="testfairy.download.out" | |
type="merge" /> | |
<errormapper | |
to="testfairy.download.error.out" | |
type="merge" /> | |
</redirector> | |
</exec> | |
<echo level="verbose" >Download result ${testfairy.download.out}</echo> | |
<if> | |
<condition> | |
<not> | |
<equals | |
arg1="${testfairy.download.out}" | |
arg2="200" /> | |
</not> | |
</condition> | |
<then> | |
<fail message="testfairy: Download instrumented failed ${testfairy.download.out}." /> | |
</then> | |
<else> | |
<property | |
name="testfairy.upload.unsinged" | |
value="true" /> | |
</else> | |
</if> | |
</target> | |
<target name="-testfairy-post-package" depends="-testfairy-deploy-unsigned" unless="testfairy.disabled"/> | |
<target name="-testfairy-post-build" depends="-testfairy-deploy-signed" unless="testfairy.disabled"/> | |
<target name="-set-release-mode" | |
depends="-rename-release-with-testfairy,android_rules.-set-release-mode"> | |
<echo message="target: ${build.target}"></echo> | |
</target> | |
<target name="-rename-release-with-testfairy" unless="testfairy.disabled"> | |
<xmlproperty file="AndroidManifest.xml" | |
prefix="themanifest" | |
collapseAttributes="true"/> | |
<!-- see ${sdk.dir}/tools/ant/build.xml -set-release-mode --> | |
<property name="out.packaged.file" | |
location="${out.absolute.dir}/${ant.project.name}-testfairy-release-unsigned.apk" /> | |
<property name="out.final.file" | |
location="${out.absolute.dir}/${ant.project.name}-testfairy-release.apk" /> | |
</target> | |
</project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment