ლექცია_6__Build__სლაიდებიx

Download Report

Transcript ლექცია_6__Build__სლაიდებიx

პროგრამული
უზრუნველყოფის შექმნის
პროცესები
ლექცია 5 – Automated Build
წარდგენა
გიორგი მამალაძე
George Mamaladze
Software Architect
Siemens I IA AS CTO
mailto:[email protected]
იოსებ ძმანაშვილი
Ioseb Dzmanashvili
Ph.D Candidate
Software Architect at AzRy LLC
mailto:[email protected]
რა არის SD პროცესი?
მოთხოვნები
პრიორიტეტები
პრინციპები
UML
პატერნები
შრეებიანი
დიზაინი
Test Doubles
Unit Tests
IDE & VCS
რა არის SD პროცესი?
მოთხოვნები
პრიორიტეტები
პრინციპები
UML
Continuous
Integration
Build
პატერნები
შრეებიანი
დიზაინი
Test Doubles
Unit Tests
IDE & VCS
დღეს
•
•
•
•
•
Build - ცნება
Build Script
Build Tool
Continuous Integration
Managing Build Dependencies
პროდუქტი არ არის მხოლოდ კოდი
Build Process
VCS
პროგრამისტები
?
Executable
Distributable
მომხმარებელი
Build პროცესი
Source
Source
Source
Code
Code
Code
Executable
Executable
Executable
Help &
Doc
Distributable
VCS
Other
Artefacts
3d Party
•Compression
•Packaging
•Signing
Build პროცესი
•თანამედროვე პროდუქტები შედგება მრავალი
ათასი კოდის ფაილისაგან, რომლებიც
ორგანიზებულია პროექტებად.
•საბოლლო პროდუქტი შეიცავს მრავალ არტეფაქტს
რომელიც (უშუალოდ) კოდისგან არ მიიღება.
•არტეფაქტებისა და პროგრამული კოდისგან
პროდუქტის შესაქმნელად საჭიროა მრავალი
ნაბიჯის სწორი თანამიმდევრობით შესრულება.
Evolution of Build
• Manual Build - It is error prone and inefficient to carry
them by hand.
• Soulution: Build Scripts
%CLASSPATH%=C:\Program Files\Java\jdk1.6\bin START %CLASSPATH%\javac Main.java
Cons:
• Difficult to manage
• Do not recognize dependencies – we always build the „whole world“.
Dependencies
Critical for automated tools is knowing dependencies: which project
artifact depends on another when it is constructed.
Knowing dependencies allows to recognize artifacts on affected
paths and build just them.
Soulution: Build Tool
Build Tool vs Script
Build script:
The user specifies
what will be used,
what to do and
the order in which to do.
Build tool:
The user specifies
what will be used (typically source code files) and
what the result should be (typically an application),
but the utility itself decides
what to do and
the order in which to do it.
Build Tools
The (UNIX) make command requires an input file, called ‘makefile’ (or ‘Makefile’), to describe
the dependencies between files and how to update them. It consists of multiple entries
(production blocks) of the following format:
target: [dependencies]
commands to build it
• Commands are executed if at least one of the dependencies is younger than the target.
• To update the target f with respect to the files on which it depends, type ‘make f’ into
the shell
• Just saying ‘make’ updates the first target named in makefile
make
all: hello
all
hello: main.o factorial.o hello.o
g++ main.o factorial.o hello.o
hello
main.o: main.cpp
g++ -c main.cpp
factorial.o: factorial.cpp
g++ -c factorial.cpp
hello.o: hello.cpp
g++ -c hello.cpp
clean:
rm -rf *o hello
main.o
factorial.o
hello.o
main.cpp
factorial.cpp
hello.cpp
Ant
make – was overkill for java. One needs rules expressing java native implicit dependencies –
e.g the dependency between X.java and X.class or expressing source code dependencies.
Ant, Another Neat Tool from Apache, is better suited as an for Java projects, and is de facto
standard tool for building applications in Java environment.
<project name="MyProject" default="dist" basedir=".">
<description>
simple example build file
</description>
<!-- set global properties for this build -->
<property name="src" location="src"/>
<property name="build" location="build"/>
<property name="dist" location="dist"/>
Ant
<target name="init">
<!-- Create the time stamp -->
<tstamp/>
<!-- Create the build directory structure used by compile -->
<mkdir dir="${build}"/>
</target>
<target name="compile" depends="init"
description="compile the source " >
<!-- Compile the java code from ${src} into ${build} -->
<javac srcdir="${src}" destdir="${build}"/>
</target>
<target name="dist" depends="compile"
description="generate the distribution" >
<!-- Create the distribution directory -->
<mkdir dir="${dist}/lib"/>
<!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file -->
<jar jarfile="${dist}/lib/MyProject-${DSTAMP}.jar" basedir="${build}"/>
</target>
<target name="clean"
description="clean up" >
<!-- Delete the ${build} and ${dist} directory trees -->
<delete dir="${build}"/>
<delete dir="${dist}"/>
</target>
</project>
Ant
Ant has targets (like make) and tasks.
Some of the Ant core tasks:
• “compile” tasks — depend, javac, apt. . .
• “execution” tasks — ant, exec, java, sleep, waitfor. . .
• “documentation” task — javadoc. . .
• “archive” tasks — jar, manifest, zip. . .
• miscellaneous tasks — echo, fail, sound. . .
Parameters for execution of tasks. Examples: <fileset>,
<classpath>, <path> and <pathelement>, <arg> and many others.
Ant is written in (surprise ) Java, has its own API which can be used to define custom task.
MSBuild
is a Microsoft build platform
works together with Visual Studio
is available at no cost
acts on project files which have a similar XML
syntax to Ant
Difference:
Project files are also used by IDE to manage projects.
Maven, the next step
Maven – yet another build tool?
Maven – is “Java project-management and project-comprehension tool.”
(Apache web site).
There are number of issues when using ant if a project has an non-trivial and
complex structure, an includes custom defined tasks.
Maven solves these problems and includes features which are designed to
increase productivity.
Build Automation
3. Continous
Integration Software
2. Build Tool
1. Script
Compiler,
Zip
etc.
CI Workflow
Continuous Integration Software
• Integrates with VCS allowing Gated Check-Ins (Pre-Tested Commits).
• Build Farm (Build Grid), Test Farm
• Integrates static code analyses, code coverage, duplicates search etc.
• Integration with Issue Tracking Systems
• Support of multiple platforms for mixed apps: Java, .NET, Ruby etc.
• Communication: Email, Feed, Messenger etc.
• User friendly (web) interface – single enty pint URL
Build Workflows: 1. Gated Check-In
Build
Unit
Test
VCS
Prevents developers from breaking sources in the version control system by running the build
remotely for local changes prior to commit
Recommended duration max.: 5 min
Build Workflows: 2. Rolling Build
Triggered
VCS
Get
Build
Messaging
Integration
Test
Issue
Track.
Is triggered
• … in predefined intervals
• …after certain number of Ceck-Ins
• …as soon as previous is finished
Recommended duration: ~ 30min
Reports
Build Workflows: 3. Nightly Build
VCS
Get
Build
Package
Deploy
Is triggered regularily or manually.
Is very time consuming ~ 24h
End User
Test
Label
Publish
XFD – eXtreme Feedback Device
Let Your Project Speak for Itself!
http://programmer.97things.oreilly.com/wiki/index.php/Let_Your_Project_Speak_for_Itself
Build Workflows: 3. Nightly Build
VCS
Get
Build
Package
Deploy
Is triggered regularily or manually.
Is very time consuming ~ 24h
End User
Test
Label
Publish
Drop Location
Storing and versioning binaries (build results):
These can be used:
• to deliver to customer
• as a pre-compiled working base for the next day
• long time archive to reproduce customer issues
• reproduce defects easily
Build Farm / Grid
Multiple servers build in parallel
Controller distributes load
Agents perform portions of build
Testing in Parallel
App Test Rack
User friendly (Web) Interface
Team City Demo
http://tv.jetbrains.net/videocontent/teamcity-demo-building-maven-with-mavenfrom-a-to-z-in-5-minutes
Managing Build
Dependencies
Quick Build is a design issue.
ისევ შრეები ... და Build პროცესი
Dependency Inversion Principle
Step2: Introduce interfaces
Initial state
100%
StopLight.dll
Step1
Build chains and times
25%
StopLight.UI.dll
50%
StopLight.Logic.dll
100%
StopLight.Interfaces.dll
75%
StopLight.Services.dll
Step2
25%
StopLight.UI.dll
0%
StopLight.dll
25%
StopLight.Logic.dll
25%
StopLight.Services.dll
100%
StopLight.Interfaces.dll
DI Frameworks
https://www.youtube.com/watch?v=hBVJbzAagfs
Feedback
გთხოვთ გაგვიზიროთ კომენტარები, სურვილები,
შესწორებები PIAZZA-ს საშუალებით.