+ All Categories
Home > Documents > From code commit to shipping it - University of WashingtonΒ Β· 2019. 3. 16.Β Β· Saving 50% of tests!...

From code commit to shipping it - University of WashingtonΒ Β· 2019. 3. 16.Β Β· Saving 50% of tests!...

Date post: 15-Sep-2020
Category:
Upload: others
View: 1 times
Download: 0 times
Share this document with a friend
40
Kim Herzig Senior Software Engineering Manager Development pipelines From code commit to shipping it 1
Transcript
Page 1: From code commit to shipping it - University of WashingtonΒ Β· 2019. 3. 16.Β Β· Saving 50% of tests! = π‘Ž βˆ— 𝑖 π‘Ž βˆ— π‘€π‘Ž β„Žπ‘– =10,000βˆ—0.12secβˆ—5.14 βˆ’4 $ΰ΅— =$𝟎.πŸ”πŸ

Kim HerzigSenior Software Engineering Manager

Development pipelinesFrom code commit to shipping it

1

Page 2: From code commit to shipping it - University of WashingtonΒ Β· 2019. 3. 16.Β Β· Saving 50% of tests! = π‘Ž βˆ— 𝑖 π‘Ž βˆ— π‘€π‘Ž β„Žπ‘– =10,000βˆ—0.12secβˆ—5.14 βˆ’4 $ΰ΅— =$𝟎.πŸ”πŸ

There cannot be a more important thing for an

engineer, for a product team, than to work on

the systems that drive our productivity.

So I would, any day of the week, trade off

features for our own productivity.

I want our best engineers to work on our

engineering systems, so that we can later on

come back and build all of the new concepts we

want.

2

Page 3: From code commit to shipping it - University of WashingtonΒ Β· 2019. 3. 16.Β Β· Saving 50% of tests! = π‘Ž βˆ— 𝑖 π‘Ž βˆ— π‘€π‘Ž β„Žπ‘– =10,000βˆ—0.12secβˆ—5.14 βˆ’4 $ΰ΅— =$𝟎.πŸ”πŸ

3

Development Processes

By Beao Old waterfall: Paul Smith - File:Waterfall model revised.svgFile:Rapid application software

development.svgFile:Software Development Spiral.svg, Public Domain,

https://commons.wikimedia.org/w/index.php?curid=7836950

By Mark - Own work, CC BY-SA 4.0, https://commons.wikimedia.org/w/index.php?curid=68365751

By Lakeworks - Own work, CC BY-SA 4.0,

https://commons.wikimedia.org/w/index.php?curid=3526338

Page 4: From code commit to shipping it - University of WashingtonΒ Β· 2019. 3. 16.Β Β· Saving 50% of tests! = π‘Ž βˆ— 𝑖 π‘Ž βˆ— π‘€π‘Ž β„Žπ‘– =10,000βˆ—0.12secβˆ—5.14 βˆ’4 $ΰ΅— =$𝟎.πŸ”πŸ

Pre-check-in Integration process 4

Inner & Outer Development Loop

Page 5: From code commit to shipping it - University of WashingtonΒ Β· 2019. 3. 16.Β Β· Saving 50% of tests! = π‘Ž βˆ— 𝑖 π‘Ž βˆ— π‘€π‘Ž β„Žπ‘– =10,000βˆ—0.12secβˆ—5.14 βˆ’4 $ΰ΅— =$𝟎.πŸ”πŸ

One Iteration

Pre-check-in Integration process

Controlled by engineer Controlled by policies

Page 6: From code commit to shipping it - University of WashingtonΒ Β· 2019. 3. 16.Β Β· Saving 50% of tests! = π‘Ž βˆ— 𝑖 π‘Ž βˆ— π‘€π‘Ž β„Žπ‘– =10,000βˆ—0.12secβˆ—5.14 βˆ’4 $ΰ΅— =$𝟎.πŸ”πŸ

6

Phase 1

Planning

