41
2007 Adobe Systems Incorporated. All Rights Reserved. 1 Joe Berkovitz VP Engineering Allurent, Inc. Continuous Integration with Flex, FlexUnit, and Ant

2007 Adobe Systems Incorporated. All Rights Reserved. 1 Joe Berkovitz VP Engineering Allurent, Inc. Continuous Integration with Flex, FlexUnit, and Ant

Embed Size (px)

Citation preview

Page 1: 2007 Adobe Systems Incorporated. All Rights Reserved. 1 Joe Berkovitz VP Engineering Allurent, Inc. Continuous Integration with Flex, FlexUnit, and Ant

2007 Adobe Systems Incorporated. All Rights Reserved.1

Joe Berkovitz

VP Engineering

Allurent, Inc.

Continuous Integration with Flex, FlexUnit, and Ant

Page 2: 2007 Adobe Systems Incorporated. All Rights Reserved. 1 Joe Berkovitz VP Engineering Allurent, Inc. Continuous Integration with Flex, FlexUnit, and Ant

2007 Adobe Systems Incorporated. All Rights Reserved.2

Is your build process like a Rube Goldberg contraption?

Manual

Fragile

Missing

Current Build Process

Image Source: http://mousetrapcontraptions.com/rube-cartoons-2.html

Page 3: 2007 Adobe Systems Incorporated. All Rights Reserved. 1 Joe Berkovitz VP Engineering Allurent, Inc. Continuous Integration with Flex, FlexUnit, and Ant

2007 Adobe Systems Incorporated. All Rights Reserved.3

Goal of this talk is to introduce tools and techniques to create a continuous integration based build process.

Centralized

Automated

Self-Testing

Ideal Build Process

Image Source: http://science.ksc.nasa.gov/shuttle/missions/sts-105/images/contact105_medium.html

Page 4: 2007 Adobe Systems Incorporated. All Rights Reserved. 1 Joe Berkovitz VP Engineering Allurent, Inc. Continuous Integration with Flex, FlexUnit, and Ant

2007 Adobe Systems Incorporated. All Rights Reserved.4

Continuous Integration is a software development practice where members of a team integrate their work frequently.

Each integration is verified by an automated build and test that detects integration errors as quickly as possible.

Continuous Integration

Source: http://www.martinfowler.com/articles/continuousIntegration.html

Page 5: 2007 Adobe Systems Incorporated. All Rights Reserved. 1 Joe Berkovitz VP Engineering Allurent, Inc. Continuous Integration with Flex, FlexUnit, and Ant

2007 Adobe Systems Incorporated. All Rights Reserved.5

Continuous Integration Cycle

Source: http://www.methodsandtools.com/archive/archive.php?id=42

Page 6: 2007 Adobe Systems Incorporated. All Rights Reserved. 1 Joe Berkovitz VP Engineering Allurent, Inc. Continuous Integration with Flex, FlexUnit, and Ant

2007 Adobe Systems Incorporated. All Rights Reserved.6

Build Failure Notification

Page 7: 2007 Adobe Systems Incorporated. All Rights Reserved. 1 Joe Berkovitz VP Engineering Allurent, Inc. Continuous Integration with Flex, FlexUnit, and Ant

2007 Adobe Systems Incorporated. All Rights Reserved.7

Build Log

Page 8: 2007 Adobe Systems Incorporated. All Rights Reserved. 1 Joe Berkovitz VP Engineering Allurent, Inc. Continuous Integration with Flex, FlexUnit, and Ant

2007 Adobe Systems Incorporated. All Rights Reserved.8

Project Dashboard

Page 9: 2007 Adobe Systems Incorporated. All Rights Reserved. 1 Joe Berkovitz VP Engineering Allurent, Inc. Continuous Integration with Flex, FlexUnit, and Ant

2007 Adobe Systems Incorporated. All Rights Reserved.9

Project Distributions

Page 10: 2007 Adobe Systems Incorporated. All Rights Reserved. 1 Joe Berkovitz VP Engineering Allurent, Inc. Continuous Integration with Flex, FlexUnit, and Ant

2007 Adobe Systems Incorporated. All Rights Reserved.10

Continuous Integration Cycle

Page 11: 2007 Adobe Systems Incorporated. All Rights Reserved. 1 Joe Berkovitz VP Engineering Allurent, Inc. Continuous Integration with Flex, FlexUnit, and Ant

