Skip to content

Commit

Permalink
Merge branch 'master' into notificationWakeLock
Browse files Browse the repository at this point in the history
  • Loading branch information
hansemannn committed Aug 11, 2017
2 parents 77d5488 + 08edfe3 commit 2390370
Show file tree
Hide file tree
Showing 7,765 changed files with 10,826 additions and 758,787 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
Binary file added .github/logo-titanium.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 1 addition & 16 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,10 @@ anvil/driver/config.js
._*
npm-debug.log

node_modules/.bin
node_modules/grunt-appc-js
node_modules/grunt-clang-format
node_modules/grunt-cli
node_modules/grunt-contrib-clean
node_modules/grunt-mocha-test
node_modules/grunt
node_modules/mocha
node_modules/should
node_modules/node-ios-device/build
!node_modules/**/*~
!node_modules/**/*.orig
node_modules/

anvil/driver/titanium_mobile
anvil/hub/config.js
support/mobileweb/dependencyAnalyzer/node_modules/*
anvil/driver/node_modules/*
apidoc/node_modules/*

support/ti_mocha_script/testApp

/titanium-mobile-mocha-suite
Expand Down
43 changes: 0 additions & 43 deletions .travis.yml

This file was deleted.

101 changes: 80 additions & 21 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def vtag = ''
def isPR = false

// Variables we can change
def nodeVersion = '4.7.3' // NOTE that changing this requires we set up the desired version on jenkins master first!
def nodeVersion = '6.10.3' // NOTE that changing this requires we set up the desired version on jenkins master first!

def unitTests(os, nodeVersion, testSuiteBranch) {
return {
Expand Down Expand Up @@ -68,6 +68,13 @@ def unitTests(os, nodeVersion, testSuiteBranch) {
}
}

@NonCPS
def isMajorVersionLessThan(version, minValue) {
def versionMatcher = version =~ /(\d+)\.(\d+)\.(\d+)/
def majorVersion = versionMatcher[0][1].toInteger()
return majorVersion < minValue
}

// Wrap in timestamper
timestamps {
def targetBranch
Expand Down Expand Up @@ -108,31 +115,55 @@ timestamps {
// Skip the Windows SDK portion if a PR, we don't need it
stage('Windows') {
if (!isPR) {
// This may be the very first build on this branch, so there's no windows build to grab yet
def isFirstBuildOnBranch = false
try {
sh 'curl -O http://builds.appcelerator.com.s3.amazonaws.com/mobile/branches.json'
if (fileExists('branches.json')) {
def contents = readFile('branches.json')
if (!contents.startsWith('<?xml')) { // May be an 'Access denied' xml file/response
def branchesJSON = jsonParse(contents)
isFirstBuildOnBranch = !(branchesJSON['branches'].contains(env.BRANCH_NAME))
}
}
} catch (err) {
// ignore? Not able to grab the branches.json, what should we assume? In 99.9% of the cases, it's not a new build
}

// If there's no windows build for this branch yet, use master
def windowsBranch = targetBranch
if (isFirstBuildOnBranch) {
windowsBranch = 'master'
manager.addWarningBadge("Looks like the first build on branch ${env.BRANCH_NAME}. Using 'master' branch build of Windows SDK to bootstrap.")
}
step([$class: 'CopyArtifact',
projectName: "../titanium_mobile_windows/${targetBranch}",
projectName: "../titanium_mobile_windows/${windowsBranch}",
selector: [$class: 'StatusBuildSelector', stable: false],
filter: 'dist/windows/'])
sh 'rm -rf windows; mv dist/windows/ windows/; rm -rf dist'
} // !isPR
} // stage

stage('Build') {
// Normal build, pull out the version
def version = sh(returnStdout: true, script: 'sed -n \'s/^ *"version": *"//p\' package.json | tr -d \'"\' | tr -d \',\'').trim()
echo "VERSION: ${version}"
// Create a timestamp
def timestamp = sh(returnStdout: true, script: 'date +\'%Y%m%d%H%M%S\'').trim()
echo "TIMESTAMP: ${timestamp}"
vtag = "${version}.v${timestamp}"
echo "VTAG: ${vtag}"
basename = "dist/mobilesdk-${vtag}"
echo "BASENAME: ${basename}"
nodejs(nodeJSInstallationName: "node ${nodeVersion}") {
stage('Build') {
// Normal build, pull out the version
def version = sh(returnStdout: true, script: 'sed -n \'s/^ *"version": *"//p\' package.json | tr -d \'"\' | tr -d \',\'').trim()
echo "VERSION: ${version}"
// Create a timestamp
def timestamp = sh(returnStdout: true, script: 'date +\'%Y%m%d%H%M%S\'').trim()
echo "TIMESTAMP: ${timestamp}"
vtag = "${version}.v${timestamp}"
echo "VTAG: ${vtag}"
basename = "dist/mobilesdk-${vtag}"
echo "BASENAME: ${basename}"

// Enforce npm 5.2.0 right now, since 5.3.0 has a bug in pruning to production: https://github.com/npm/npm/issues/17781
sh 'npm install -g npm@5.2'

nodejs(nodeJSInstallationName: "node ${nodeVersion}") {
// Install dev dependencies
timeout(5) {
// We already check in our production dependencies, so only install devDependencies
sh(returnStatus: true, script: 'npm install --only=dev') // ignore PEERINVALID grunt issue for now
// FIXME Do we need to do anything special to make sure we get os-specific modules only on that OS's build/zip?
sh 'npm install'
}
sh 'npm test' // Run linting first
// Then validate docs
Expand All @@ -156,11 +187,38 @@ timestamps {
}
} // ansiColor
} // dir
} // nodeJs
archiveArtifacts artifacts: "${basename}-*.zip"
stash includes: 'dist/parity.html', name: 'parity'
stash includes: 'tests/', name: 'override-tests'
} // end 'Build' stage
archiveArtifacts artifacts: "${basename}-*.zip"
stash includes: 'dist/parity.html', name: 'parity'
stash includes: 'tests/', name: 'override-tests'
} // end 'Build' stage

stage('Security') {
// Clean up and install only production dependencies
sh 'npm prune --production'

// Scan for NSP and RetireJS warnings
def scanFiles = []
sh 'npm install -g nsp'
def nspExitCode = sh(returnStatus: true, script: 'nsp check --output json 2> nsp.json')
if (nspExitCode != 0) {
scanFiles << [path: 'nsp.json']
}

sh 'npm install -g retire'
def retireExitCode = sh(returnStatus: true, script: 'retire --outputformat json --outputpath ./retire.json')

if (retireExitCode != 0) {
scanFiles << [path: 'retire.json']
}

if (!scanFiles.isEmpty()) {
step([$class: 'ThreadFixPublisher', appId: '136', scanFiles: scanFiles])
}

// re-install dev dependencies for testing later...
sh(returnStatus: true, script: 'npm install --only=dev') // ignore PEERINVALID grunt issue for now
} // end 'Security' stage
} // nodeJs
} // end node for checkout/build

// Run unit tests in parallel for android/iOS
Expand Down Expand Up @@ -193,6 +251,7 @@ timestamps {
indexJson = jsonParse(contents)
}
}
// FIXME Add branch to branches.json file as well if the <branch>/index.json didn't exist!

// unarchive zips
unarchive mapping: ['dist/': '.']
Expand Down
91 changes: 78 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Appcelerator Titanium [![Build Status](https://jenkins.appcelerator.org/buildStatus/icon?job=titanium-sdk/titanium_mobile/master)](https://jenkins.appcelerator.org/job/titanium-sdk/job/titanium_mobile/job/master/)
<p align="center"><a href="https://appcelerator.com" target="_blank"><img width="120" src=".github/logo-titanium.png"></a></p>

Welcome to the Titanium open source project. Titanium provides a mature platform for developers to build
<h1 align="center">Titanium <a href="https://jenkins.appcelerator.org/job/titanium-sdk/job/titanium_mobile/job/master/" target="_blank"><img src="https://jenkins.appcelerator.org/buildStatus/icon?job=titanium-sdk/titanium_mobile/master" /></a></h1>

Welcome to the Titanium open source project. Titanium provides a mature platform for developers to build
completely native cross-platform mobile applications using JavaScript.

Currently supported native platforms are iOS, Android and Windows Phone / Windows Desktop.
Expand All @@ -10,6 +12,23 @@ see the LICENSE file for specific details.

*[Download Pre-built Titanium](http://builds.appcelerator.com/#master)*

# Table of Contents
1. [Features](#features)
2. [Hyperloop](#hyperloop)
3. [Alloy](#alloy)
4. [Getting Help](#getting-help)
* [Official Documentation, Tutorials and Videos](#official-documentation-tutorials-and-videos)
* [Developer Community](#developer-community)
* [Video Tutorials](#video-tutorials)
* [Slack](#slack)
* [Twitter](#twitter)
* [Blog](#blog)
* [Commercial Support, Licensing](#commercial-support-licensing)
5. [Contributing](#contributing)
6. [Building Locally](#building-locally)
* [Unit Tests](#unit-tests)
7. [Legal Stuff](#legal-stuff)

## Features

With Titanium, you use JavaScript to code your application. Titanium's compiler will compile
Expand Down Expand Up @@ -46,10 +65,10 @@ And much, much more (see our [Documentation](http://docs.appcelerator.com/platfo

## Hyperloop

Use Hyperloop, our latest addition to the Appcelerator Platform, to extend your Titanium apps by native API's using
Use Hyperloop, our latest addition to the Appcelerator Platform, to extend your Titanium apps by native API's using
JavaScript. Prior to Hyperloop, you would use [native modules](http://docs.appcelerator.com/platform/latest/#!/guide/Titanium_Module_Concepts) to extend the Titanium API. With
Hyperloop, you are now able to implement native classes, 3rd-Party libraries (Cocoapods, local frameworks, .aar files)
and more directly into your apps. Hyperloop is available for iOS, Android and Windows Phone (Tech Preview).
Hyperloop, you are now able to implement native classes, 3rd-Party libraries (Cocoapods, local frameworks, .aar files)
and more directly into your apps. Hyperloop is available for iOS, Android and Windows Phone (Tech Preview).

### Features

Expand Down Expand Up @@ -98,8 +117,8 @@ Check out our [Hyperloop Sample App](https://github.com/appcelerator/hyperloop-e

## Alloy

[Alloy](http://docs.appcelerator.com/platform/latest/#!/guide/Alloy_Quick_Start) is the MVC application framework built
on top of Titanium. It is optional. It rocks. Check it out if you're considering using Titanium.
[Alloy](http://docs.appcelerator.com/platform/latest/#!/guide/Alloy_Quick_Start) is the MVC application framework built
on top of Titanium. It is optional. It rocks. Check it out if you're considering using Titanium.
It is also a separate [open source project](https://github.com/appcelerator/alloy) available under Apache Public License.

### Example
Expand Down Expand Up @@ -186,9 +205,11 @@ To protect the interests of the Titanium contributors, Appcelerator, customers a
Previously Titanium used scons and python scripts to build the SDK.
If you'd like to build the SDK locally, we've replaced scons with some Node.JS scripts. Typical usage would be:

npm install
cd build
node scons.js cleanbuild --android-ndk /opt/android-ndk --android-sdk /opt/android-sdk
```bash
npm install
cd build
node scons.js cleanbuild --android-ndk /opt/android-ndk --android-sdk /opt/android-sdk
```

The build and package commands will default to all target platforms on your host OS unless explicitly specified. (i.e. Android, iOS on macOS; Windows and Android on Windows). It will compile, package and install the locally-built SDK for you
as well, so you can test it in your own applications without any further procedures.
Expand All @@ -197,10 +218,54 @@ The build command will look for Android NDK and SDK using $ANDROID_NDK and $ANDR

You can use the `-h` flag to display the full list of comands and options.

npm install
cd build
node scons.js cleanbuild [platform1] [platform2] --android-ndk /opt/android-ndk --android-sdk /opt/android-sdk /Users/build/android-sdk-macosx
```bash
npm install
cd build
node scons.js cleanbuild [platform1] [platform2] --android-ndk /opt/android-ndk --android-sdk /opt/android-sdk /Users/build/android-sdk-macosx
```

### Unit tests

We have a [common unit test suite](https://github.com/appcelerator/titanium-mobile-mocha-suite) intended to run across all supported platforms.

To invoke the tests, you must create a local build of the sdk via the steps above and have an sdk zip in your `dist` directory. Then you'd run:

```bash
cd build
node scons.js test [platform]
```

#### How it works

The common test suite generates a single titaniun project targeting the specified platform, builds the project for emulator, launches the app on the emulator and then runs a series of tests defined via ti-mocha and should.js.

The tests spit out their results to the console log, and the test scripts listen to the logs to gather the results. We then generate an overview on the console as well as a junit report xml file (to be consume by CI build systems like Jenkins).

#### How to modify the tests locally and in your PRs

The `tests` folder acts as an override folder for the common suite. Any files living within that directory are copied on top of the common suite's app structure.

##### Adding a new test suite

In practical terms that means if we need to add new test files, you'd place the new file under `tests/Resources`, and then copy the `titanium-mobile-mocha-suite/Resources/app.js` to `tests/Resources/app.js` and editing the copy to require the new file(s).

For example, if we want to test a new `Ti.Foo` namespace, we'd create a new test file at `tests/Resources/ti.foo.test.js`. We'd then copy `titanium-mobile-mocha-suite/Resources/app.js` to `tests/Resources/app.js` and add the line:

```javascript
require('./ti.foo.test')
```

##### Editing an existing test suite

If we want to edit the set of tests for the `Ti.App` namespace, we'd copy the existing test from `titanium-mobile-mocha-suite/Resources/ti.app.test.js` to `tests/Resources/ti.foo.test.js`. We'd then edit the file to add/remove/modify the existing suite.

##### Merging the modified tests back to the common suite

We do not have any automated process for merging the modified tests from the `tests` override folder back to the [common unit test suite](https://github.com/appcelerator/titanium-mobile-mocha-suite).

As a result, we need to manually 'migrate' the modified files back to the suite ourselves. This involves copying the modified folders to a clone of that repository on the same mainline branch (i.e. master, 6_1_X, 7_0_X), committing and pushing it up to the common suite; then removing the files from `titanium_mobile/tests`.

A future improvement could be to modify our Jenkins build in `Jenkinsfile` to automate this merge back to the common suite if all tests run and pass on a mainline branch.

## Legal Stuff

Expand Down
2 changes: 2 additions & 0 deletions android/build/common.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Common ant tasks and macros for building Android-based Titanium modules and proj

<property name="v7appcompat.project.dir" location="${ti.android.root}/modules/appcompat"/>
<property name="v7cardview.project.dir" location="${ti.android.root}/modules/cardview"/>
<property name="design.project.dir" location="${ti.android.root}/modules/design"/>
<property name="titanium.project.dir" location="${ti.android.root}/titanium"/>
<property name="kroll.apt.project.dir" location="${ti.android.root}/kroll-apt"/>
<property name="kroll.common.project.dir" location="${ti.android.root}/runtime/common"/>
Expand Down Expand Up @@ -147,6 +148,7 @@ Common ant tasks and macros for building Android-based Titanium modules and proj
<fileset dir="${titanium.project.dir}/lib" includes="**/*.jar"/>
<fileset dir="${v7appcompat.project.dir}/lib" includes="**/*.jar"/>
<fileset dir="${v7cardview.project.dir}/lib" includes="**/*.jar"/>
<fileset dir="${design.project.dir}/lib" includes="**/*.jar"/>
</path>

<macrodef name="build.project">
Expand Down

0 comments on commit 2390370

Please sign in to comment.