Page 7: From code commit to shipping it - University of WashingtonΒ Β· 2019. 3. 16.Β Β· Saving 50% of tests! = π‘Ž βˆ— 𝑖 π‘Ž βˆ— π‘€π‘Ž β„Žπ‘– =10,000βˆ—0.12secβˆ—5.14 βˆ’4 $ΰ΅— =$𝟎.πŸ”πŸ

Objectives and Key Results: OKR

7

β€’ Set quarterly goals

Measure metric progress

Share with leaders & co-workers

Methodology

β€’ Common goal set

β€’ Teams are aligned and linked

β€’ Transparency to everyone

Goals

Objective:

80% of Microsoft integration builds

performed using CloudBuild.

Key Results:

- Select top 10 teams not utilizing CloudBuild

by March.

- Perform gap analysis for these teams by April.

- Implement 90% of required features in

CloudBuild by July.

- Start migration process and transition 80% of

builds to CloudBuild before December.

Page 8: From code commit to shipping it - University of WashingtonΒ Β· 2019. 3. 16.Β Β· Saving 50% of tests! = π‘Ž βˆ— 𝑖 π‘Ž βˆ— π‘€π‘Ž β„Žπ‘– =10,000βˆ—0.12secβˆ—5.14 βˆ’4 $ΰ΅— =$𝟎.πŸ”πŸ

Kanban

8

Req

uire

s revie

w/a

pp

roval

Page 9: From code commit to shipping it - University of WashingtonΒ Β· 2019. 3. 16.Β Β· Saving 50% of tests! = π‘Ž βˆ— 𝑖 π‘Ž βˆ— π‘€π‘Ž β„Žπ‘– =10,000βˆ—0.12secβˆ—5.14 βˆ’4 $ΰ΅— =$𝟎.πŸ”πŸ

9

Phase 2

Coding

Page 10: From code commit to shipping it - University of WashingtonΒ Β· 2019. 3. 16.Β Β· Saving 50% of tests! = π‘Ž βˆ— 𝑖 π‘Ž βˆ— π‘€π‘Ž β„Žπ‘– =10,000βˆ—0.12secβˆ—5.14 βˆ’4 $ΰ΅— =$𝟎.πŸ”πŸ

Simple Scenario

Unit testing

β€’ Code changes are applied into a single repository.

β€’ Code changes are immediately visible for everybody.

β€’ Unit tests check for functional correctness at function/method level

β€’ Developer run β€œtheir” tests.

Development branchtime

Page 11: From code commit to shipping it - University of WashingtonΒ Β· 2019. 3. 16.Β Β· Saving 50% of tests! = π‘Ž βˆ— 𝑖 π‘Ž βˆ— π‘€π‘Ž β„Žπ‘– =10,000βˆ—0.12secβˆ—5.14 βˆ’4 $ΰ΅— =$𝟎.πŸ”πŸ

But …

Development branchtime

β€’ Thousands of engineers.

β€’ Millions of lines of code and millions of changes.

β€’ Different organizational groups distributed around the world.

β€’ Shared code: Windows Desktop, Server, Phone, Azure, Xbox, …

Build durationBuild duration

Build durationBuild duration

Page 12: From code commit to shipping it - University of WashingtonΒ Β· 2019. 3. 16.Β Β· Saving 50% of tests! = π‘Ž βˆ— 𝑖 π‘Ž βˆ— π‘€π‘Ž β„Žπ‘– =10,000βˆ—0.12secβˆ—5.14 βˆ’4 $ΰ΅— =$𝟎.πŸ”πŸ

time Build 1

Repo strategies

Build 2Build 3

Build 4Build 5

Overlay: Works well on componentized

products with clear interfaces.

time Build 1

Locking: Creates long build queues

and bottlenecks.

Page 13: From code commit to shipping it - University of WashingtonΒ Β· 2019. 3. 16.Β Β· Saving 50% of tests! = π‘Ž βˆ— 𝑖 π‘Ž βˆ— π‘€π‘Ž β„Žπ‘– =10,000βˆ—0.12secβˆ—5.14 βˆ’4 $ΰ΅— =$𝟎.πŸ”πŸ