2007 Adobe Systems Incorporated. All Rights Reserved.11

Build Process

Source Code

Build File

Generated AssetsBuild Tool

Page 12: 2007 Adobe Systems Incorporated. All Rights Reserved. 1 Joe Berkovitz VP Engineering Allurent, Inc. Continuous Integration with Flex, FlexUnit, and Ant

2007 Adobe Systems Incorporated. All Rights Reserved.12

Project View

Project

Build File

Generated Assets/bin

/src Source Code

Build Tool

/

Page 13: 2007 Adobe Systems Incorporated. All Rights Reserved. 1 Joe Berkovitz VP Engineering Allurent, Inc. Continuous Integration with Flex, FlexUnit, and Ant

2007 Adobe Systems Incorporated. All Rights Reserved.13

Build Automation Tool

Widely Used

Extensive Documentation

Cross Platform

Robust

XML Based

Ant

Page 14: 2007 Adobe Systems Incorporated. All Rights Reserved. 1 Joe Berkovitz VP Engineering Allurent, Inc. Continuous Integration with Flex, FlexUnit, and Ant

2007 Adobe Systems Incorporated. All Rights Reserved.14

Project

Tree governed by a set of automated jobs or "targets"

Ideally corresponds 1-to-1 with real projects

XML defines targets

Key Ant Concepts

Property

• Holds a constant textual value or file location

• Accessed with ${xyz} syntax

• Environment or custom defined

Target

• Logical chunk of work

• Can depend on other targets

• Works like a script

Task

• Individual command

• Accepts arguments to control behavior

• Used in targets

Page 15: 2007 Adobe Systems Incorporated. All Rights Reserved. 1 Joe Berkovitz VP Engineering Allurent, Inc. Continuous Integration with Flex, FlexUnit, and Ant

2007 Adobe Systems Incorporated. All Rights Reserved.15

Ant Hello World Demonstration

Page 16: 2007 Adobe Systems Incorporated. All Rights Reserved. 1 Joe Berkovitz VP Engineering Allurent, Inc. Continuous Integration with Flex, FlexUnit, and Ant

2007 Adobe Systems Incorporated. All Rights Reserved.16

<project name="HelloWorld" default="build">

<property name="message" value="Hello World!"/>

<target name="init" description="Initialize the build">

<tstamp/>

</target>

<target name="build" depends="init" description="Build the Hello World project">

<echo message="${message} Today is ${TODAY}"/>

</target>

</project>

Hello World Build Script

Page 17: 2007 Adobe Systems Incorporated. All Rights Reserved. 1 Joe Berkovitz VP Engineering Allurent, Inc. Continuous Integration with Flex, FlexUnit, and Ant

2007 Adobe Systems Incorporated. All Rights Reserved.

Hello World Build Script Output

Executed build file

Name of target being run

Name of target being run

Task name and output

Result of the build

Diagnostic information

Buildfile: build.xml

init:

build:

[echo] Hello World! Today is September 17 2007

BUILD SUCCESSFUL

Total time: 0 seconds

17

Page 18: 2007 Adobe Systems Incorporated. All Rights Reserved. 1 Joe Berkovitz VP Engineering Allurent, Inc. Continuous Integration with Flex, FlexUnit, and Ant

2007 Adobe Systems Incorporated. All Rights Reserved.18

Ant mxmlc Demonstration

Page 19: 2007 Adobe Systems Incorporated. All Rights Reserved. 1 Joe Berkovitz VP Engineering Allurent, Inc. Continuous Integration with Flex, FlexUnit, and Ant

2007 Adobe Systems Incorporated. All Rights Reserved.19

<!-- Using the Flex Ant Tasks provided by Adobe Labs -->

<project name="SampleApplication" default="build">

<taskdef resource="flexTasks.tasks" classpath="${basedir}/flexTasks/lib/flexTasks.jar"/>

<property name="FLEX_HOME" value="C:/Talk/Flex2.0.1HF2"/>

<target name="build">

<mxmlc file="src/${ant.project.name}.mxml" output="bin/${ant.project.name}.swf">

<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>

<source-path path-element="${FLEX_HOME}/frameworks"/>

</mxmlc>

</target>

</project>

Compiling an Application

Page 20: 2007 Adobe Systems Incorporated. All Rights Reserved. 1 Joe Berkovitz VP Engineering Allurent, Inc. Continuous Integration with Flex, FlexUnit, and Ant

