Transcript
Page 1: Sustainable Software Development in an Academic Setting€¦ · 2 Hartwig Anzt: Sustainable Software Development in an Academic Setting 10/01/2019 What we cover today • Versioning

KIT – The Research University in the Helmholtz Association

Hartwig Anzt, Terry Cojean, Thomas Grűtzmacher, Pratik Nayak, Mike TsaiSteinbuch Centre for Computing (SCC)

www.kit.edu

SustainableSoftwareDevelopmentinanAcademicSetting4thInternationalSymposium onResearchandEducationofComputational Science(RECS)University ofTokyo,October1st,2019

Theseslidesareavailableunder:https://hartwiganzt.github.io/slides/SustainableSoftwareDevelopment.pdf

Page 2: Sustainable Software Development in an Academic Setting€¦ · 2 Hartwig Anzt: Sustainable Software Development in an Academic Setting 10/01/2019 What we cover today • Versioning

2 10/01/2019Hartwig Anzt:SustainableSoftwareDevelopmentinanAcademicSetting

What we cover today

• Versioningsystems

• Git workflow

• Git hostingsites

• Continuous Integration(CI)

• GitLab runners

• AutomatedTesting

• UnitTestingwithGoogletest

• SoftwareDocumentationwithDoxygen

Tointeractivelyparticipate inthiscourse,youneedaGitLab account.

• Pleasecreateanaccount(chooseyournamecarefully!)• Pleaselogin• https://gitlab.com/

PratikNayakTerryCojean ThomasGrützmacher

TobiasRibizel

Interactivewebinarwiththehelpof

Forcompleteinteractiveparticipation(onLinuxSystems):

apt-get install git cmake g++ gcovr

MikeTsai

Page 3: Sustainable Software Development in an Academic Setting€¦ · 2 Hartwig Anzt: Sustainable Software Development in an Academic Setting 10/01/2019 What we cover today • Versioning

3 10/01/2019Hartwig Anzt:SustainableSoftwareDevelopmentinanAcademicSetting

What is a version control system?

Versioncontrolsystemfortrackingchangesincomputerfiles.

Page 4: Sustainable Software Development in an Academic Setting€¦ · 2 Hartwig Anzt: Sustainable Software Development in an Academic Setting 10/01/2019 What we cover today • Versioning

4 10/01/2019Hartwig Anzt:SustainableSoftwareDevelopmentinanAcademicSetting

What is a version control system?

• Distributedversioncontrol

• Coordinatesworkbetweenmultipledevelopers

• Whomadewhatchangesandwhen

• Revertbackatanytime

• Localandremoterepos

Versioncontrolsystemfortrackingchangesincomputerfiles.

ü Keepstrackofcodehistory

ü Takes“snapshots”ofyourfiles

ü Youdecidewhentotakeasnapshot bymakinga”commit”

ü Youcanvisitanysnapshotatanytime

Page 5: Sustainable Software Development in an Academic Setting€¦ · 2 Hartwig Anzt: Sustainable Software Development in an Academic Setting 10/01/2019 What we cover today • Versioning

5 10/01/2019Hartwig Anzt:SustainableSoftwareDevelopmentinanAcademicSetting

Git Versioning System

Ø git init //Initializelocalgit repository

Ø git add*files //Addfile(s)tosnapshot

Ø git status //Checkchangesnotyetinthesnapshot

Ø git commit*files //Takesnapshot (commitchanges)Ø git commit–m‘putacommentonthiscommit’*files

Git CheatSheet:https://www.git-tower.com/blog/git-cheat-sheet/

Page 6: Sustainable Software Development in an Academic Setting€¦ · 2 Hartwig Anzt: Sustainable Software Development in an Academic Setting 10/01/2019 What we cover today • Versioning

6 10/01/2019Hartwig Anzt:SustainableSoftwareDevelopmentinanAcademicSetting

Git Versioning System

Ø git init //Initializelocalgit repository

Ø git add*files //Addfile(s)tosnapshot

Ø git status //Checkchangesnotyetinthesnapshot

Ø git commit*files //Takesnapshot (commitchanges)Ø git commit–m‘putacommentonthiscommit’*files

LocalRepository

Git CheatSheet:https://www.git-tower.com/blog/git-cheat-sheet/

Page 7: Sustainable Software Development in an Academic Setting€¦ · 2 Hartwig Anzt: Sustainable Software Development in an Academic Setting 10/01/2019 What we cover today • Versioning

7 10/01/2019Hartwig Anzt:SustainableSoftwareDevelopmentinanAcademicSetting

Git Versioning System

Ø git init //Initializelocalgit repository

Ø git add*files //Addfile(s)tosnapshot

Ø git status //Checkchangesnotyetinthesnapshot

Ø git commit*files //Takesnapshot (commitchanges)Ø git commit–m‘putacommentonthiscommit’*files

Ø git push //Pushlocalsnapshotstoremoterepo