Repo strategies

Rolling: Fast, but when failing hard to

find issue.

time

Build 2Build 1

Branching: Can get very complex and

slow.

time

Page 14: From code commit to shipping it - University of WashingtonΒ Β· 2019. 3. 16.Β Β· Saving 50% of tests! = π‘Ž βˆ— 𝑖 π‘Ž βˆ— π‘€π‘Ž β„Žπ‘– =10,000βˆ—0.12secβˆ—5.14 βˆ’4 $ΰ΅— =$𝟎.πŸ”πŸ

14

Phase 3

(Local?) Building

Page 15: From code commit to shipping it - University of WashingtonΒ Β· 2019. 3. 16.Β Β· Saving 50% of tests! = π‘Ž βˆ— 𝑖 π‘Ž βˆ— π‘€π‘Ž β„Žπ‘– =10,000βˆ—0.12secβˆ—5.14 βˆ’4 $ΰ΅— =$𝟎.πŸ”πŸ

Local (?) builds

15

Editor Compiler Processes Write to disk

Local machine

Cache

Cache hit!

Page 16: From code commit to shipping it - University of WashingtonΒ Β· 2019. 3. 16.Β Β· Saving 50% of tests! = π‘Ž βˆ— 𝑖 π‘Ž βˆ— π‘€π‘Ž β„Žπ‘– =10,000βˆ—0.12secβˆ—5.14 βˆ’4 $ΰ΅— =$𝟎.πŸ”πŸ

Local (?) builds

16

Editor Write to diskCompiler Processes

Local machine

Cache

No cache hit!

Shim

Page 17: From code commit to shipping it - University of WashingtonΒ Β· 2019. 3. 16.Β Β· Saving 50% of tests! = π‘Ž βˆ— 𝑖 π‘Ž βˆ— π‘€π‘Ž β„Žπ‘– =10,000βˆ—0.12secβˆ—5.14 βˆ’4 $ΰ΅— =$𝟎.πŸ”πŸ
Page 18: From code commit to shipping it - University of WashingtonΒ Β· 2019. 3. 16.Β Β· Saving 50% of tests! = π‘Ž βˆ— 𝑖 π‘Ž βˆ— π‘€π‘Ž β„Žπ‘– =10,000βˆ—0.12secβˆ—5.14 βˆ’4 $ΰ΅— =$𝟎.πŸ”πŸ

18

Phase 4

Unit-Testing

Page 19: From code commit to shipping it - University of WashingtonΒ Β· 2019. 3. 16.Β Β· Saving 50% of tests! = π‘Ž βˆ— 𝑖 π‘Ž βˆ— π‘€π‘Ž β„Žπ‘– =10,000βˆ—0.12secβˆ—5.14 βˆ’4 $ΰ΅— =$𝟎.πŸ”πŸ

Local Unit Testing

19

As you write code Live Unit Testing automatically runs

any impacted unit tests in the background

and presents the results and code coverage in real time.

Page 20: From code commit to shipping it - University of WashingtonΒ Β· 2019. 3. 16.Β Β· Saving 50% of tests! = π‘Ž βˆ— 𝑖 π‘Ž βˆ— π‘€π‘Ž β„Žπ‘– =10,000βˆ—0.12secβˆ—5.14 βˆ’4 $ΰ΅— =$𝟎.πŸ”πŸ

20

Phase 5

Code Reviews

Page 21: From code commit to shipping it - University of WashingtonΒ Β· 2019. 3. 16.Β Β· Saving 50% of tests! = π‘Ž βˆ— 𝑖 π‘Ž βˆ— π‘€π‘Ž β„Žπ‘– =10,000βˆ—0.12secβˆ—5.14 βˆ’4 $ΰ΅— =$𝟎.πŸ”πŸ

Branch Policies

21