2007 Adobe Systems Incorporated. All Rights Reserved.20

Keep source and output separated

Don’t do work you’ve already done

Provide reasonable defaults

Centralize behavior

Predictability

Build Practices

Page 21: 2007 Adobe Systems Incorporated. All Rights Reserved. 1 Joe Berkovitz VP Engineering Allurent, Inc. Continuous Integration with Flex, FlexUnit, and Ant

2007 Adobe Systems Incorporated. All Rights Reserved.21

Build Templates

Source Code

Build File

Generated AssetsBuild Tool

Build Templates

User Specific

Overrides

Page 22: 2007 Adobe Systems Incorporated. All Rights Reserved. 1 Joe Berkovitz VP Engineering Allurent, Inc. Continuous Integration with Flex, FlexUnit, and Ant

2007 Adobe Systems Incorporated. All Rights Reserved.22

Build Templates

Encapsulates Best Practices

Handles Flex Applications, Libraries, and Documentation

Cross Project Dependencies

Multiple Project Builds

Antennae

Page 23: 2007 Adobe Systems Incorporated. All Rights Reserved. 1 Joe Berkovitz VP Engineering Allurent, Inc. Continuous Integration with Flex, FlexUnit, and Ant

2007 Adobe Systems Incorporated. All Rights Reserved.23

Antennae Demonstration

Page 24: 2007 Adobe Systems Incorporated. All Rights Reserved. 1 Joe Berkovitz VP Engineering Allurent, Inc. Continuous Integration with Flex, FlexUnit, and Ant

2007 Adobe Systems Incorporated. All Rights Reserved.24

<project name="SampleApplication" default="build">

<property name="root.dir" location="../"/>

<property file="${root.dir}/build-user.properties"/>

<import file="${root.dir}/tools/build-imports.xml"/>

<path id="flex2.lib.path"/>

<target name="build" depends="init,flex2-application" description="Build the application" />

</project>

Antennae Build Script

Page 25: 2007 Adobe Systems Incorporated. All Rights Reserved. 1 Joe Berkovitz VP Engineering Allurent, Inc. Continuous Integration with Flex, FlexUnit, and Ant

2007 Adobe Systems Incorporated. All Rights Reserved.25

Flex Builder can invoke Ant to compile a Flex project

Flex Builder can use Ant targets…

to do all build work

just to do the non-compilation steps

Using Ant and Flex Builder together

Page 26: 2007 Adobe Systems Incorporated. All Rights Reserved. 1 Joe Berkovitz VP Engineering Allurent, Inc. Continuous Integration with Flex, FlexUnit, and Ant

2007 Adobe Systems Incorporated. All Rights Reserved.26

Continuous Integration Cycle

Page 27: 2007 Adobe Systems Incorporated. All Rights Reserved. 1 Joe Berkovitz VP Engineering Allurent, Inc. Continuous Integration with Flex, FlexUnit, and Ant

2007 Adobe Systems Incorporated. All Rights Reserved.27

Build Verification

Supports Flex and ActionScript

Asynchronous Testing Facilities

Graphical Test Results

FlexUnit

Page 28: 2007 Adobe Systems Incorporated. All Rights Reserved. 1 Joe Berkovitz VP Engineering Allurent, Inc. Continuous Integration with Flex, FlexUnit, and Ant

2007 Adobe Systems Incorporated. All Rights Reserved.28

FlexUnit Test Results

Page 29: 2007 Adobe Systems Incorporated. All Rights Reserved. 1 Joe Berkovitz VP Engineering Allurent, Inc. Continuous Integration with Flex, FlexUnit, and Ant

2007 Adobe Systems Incorporated. All Rights Reserved.29

FlexUnit Demonstration

Page 30: 2007 Adobe Systems Incorporated. All Rights Reserved. 1 Joe Berkovitz VP Engineering Allurent, Inc. Continuous Integration with Flex, FlexUnit, and Ant

2007 Adobe Systems Incorporated. All Rights Reserved.30

FlexUnit Automation

Test Suite Generation

Test Filtering

Actionscript to Java Result Reporting

Antennae

Page 31: 2007 Adobe Systems Incorporated. All Rights Reserved. 1 Joe Berkovitz VP Engineering Allurent, Inc. Continuous Integration with Flex, FlexUnit, and Ant

