Continuous Integration on my work

Post on 27-Jan-2015

106 views 2 download

Tags:

description

 

transcript

Continuous Integration on my work

Kewang

2

Agenda

● What is Continuous Integration ?● CI software● CI integrate 3rd-party software● How to apply CI to my work ?● Live DEMO● CI Principles● TODO list

What is Continuous Integration ?

4

Continuous Integration is ...

● CI● An important role at Agile & TDD

5

Continuous Integration should have

● Split source code to small & easy-maintain snippets● Test snippets● Commit source code to VCS frequently● Auto checkout latest source code & run all tests

Case Study

7

Case Study 1

8

Case Study 2

9

Case Study 3

CI software

11

Travis CI

12

Hudson / Jenkins

CI integrate 3rd-party software

14

3rd-party software includes ...

● Version Control System (i.e. Git / SVN / others)● Redmine● Maven● Pandoc● more & more ......

15

Git

● git clone● git add● git rm● git commit● git pull

● git push● git branch● git checkout● git merge

16

Redmine

● Project management● Issue tracking● Wiki● Forum● File management

17

Maven

● Making the build process easy● Providing a uniform build system● Convention over Configuration (CoC)● Dependency management

18

Pandoc

● It can convert markup file to many format documents.

● Markup file, like Markdown, HTML, LaTeX, Wiki, or other markup language.

● Artifact has more format, like Markdown, HTML, docx, EPUB, PDF, ......etc.

How to apply CI to my work ?

20

Example

● Auto-deploy backend program● Auto-publish API spec

Auto-deploy backend program

22

Step by step

1.Check out the latest source code

2.Compile it to jar file

3.Upload to backend

23

Step by step

1.Check out the latest source code from `dev`

2.Compile it to jar file

3.Merge `dev` to `master`

4.Upload to backend

24

Step by step

1.Check out the latest source code from `dev`

2.Compile it to jar file

3.Merge `dev` to `master`

4.Upload to backend1. Stop backend

25

Step by step

1.Check out the latest source code from `dev`

2.Compile it to jar file

3.Merge `dev` to `master`

4.Upload to backend1. Stop backend

2. Copy jar & its dependency files to backend

26

Step by step

1.Check out the latest source code from `dev`

2.Compile it to jar file

3.Merge `dev` to `master`

4.Upload to backend1. Stop backend

2. Copy jar & its dependency files to backend

3. Start backend

27

Step by step

1.Check out the latest source code from `dev`

2.Compile it to jar file

3.Merge `dev` to `master`

4.Upload to backend1. Stop backend

2. Copy jar & its dependency files to backend

3. Start backend

5.Send mail to all RD

28

Step by step

1.Check out the latest source code from `dev`

2.Compile it to jar file

3.Merge `dev` to `master`

4.Upload to backend1. Stop backend

2. Copy jar & its dependency files to backend

3. Start backend

5.Send mail to all RD1. Send mail to backend RD if failure

Auto-publish API spec

30

Step by step

1.Check out the latest Markdown

2.Convert Markdown to PDF

3.Upload PDF to Redmine

31

Step by step

1.Check out the latest Markdown from `dev`

2.Convert Markdown to PDF

3.Upload PDF to Redmine

4.Merge `dev` to `master`

32

Step by step

1.Check out the latest Markdown from `dev`

2.Convert Markdown to PDF

3.Upload PDF to Redmine1. Call RESTful API to upload PDF file to Redmine

4.Merge `dev` to `master`

33

Step by step

1.Check out the latest Markdown from `dev`

2.Convert Markdown to PDF

3.Upload PDF to Redmine1. Call RESTful API to upload PDF file to Redmine

2. Send file id to Redmine

4.Merge `dev` to `master`

34

Step by step

1.Check out the latest Markdown from `dev`

2.Convert Markdown to PDF

3.Upload PDF to Redmine1. Call RESTful API to upload PDF file to Redmine

2. Send file id to Redmine

3. Place the file into Files at Redmine

4.Merge `dev` to `master`

35

Step by step

1.Check out the latest Markdown from `dev`

2.Convert Markdown to PDF

3.Upload PDF to Redmine1. Call RESTful API to upload PDF file to Redmine

2. Send file id to Redmine

3. Place the file into Files at Redmine

4.Merge `dev` to `master`

5.Send file link at Redmine to all RD

Live DEMO

CI Principles

38

Principles for Developers

1.Commit code frequently

39

Principles for Developers

1.Commit code frequently

2.Don't commit broken code

40

Principles for Developers

1.Commit code frequently

2.Don't commit broken code

3.Fix broken builds immediately

41

Principles for Developers

1.Commit code frequently

2.Don't commit broken code

3.Fix broken builds immediately

4.Write automated developers tests

42

Principles for Developers

1.Commit code frequently

2.Don't commit broken code

3.Fix broken builds immediately

4.Write automated developers tests

5.All tests and inspections must pass

43

Principles for Developers

1.Commit code frequently

2.Don't commit broken code

3.Fix broken builds immediately

4.Write automated developers tests

5.All tests and inspections must pass

6.Run private builds

44

Principles for Developers

1.Commit code frequently

2.Don't commit broken code

3.Fix broken builds immediately

4.Write automated developers tests

5.All tests and inspections must pass

6.Run private builds

7.Avoid getting broken code

45

Principles for CI Engineers

1.Automate builds

46

Principles for CI Engineers

1.Automate builds

2.Perform single command builds

47

Principles for CI Engineers

1.Automate builds

2.Perform single command builds

3.Separate build scripts from your IDE

48

Principles for CI Engineers

1.Automate builds

2.Perform single command builds

3.Separate build scripts from your IDE

4.Centralize software assets

49

Principles for CI Engineers

1.Automate builds

2.Perform single command builds

3.Separate build scripts from your IDE

4.Centralize software assets

5.Create a consistent directory structure

50

Principles for CI Engineers

1.Automate builds

2.Perform single command builds

3.Separate build scripts from your IDE

4.Centralize software assets

5.Create a consistent directory structure

6.Fail builds fast

51

Principles for CI Engineers

1.Automate builds

2.Perform single command builds

3.Separate build scripts from your IDE

4.Centralize software assets

5.Create a consistent directory structure

6.Fail builds fast

7.Build for any environment

52

Principles for CI Engineers

1.Automate builds

2.Perform single command builds

3.Separate build scripts from your IDE

4.Centralize software assets

5.Create a consistent directory structure

6.Fail builds fast

7.Build for any environment

8.Use a dedicated CI machine and a CI server

53

Principles for CI Engineers

1.Automate builds

2.Perform single command builds

3.Separate build scripts from your IDE

4.Centralize software assets

5.Create a consistent directory structure

6.Fail builds fast

7.Build for any environment

8.Use a dedicated CI machine and a CI server

9.Run fast builds

54

Principles for CI Engineers

1.Automate builds

2.Perform single command builds

3.Separate build scripts from your IDE

4.Centralize software assets

5.Create a consistent directory structure

6.Fail builds fast

7.Build for any environment

8.Use a dedicated CI machine and a CI server

9.Run fast builds

10.State builds

TODO list

56

TODO list

1.Run unit tests

57

TODO list

1.Run unit tests

2.Every commit build

58

TODO list

1.Run unit tests

2.Every commit build

3.Static code analysis

59

TODO list

1.Run unit tests

2.Every commit build

3.Static code analysis

4.Multi-environment deployment