Page 23: From code commit to shipping it - University of WashingtonΒ Β· 2019. 3. 16.Β Β· Saving 50% of tests! = π‘Ž βˆ— 𝑖 π‘Ž βˆ— π‘€π‘Ž β„Žπ‘– =10,000βˆ—0.12secβˆ—5.14 βˆ’4 $ΰ΅— =$𝟎.πŸ”πŸ

Live Share

23

Page 24: From code commit to shipping it - University of WashingtonΒ Β· 2019. 3. 16.Β Β· Saving 50% of tests! = π‘Ž βˆ— 𝑖 π‘Ž βˆ— π‘€π‘Ž β„Žπ‘– =10,000βˆ—0.12secβˆ—5.14 βˆ’4 $ΰ΅— =$𝟎.πŸ”πŸ

24

Phase 6

Integration Builds

Page 25: From code commit to shipping it - University of WashingtonΒ Β· 2019. 3. 16.Β Β· Saving 50% of tests! = π‘Ž βˆ— 𝑖 π‘Ž βˆ— π‘€π‘Ž β„Žπ‘– =10,000βˆ—0.12secβˆ—5.14 βˆ’4 $ΰ΅— =$𝟎.πŸ”πŸ

Build-Graph

25

β€’ Prior to build: build dependency graph (DAG).

β€’ Models dependencies between projects.

β€’ Hashing compiler inputs …

β€’ … rebuilds only targets for which hash lookup failed

β€’ Distributed build tasks across machines and CPUs

40,000 feet overview

Page 26: From code commit to shipping it - University of WashingtonΒ Β· 2019. 3. 16.Β Β· Saving 50% of tests! = π‘Ž βˆ— 𝑖 π‘Ž βˆ— π‘€π‘Ž β„Žπ‘– =10,000βˆ—0.12secβˆ—5.14 βˆ’4 $ΰ΅— =$𝟎.πŸ”πŸ

Unit-testing

26

β€’ Tests run in parallel of build tasks (usually using under-utilized CPUs)

β€’ Only run tests for projects that will build.

Page 27: From code commit to shipping it - University of WashingtonΒ Β· 2019. 3. 16.Β Β· Saving 50% of tests! = π‘Ž βˆ— 𝑖 π‘Ž βˆ— π‘€π‘Ž β„Žπ‘– =10,000βˆ—0.12secβˆ—5.14 βˆ’4 $ΰ΅— =$𝟎.πŸ”πŸ

Integration Builds: CloudBuild (1) Build

Unit test Code Coverage

Automatic retry

Flaky test management

Static analyses Code smell

Security vulnerabilities

Bad code behavior, e.g. leap year issue

Audit logs

Code Signing27

Page 28: From code commit to shipping it - University of WashingtonΒ Β· 2019. 3. 16.Β Β· Saving 50% of tests! = π‘Ž βˆ— 𝑖 π‘Ž βˆ— π‘€π‘Ž β„Žπ‘– =10,000βˆ—0.12secβˆ—5.14 βˆ’4 $ΰ΅— =$𝟎.πŸ”πŸ

Integration Builds: CloudBuild (1)

28

Page 29: From code commit to shipping it - University of WashingtonΒ Β· 2019. 3. 16.Β Β· Saving 50% of tests! = π‘Ž βˆ— 𝑖 π‘Ž βˆ— π‘€π‘Ž β„Žπ‘– =10,000βˆ—0.12secβˆ—5.14 βˆ’4 $ΰ΅— =$𝟎.πŸ”πŸ

29

Phase 7

System Testing

Page 30: From code commit to shipping it - University of WashingtonΒ Β· 2019. 3. 16.Β Β· Saving 50% of tests! = π‘Ž βˆ— 𝑖 π‘Ž βˆ— π‘€π‘Ž β„Žπ‘– =10,000βˆ—0.12secβˆ—5.14 βˆ’4 $ΰ΅— =$𝟎.πŸ”πŸ

Integration Testing: CloudTest

30

40,000 feet overview