2007 Adobe Systems Incorporated. All Rights Reserved.31

Antennae Demonstration

Page 32: 2007 Adobe Systems Incorporated. All Rights Reserved. 1 Joe Berkovitz VP Engineering Allurent, Inc. Continuous Integration with Flex, FlexUnit, and Ant

2007 Adobe Systems Incorporated. All Rights Reserved.32

<project name="SampleTestApplication" default="test">

<!-- Shared imports -->

<import file="${root.dir}/lib/build-assets.xml" />

<path id="flex2.lib.path">

<pathelement location="${flexunit2.swc}"/>

<pathelement location="${arc-flexunit2.swc}"/>

<!-- Include asset under test here -->

</path>

<target name="build" depends="init,flex2-test-application" description="Build the test application"/>

<target name="test" depends="build,test-flexunit2" description="Run the test application"/>

</project>

Automated Test Script

Page 33: 2007 Adobe Systems Incorporated. All Rights Reserved. 1 Joe Berkovitz VP Engineering Allurent, Inc. Continuous Integration with Flex, FlexUnit, and Ant

2007 Adobe Systems Incorporated. All Rights Reserved.33

Continuous Integration Cycle

Page 34: 2007 Adobe Systems Incorporated. All Rights Reserved. 1 Joe Berkovitz VP Engineering Allurent, Inc. Continuous Integration with Flex, FlexUnit, and Ant

2007 Adobe Systems Incorporated. All Rights Reserved.34

Ant Demonstration

Page 35: 2007 Adobe Systems Incorporated. All Rights Reserved. 1 Joe Berkovitz VP Engineering Allurent, Inc. Continuous Integration with Flex, FlexUnit, and Ant

2007 Adobe Systems Incorporated. All Rights Reserved.35

Complex Project Demonstration

Page 36: 2007 Adobe Systems Incorporated. All Rights Reserved. 1 Joe Berkovitz VP Engineering Allurent, Inc. Continuous Integration with Flex, FlexUnit, and Ant

2007 Adobe Systems Incorporated. All Rights Reserved.36

Complex Project View

SubProject1

Assets/bin

/srcSource Code

assets

SubProject2

Assets/bin

/srcSource Code

imports

Project

Build File

/proj2

/proj1

/

Page 37: 2007 Adobe Systems Incorporated. All Rights Reserved. 1 Joe Berkovitz VP Engineering Allurent, Inc. Continuous Integration with Flex, FlexUnit, and Ant

2007 Adobe Systems Incorporated. All Rights Reserved.37

Many small projects keep dependencies under control

But… Flex Builder is very slow when building many Library Projects

Solution: Create single Flex Builder "super-project" that has multiple source paths in multiple projects.

Building Complex Projects with Flex Builder

Page 38: 2007 Adobe Systems Incorporated. All Rights Reserved. 1 Joe Berkovitz VP Engineering Allurent, Inc. Continuous Integration with Flex, FlexUnit, and Ant

2007 Adobe Systems Incorporated. All Rights Reserved.38

Continuous Integration Cycle

Page 39: 2007 Adobe Systems Incorporated. All Rights Reserved. 1 Joe Berkovitz VP Engineering Allurent, Inc. Continuous Integration with Flex, FlexUnit, and Ant

2007 Adobe Systems Incorporated. All Rights Reserved.39

Key Concepts Source code repository

Clean build machine

Runs after every commit

Popular platforms CruiseControl

Apache Continuum

Many others

Continuous Integration

Page 40: 2007 Adobe Systems Incorporated. All Rights Reserved. 1 Joe Berkovitz VP Engineering Allurent, Inc. Continuous Integration with Flex, FlexUnit, and Ant

2007 Adobe Systems Incorporated. All Rights Reserved.40

Ant http://ant.apache.org/

FlexUnit http://code.google.com/p/as3flexunitlib/

Antennae http://code.google.com/p/antennae/

Continuous Integration Matrix http://docs.codehaus.org/x/gCk

Flex Ant Tasks http://labs.adobe.com/wiki/index.php/Flex_Ant_Tasks

Resources

Page 41: 2007 Adobe Systems Incorporated. All Rights Reserved. 1 Joe Berkovitz VP Engineering Allurent, Inc. Continuous Integration with Flex, FlexUnit, and Ant

2007 Adobe Systems Incorporated. All Rights Reserved.41

Q & A