Ø git pull //Getlatestsnapshot fromremoterepo

Ø git clone*path/to/repo //CloneanexistingremoterepositoryRemoteRepository

LocalRepository

Git CheatSheet:https://www.git-tower.com/blog/git-cheat-sheet/

Page 8: Sustainable Software Development in an Academic Setting€¦ · 2 Hartwig Anzt: Sustainable Software Development in an Academic Setting 10/01/2019 What we cover today • Versioning

8 10/01/2019Hartwig Anzt:SustainableSoftwareDevelopmentinanAcademicSetting

Git Hosting Sites

• GitHub

• GitLab

• Bitbucket

• … https://en.wikipedia.org/wiki/Comparison_of_source-code-hosting_facilities

WemayjustchooseGitLab forthiscourse• Pleasecreateanaccount(chooseyournamecarefully!)• Pleaselogin• https://gitlab.com/

Theyoffertheenvironmentfortheremoterepository.

Page 9: Sustainable Software Development in an Academic Setting€¦ · 2 Hartwig Anzt: Sustainable Software Development in an Academic Setting 10/01/2019 What we cover today • Versioning

9 10/01/2019Hartwig Anzt:SustainableSoftwareDevelopmentinanAcademicSetting

Git Hands-On

1. WecreateanAccountatGitLab andlogin.

2. IcreateaprojectonGitLab (\[email protected]:hanzt/recs)

3. Iaddafirstsourcefileandmakeitapublicrepository

4. Youallcloneortheproject:

git clone [email protected]:hanzt/recs

5. Youaddyournametothelocalversionofcontributors.txt

6. Youcheckyourchanges:

git diff

7. Youcommityour localchanges:

git commit –m ‘add my name’ contributors.txt

8. Youpushyourlocalchangestotheremoterepository:

git push origin master

9. Youfix”mergeconflicts”….

Page 10: Sustainable Software Development in an Academic Setting€¦ · 2 Hartwig Anzt: Sustainable Software Development in an Academic Setting 10/01/2019 What we cover today • Versioning

10 10/01/2019Hartwig Anzt:SustainableSoftwareDevelopmentinanAcademicSetting

Continuous Integration (CI)

clone

• Howdoyoufindoutthecodeisbroken?• Howdowefindoutwhowhichcode

integration introducedthebug?• Howcanwemakesureeverythingworks

atanypointintime?

Sometimes,someoneintroducesabugthatbreaksthecode…

Page 11: Sustainable Software Development in an Academic Setting€¦ · 2 Hartwig Anzt: Sustainable Software Development in an Academic Setting 10/01/2019 What we cover today • Versioning

11 10/01/2019Hartwig Anzt:SustainableSoftwareDevelopmentinanAcademicSetting

Continuous Integration (CI)

Weneedamechanismthatconstantlychecksthefunctionalityofthemaster“branch”.

clone

ContinuousIntegration

• Howdoyoufindoutthecodeisbroken?• Howdowefindoutwhowhichcode

integration introducedthebug?• Howcanwemakesureeverythingworks

atanypointintime?

Sometimes,someoneintroducesabugthatbreaksthecode…

• Setsupapre-definedenvironment;

• Clonestheremoterepositoryonaserver;

• Triestocompileandrunallpre-definedtests;

• Reportstheoutcome;

Page 12: Sustainable Software Development in an Academic Setting€¦ · 2 Hartwig Anzt: Sustainable Software Development in an Academic Setting 10/01/2019 What we cover today • Versioning

12 10/01/2019Hartwig Anzt:SustainableSoftwareDevelopmentinanAcademicSetting

Continuous Integration on GitLab

• GitLab supportsGitLab runnersasCIfeature.

• Theycanbeconfiguredviaaddingthefile.gitlab-ci.yml

https://docs.gitlab.com/ee/ci/yaml/

• GitLab runneraresetupviawebinterface.

example.gitlab-ci.yml

LoadimageofOS

UpdateOS

Installpackagesneeded:git cmake g++gcovr

Createdirectory

CallCMake

Buildlibrarygcov checksunittestcoverage

Page 13: Sustainable Software Development in an Academic Setting€¦ · 2 Hartwig Anzt: Sustainable Software Development in an Academic Setting 10/01/2019 What we cover today • Versioning

13 10/01/2019Hartwig Anzt:SustainableSoftwareDevelopmentinanAcademicSetting

Software TestingAutomatedtesting:Thepracticeofwritingcodetotestthecode,andthenrunthosetestsinanautomatedfashion.

ProductionCode TestCode

Page 14: Sustainable Software Development in an Academic Setting€¦ · 2 Hartwig Anzt: Sustainable Software Development in an Academic Setting 10/01/2019 What we cover today • Versioning

14 10/01/2019Hartwig Anzt:SustainableSoftwareDevelopmentinanAcademicSetting

Integrationtests:Checktheapplicationsfunctionalitywithitsexternaldependencies.

• Givemoreconfidenceincomplexapplication.• Testsunits/classesaswhole.