Page 31: From code commit to shipping it - University of WashingtonΒ Β· 2019. 3. 16.Β Β· Saving 50% of tests! = π‘Ž βˆ— 𝑖 π‘Ž βˆ— π‘€π‘Ž β„Žπ‘– =10,000βˆ—0.12secβˆ—5.14 βˆ’4 $ΰ΅— =$𝟎.πŸ”πŸ

31

Phase 8

Deployment

Page 32: From code commit to shipping it - University of WashingtonΒ Β· 2019. 3. 16.Β Β· Saving 50% of tests! = π‘Ž βˆ— 𝑖 π‘Ž βˆ— π‘€π‘Ž β„Žπ‘– =10,000βˆ—0.12secβˆ—5.14 βˆ’4 $ΰ΅— =$𝟎.πŸ”πŸ

Cloud-hosted pipelines for Linux, Windows and

macOS, with unlimited minutes for open source

Any language, any platform, any cloud

Build, test, and deploy Node.js, Python, Java, PHP, Ruby, C/C++, .NET,

Android, and iOS apps. Run in parallel on Linux, macOS, and Windows.

Deploy to Azure, AWS, GCP or on-premises

Flexible Workflows & Extensible

Explore and implement community-built build, test, and deployment tasks,

along with hundreds of extensions from Slack to SonarCloud. Support for

YAML, test integration, release gates, reporting, and more.

Best-in-class for open source

Ensure fast continuous integration/continuous delivery (CI/CD) pipelines for

every open source project. Get unlimited build minutes for all open source

projects with up to 10 free parallel jobs across Linux, macOS and Windows

Containers and Kubernetes

Easily build and push images to container registries like Docker Hub and

Azure Container Registry. Deploy containers to individual hosts or

Kubernetes.

Page 33: From code commit to shipping it - University of WashingtonΒ Β· 2019. 3. 16.Β Β· Saving 50% of tests! = π‘Ž βˆ— 𝑖 π‘Ž βˆ— π‘€π‘Ž β„Žπ‘– =10,000βˆ—0.12secβˆ—5.14 βˆ’4 $ΰ΅— =$𝟎.πŸ”πŸ

Deployment Stages / Rings

β€œGold”-Ring

Page 34: From code commit to shipping it - University of WashingtonΒ Β· 2019. 3. 16.Β Β· Saving 50% of tests! = π‘Ž βˆ— 𝑖 π‘Ž βˆ— π‘€π‘Ž β„Žπ‘– =10,000βˆ—0.12secβˆ—5.14 βˆ’4 $ΰ΅— =$𝟎.πŸ”πŸ

Shipped!Let’s do it again … and again …

34

Page 35: From code commit to shipping it - University of WashingtonΒ Β· 2019. 3. 16.Β Β· Saving 50% of tests! = π‘Ž βˆ— 𝑖 π‘Ž βˆ— π‘€π‘Ž β„Žπ‘– =10,000βˆ—0.12secβˆ—5.14 βˆ’4 $ΰ΅— =$𝟎.πŸ”πŸ

35

Example Unit Tests:

Test Selection & Code Coverage

Page 36: From code commit to shipping it - University of WashingtonΒ Β· 2019. 3. 16.Β Β· Saving 50% of tests! = π‘Ž βˆ— 𝑖 π‘Ž βˆ— π‘€π‘Ž β„Žπ‘– =10,000βˆ—0.12secβˆ—5.14 βˆ’4 $ΰ΅— =$𝟎.πŸ”πŸ

Example

Test selection based on code coverage

Your tool

CODE

COVERAGE

RUNTIME

REDUCTION

36

Slows down test execution by 30%

Saving 50% of tests!

?

Page 37: From code commit to shipping it - University of WashingtonΒ Β· 2019. 3. 16.Β Β· Saving 50% of tests! = π‘Ž βˆ— 𝑖 π‘Ž βˆ— π‘€π‘Ž β„Žπ‘– =10,000βˆ—0.12secβˆ—5.14 βˆ’4 $ΰ΅— =$𝟎.πŸ”πŸ

