Skip to content

Commit e4ae430

Browse files
committed
Publish XML Test results and publish @next
Modify the AndroidManifest file in the app dir to fix the HTTP tests Pull the test results in XML format and publish them as artifacts Have the test-results checks as a single command Parametrize AVD version; Use the package version, retrieved from package.json for builds and runs Make the package name a variable Fix test crash detection according to the time taken Move all travis-related scripts under the build dir
1 parent 696c1c4 commit e4ae430

File tree

4 files changed

+71
-12
lines changed

4 files changed

+71
-12
lines changed

.travis.yml

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
env:
2+
global:
3+
- DATE=$(date +%Y-%m-%d)
4+
- PACKAGE_VERSION=$DATE-$TRAVIS_BUILD_NUMBER
5+
- PACKAGE_NAME=tns-core-modules
6+
- NODE_VERSION=5.10.1
7+
- EMULATOR_API_VER=21
8+
- RUNTIMEVERSION=next
9+
- AVD_NAME=Arm$EMULATOR_API_VER
10+
addons:
11+
artifacts:
12+
paths: $HOME/test-run-results$PACKAGE_VERSION.xml
113
sudo: required
214
dist: trusty
315
language: android
@@ -10,26 +22,48 @@ android:
1022
- platform-tools
1123
- tools
1224
- build-tools-23.0.3
13-
- android-21
25+
- android-$EMULATOR_API_VER
1426
- android-23
1527
- extra-android-support
1628
- extra-android-m2repository
17-
- sys-img-armeabi-v7a-android-21
29+
- sys-img-armeabi-v7a-android-$EMULATOR_API_VER
1830

1931
before_script:
20-
- nvm install 5.10.1
32+
- nvm install $NODE_VERSION
2133
- npm install -g grunt-cli
2234
- npm install
2335
- (cd build/platform-declarations && npm install)
24-
- echo no | android create avd --force -n Arm21 -t android-21 -b armeabi-v7a -c 12M
25-
- emulator -avd Arm21 -no-skin -no-audio -no-window &
36+
- echo no | android create avd --force -n $AVD_NAME -t android-$EMULATOR_API_VER -b armeabi-v7a -c 12M
37+
- emulator -avd $AVD_NAME -no-skin -no-audio -no-window &
2638
- android-wait-for-emulator
2739
script:
2840
- jdk_switcher use oraclejdk8
2941
- grunt default &&
42+
FULL_PACKAGE_VERSION=`node -e 'console.log(require("./bin/dist/modules/package.json").version);'` &&
3043
(cd build/platform-declarations && grunt) &&
3144
echo no | npm install nativescript -g > /dev/null &&
32-
grunt buildOnlyTestsApp --platform=Android --modulesPath=./bin/dist/tns-core-modules-2.0.0.tgz --runtimeVersion=next --emuPId=.*emulator.* --avd=Api21 --showEmu=false > /dev/null &&
33-
grunt runOnlyTestsApp --platform=Android --modulesPath=./bin/dist/tns-core-modules-2.0.0.tgz --emuPId=.*emulator.* --avd=Api21 --showEmu=false
45+
grunt buildOnlyTestsApp --platform=Android --modulesPath=./bin/dist/$PACKAGE_NAME-$FULL_PACKAGE_VERSION.tgz --runtimeVersion=$RUNTIMEVERSION --emuPId=.*emulator.* --avd=$AVD_NAME --showEmu=false > /dev/null &&
46+
grunt runOnlyTestsApp --platform=Android --modulesPath=./bin/dist/$PACKAGE_NAME-$FULL_PACKAGE_VERSION.tgz --emuPId=.*emulator.* --avd=$AVD_NAME --showEmu=false
3447

3548
- node ./build/travis-scripts/check-testrun-broken.js
49+
- adb pull /data/data/org.nativescript.TestsApp/files/test-results.xml &&
50+
mv test-results.xml ~/test-run-results$PACKAGE_VERSION.xml
51+
before_deploy:
52+
- mv bin/dist/$PACKAGE_NAME-$FULL_PACKAGE_VERSION.tgz ../.deploymentpackage
53+
- mv .build ../
54+
- cd ..
55+
- rm -rf NativeScript
56+
- tar -zxvf .deploymentpackage
57+
- mv package $PACKAGE_NAME
58+
- cd $PACKAGE_NAME
59+
- rm ../.deploymentpackage
60+
- mv ../build ./
61+
- node ./build/travis-scripts/add-publishConfig.js next
62+
deploy:
63+
provider: npm
64+
email: nativescript@telerik.com
65+
on:
66+
branch: master
67+
skip_cleanup: true
68+
api_key:
69+
secure: aFJZR8VIbFAlXfFx5G2AveSgpGjr40prghvw8m06X0yvmUQlucwHVyq+Ov0ZD94br8d7OUOPbUzh+p9N/+oXLAXOj3DbQmJaCc+fk/e+avHu1BRy3fg295P9BQau1Abu+2ZO7tUbg5zAqJqhbEgjXsr9B5gxl+vwh4lbDhCPCwo=

build/run-testsapp.grunt.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ module.exports = {
115115
},
116116
addAndroidPermissions: {
117117
src: "AndroidManifest.xml",
118-
dest: localCfg.applicationDir + "/platforms/android/src/main/",
119-
cwd: localCfg.applicationDir + "/platforms/android/src/main",
118+
dest: localCfg.applicationDir + "/app/App_Resources/Android/",
119+
cwd: localCfg.applicationDir + "/app/App_Resources/Android",
120120
expand: true,
121121
options: {
122122
process: function(content, srcPath) {
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env node
2+
3+
var fsModule = require('fs');
4+
5+
//Adds a publishConfig section to the package.json file
6+
// and sets a tag to it
7+
8+
var path = './package.json';
9+
var fileOptions = {encoding: "utf-8"};
10+
var content = fsModule.readFileSync(path, fileOptions);
11+
12+
var tag = process.argv[2];
13+
if (!tag) {
14+
console.log('Please pass the tag name as an argument!');
15+
process.exit(1);
16+
}
17+
18+
var packageDef = JSON.parse(content);
19+
if (!packageDef.publishConfig) {
20+
packageDef.publishConfig = {};
21+
}
22+
packageDef.publishConfig.tag = tag;
23+
24+
var newContent = JSON.stringify(packageDef, null, ' ');
25+
fsModule.writeFileSync(path, newContent, fileOptions);

build/travis-scripts/check-testrun-broken.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env node
22
var fsModule = require('fs');
33
var resultsFile = 'TestRunResult.txt';
4-
var successMarker ='=== ALL TESTS COMPLETE ===';
5-
var passMarker = /=== ALL TESTS COMPLETE ===\s+[^\n]*OK,\s+0\s+failed/mg;
4+
var successMarker = /=== ALL TESTS COMPLETE for \d+ ms ===/;
5+
var passMarker = /=== ALL TESTS COMPLETE for \d+ ms ===\s+[^\n]*OK,\s+0\s+failed/mg;
66

77
var messages = {
88
crash: 'TEST RUN CRASHED!',
@@ -13,7 +13,7 @@ var messages = {
1313

1414
var results = fsModule.readFileSync(resultsFile, 'utf-8');
1515

16-
if (results.indexOf(successMarker) == -1) {
16+
if (!results.match(successMarker)) {
1717
console.log(messages.crash);
1818
process.exit(1);
1919
} else if (results.match(passMarker)) {

0 commit comments

Comments
 (0)