End-to-Endtests:Checktheapplicationsfunctionalitywithitsexternaldependenciesanduserinput.

• Testcompleteworkflowandapplicationinteraction.• Veryslowandbrittle.

Software TestingAutomatedtesting:Thepracticeofwritingcodetotestthecode,andthenrunthosetestsinanautomatedfashion.

ProductionCode TestCode

Unittests:Checkthefunctionalityandvalidityofeachbuildingblockwithout itsexternaldependencies.

• Trackdownbugs

Many.Easy-to-write.ExecuteFast.

Page 15: Sustainable Software Development in an Academic Setting€¦ · 2 Hartwig Anzt: Sustainable Software Development in an Academic Setting 10/01/2019 What we cover today • Versioning

15 10/01/2019Hartwig Anzt:SustainableSoftwareDevelopmentinanAcademicSetting

Integrationtests:Checktheapplicationsfunctionalitywithitsexternaldependencies.

• Givemoreconfidenceincomplexapplication.• Testsunits/classesaswhole.

End-to-Endtests:Checktheapplicationsfunctionalitywithitsexternaldependenciesanduserinput.

• Testcompleteworkflowandapplicationinteraction.• Veryslowandbrittle.

Software TestingAutomatedtesting:Thepracticeofwritingcodetotestthecode,andthenrunthosetestsinanautomatedfashion.

ProductionCode TestCode

Unittests:Checkthefunctionalityandvalidityofeachbuildingblockwithout itsexternaldependencies.

• Trackdownbugs

Many.Easy-to-write.ExecuteFast.

Fewer.Dependencies.

Page 16: Sustainable Software Development in an Academic Setting€¦ · 2 Hartwig Anzt: Sustainable Software Development in an Academic Setting 10/01/2019 What we cover today • Versioning

16 10/01/2019Hartwig Anzt:SustainableSoftwareDevelopmentinanAcademicSetting

Integrationtests:Checktheapplicationsfunctionalitywithitsexternaldependencies.

• Givemoreconfidenceincomplexapplication.• Testsunits/classesaswhole.

End-to-Endtests:Checktheapplicationsfunctionalitywithitsexternaldependenciesanduserinput.

• Testcompleteworkflowandapplicationinteraction.• Veryslowandbrittle.

Software TestingAutomatedtesting:Thepracticeofwritingcodetotestthecode,andthenrunthosetestsinanautomatedfashion.

ProductionCode TestCode

Unittests:Checkthefunctionalityandvalidityofeachbuildingblockwithout itsexternaldependencies.

• Trackdownbugs

Many.Easy-to-write.ExecuteFast.

Few.Complex.

Fewer.Dependencies.

Page 17: Sustainable Software Development in an Academic Setting€¦ · 2 Hartwig Anzt: Sustainable Software Development in an Academic Setting 10/01/2019 What we cover today • Versioning

17 10/01/2019Hartwig Anzt:SustainableSoftwareDevelopmentinanAcademicSetting

Unit tests with Googletest

• Frameworktofacilitateunittesting.

• https://github.com/google/googletest

Let’sdoanexample.

Muchofthismaterialistakenfrom NikolaosPothitoshttp://cgi.di.uoa.gr/~pothitos/https://github.com/pothitos/gtest-demo-gitlab

Page 18: Sustainable Software Development in an Academic Setting€¦ · 2 Hartwig Anzt: Sustainable Software Development in an Academic Setting 10/01/2019 What we cover today • Versioning

18 10/01/2019Hartwig Anzt:SustainableSoftwareDevelopmentinanAcademicSetting

Software Documentation

• Automatedcodedocumentationtool.

• Convertscommentsinsourcecodeintodocumentation.

• HTML-oriented.

• http://www.doxygen.nl/

• https://github.com/doxygen/doxygen.git

Doxygen is the de facto standard tool for generatingdocumentation from annotated C++ sources, but it alsosupports other popular programming languages such as C,Objective-C, C#, PHP, Java, Python, IDL (Corba, Microsoft, andUNO/OpenOffice flavors), Fortran, VHDL, Tcl, and to someextent D.

Example:https://www.dealii.org/current/doxygen/deal.II/classTorusManifold.html

Page 19: Sustainable Software Development in an Academic Setting€¦ · 2 Hartwig Anzt: Sustainable Software Development in an Academic Setting 10/01/2019 What we cover today • Versioning

19 10/01/2019Hartwig Anzt:SustainableSoftwareDevelopmentinanAcademicSetting

References & Further Reading

https://bssw.io/

• https://www.git-tower.com/blog/git-cheat-sheet/• https://github.com/google/googletest• https://github.com/pothitos/gtest-demo-gitlab• https://docs.gitlab.com/ee/ci/yaml/• http://www.doxygen.nl/

Theseslidesareavailableunder:https://hartwiganzt.github.io/slides/SustainableSoftwareDevelopment.pdf


Recommended