πΆπ‘œπ‘ π‘‘π‘‡π‘’π‘ π‘‘ = π‘‡π‘’π‘ π‘‘πΆπ‘Žπ‘ π‘’π‘  βˆ— π‘…π‘’π‘›π‘‘π‘–π‘šπ‘’π‘‡π‘’π‘ π‘‘π‘π‘Žπ‘ π‘’ βˆ— πΆπ‘œπ‘ π‘‘π‘€π‘Žπ‘β„Žπ‘–π‘›π‘’

= 10,000 βˆ— 0.12 sec βˆ— 5.14π‘’βˆ’4 ΰ΅—$ 𝑠𝑒𝑐 = $𝟎. πŸ”πŸ

This excludes human effort!

~2500 builds per day

Azure machine: $1.85/hr

Assumption: you achieve 50% test reduction

per dayYou saved: $0.62 βˆ— 2500 βˆ— 0.5 = $722

per build

37

Page 38: From code commit to shipping it - University of WashingtonΒ Β· 2019. 3. 16.Β Β· Saving 50% of tests! = π‘Ž βˆ— 𝑖 π‘Ž βˆ— π‘€π‘Ž β„Žπ‘– =10,000βˆ—0.12secβˆ—5.14 βˆ’4 $ΰ΅— =$𝟎.πŸ”πŸ

per build

πΆπ‘œπ‘ π‘‘πΆπ‘œπ‘‘π‘’πΆπ‘œπ‘£π‘’π‘Ÿπ‘Žπ‘”π‘’ = πΆπ‘œπ‘ π‘‘π‘‡π‘’π‘ π‘‘π‘–π‘›π‘” βˆ— π‘…π‘’π‘›π‘‘π‘–π‘šπ‘’π‘‚π‘£π‘’π‘Ÿβ„Žπ‘’π‘Žπ‘‘ + 𝐢𝐢𝑆𝑖𝑧𝑒 βˆ— πΆπ‘œπ‘ π‘‘π·π‘–π‘ π‘˜

+ 𝐢𝐢𝑆𝑖𝑧𝑒 βˆ— 𝑆𝑝𝑒𝑒𝑑𝐼/𝑂 βˆ— πΆπ‘œπ‘ π‘‘π‘€π‘Žπ‘β„Žπ‘–π‘›π‘’

But …

You used code coverage, right?

= $0.62 βˆ— 0.3 + 3.3𝐺𝐡 βˆ— 0.35 ΰ΅—$ 𝐺𝐡

+ 2 ΀𝑠𝑒𝑐𝐺𝐡 βˆ— 3.3𝐺𝐡 βˆ— 5.14π‘’βˆ’4 Ξ€$ 𝑠𝑒𝑐= $1.34

SSD speed 500MB/sec

Azure machine: $1.853/hr

You spend: $1.34 βˆ— 2500 = $3,350 per day

38

Page 39: From code commit to shipping it - University of WashingtonΒ Β· 2019. 3. 16.Β Β· Saving 50% of tests! = π‘Ž βˆ— 𝑖 π‘Ž βˆ— π‘€π‘Ž β„Žπ‘– =10,000βˆ—0.12secβˆ—5.14 βˆ’4 $ΰ΅— =$𝟎.πŸ”πŸ

$3,350 $722Slows down test execution by 30%

Saving 50% of tests!

And this excludes many aspects: analysis time, network cost, service maintenance, etc.

It might still be worth the effortBut it’s as good as you might think, and we have more pressing issues.

39

Page 40: From code commit to shipping it - University of WashingtonΒ Β· 2019. 3. 16.Β Β· Saving 50% of tests! = π‘Ž βˆ— 𝑖 π‘Ž βˆ— π‘€π‘Ž β„Žπ‘– =10,000βˆ—0.12secβˆ—5.14 βˆ’4 $ΰ΅— =$𝟎.πŸ”πŸ

Β©2019 Microsoft Corporation. All rights reserved.


Recommended