Software
Craftsmanship for
DevOps
Professionals
Software Craftsmen just
care about beautiful code
Manifesto for Agile Software Development
https://agilemanifesto.org/
Manifesto of Software Craftsmen
http://manifesto.softwarecraftsmanship.org/
What is Software Craftsmanship?
Software Craftsmanship is all about putting
responsibility, professionalism, pragmatism and
pride back into software development
DevOps Pipeline
What DevOps pipeline consists of
Current role of an DevOps engineer
- Building CI/CD pipelines for multiple technology stack
- Containerising applications/services with Docker
- Automation of provisioning environments in cloud/on-prem with code
- Automation of Configuration management of environments and application
with code
- Writing deployment scripts for container orchestration with Kubernetes
- Enable monitoring and alerting
DevOps engineers role is evolving
Treat everything as code
No more UI
DevOps
engineers
are writing
code
DevOps
engineers
are writing
long code
DevOps
engineers
are writing
long bad
code
Pipeline code become Dirty
- Unreadable
- Hard to test
- Difficult to maintain
- Takes lot of time to add new functionality
Any fool can write code that a computer can
understand. Good programmers write code
that humans can understand.
- Martin Fowler
Good Code
- Clean Code principles
- Refactoring legacy code
- Code Review and pull request
- Unit Testing of Pipeline
- Integration testing of Pipeline
- Automated testing of Infrastructure as code scripts
- Continuous Integration of DevOps pipeline scripts
- Continuous Delivery of DevOps pipeline scripts
Refactoring legacy code
When we refactor, we should have tests. To put tests in place, we often have to
refactor
- Identify Change Points
- Identify Test Points
- Break Dependencies
- Write Tests
- Refactor or Change
Code Review and pull request
- Why don't we put gates for DevOps engineers code
- Code review practices
- Sonarqube Code Analysis
- Git Hooks
- pre-commit: Check the commit message for spelling errors.
- pre-receive: Enforce project coding standards.
- post-commit: Email/SMS team members of a new commit.
- post-receive: Push the code to production.
Unit Testing of Pipeline Code
- Unit test for Jenkinsfile
- Unit test for shared library
- Unit testing increase confidence of code changing/ managing pipeline code.
- Non-Regression test
- Call Stack print for pipeline code.
Github: https://github.com/mrumeshkumar/pipelinecode-unittest-shared-
library.git
Pipeline Code Unit Testing Framework
1. Com.homeaway.devtools.jenkins with Spock
2. Jenkins-pipeline-unit with junit and Spock
Take away -
Go Fast by adopting Software Craftsmanship
● DevOps engineers mindset should change to Developer mindset
● Follow Boy scout rule
● Software Craftsmanship is a long journey to mastery
● Follow Clean Code principles
● Continuous Refactoring of legacy code
● Code Review and pull request
● Unit Testing of Pipeline
● Integration testing of Pipeline
● Automated testing of Infrastructure as code scripts
● CI/CD of DevOps pipeline scripts
Reference Books

Software Craftsmanship for DevOps professionals - Umesh Kumar / Murughan Palaniachari

  • 1.
  • 2.
    Manifesto for AgileSoftware Development https://agilemanifesto.org/
  • 3.
    Manifesto of SoftwareCraftsmen http://manifesto.softwarecraftsmanship.org/
  • 4.
    What is SoftwareCraftsmanship? Software Craftsmanship is all about putting responsibility, professionalism, pragmatism and pride back into software development
  • 5.
  • 6.
  • 7.
    Current role ofan DevOps engineer - Building CI/CD pipelines for multiple technology stack - Containerising applications/services with Docker - Automation of provisioning environments in cloud/on-prem with code - Automation of Configuration management of environments and application with code - Writing deployment scripts for container orchestration with Kubernetes - Enable monitoring and alerting
  • 8.
    DevOps engineers roleis evolving Treat everything as code No more UI
  • 9.
  • 10.
  • 11.
  • 13.
    Pipeline code becomeDirty - Unreadable - Hard to test - Difficult to maintain - Takes lot of time to add new functionality
  • 14.
    Any fool canwrite code that a computer can understand. Good programmers write code that humans can understand. - Martin Fowler
  • 16.
    Good Code - CleanCode principles - Refactoring legacy code - Code Review and pull request - Unit Testing of Pipeline - Integration testing of Pipeline - Automated testing of Infrastructure as code scripts - Continuous Integration of DevOps pipeline scripts - Continuous Delivery of DevOps pipeline scripts
  • 20.
    Refactoring legacy code Whenwe refactor, we should have tests. To put tests in place, we often have to refactor - Identify Change Points - Identify Test Points - Break Dependencies - Write Tests - Refactor or Change
  • 22.
    Code Review andpull request - Why don't we put gates for DevOps engineers code - Code review practices - Sonarqube Code Analysis - Git Hooks - pre-commit: Check the commit message for spelling errors. - pre-receive: Enforce project coding standards. - post-commit: Email/SMS team members of a new commit. - post-receive: Push the code to production.
  • 23.
    Unit Testing ofPipeline Code - Unit test for Jenkinsfile - Unit test for shared library - Unit testing increase confidence of code changing/ managing pipeline code. - Non-Regression test - Call Stack print for pipeline code. Github: https://github.com/mrumeshkumar/pipelinecode-unittest-shared- library.git
  • 24.
    Pipeline Code UnitTesting Framework 1. Com.homeaway.devtools.jenkins with Spock 2. Jenkins-pipeline-unit with junit and Spock
  • 34.
    Take away - GoFast by adopting Software Craftsmanship ● DevOps engineers mindset should change to Developer mindset ● Follow Boy scout rule ● Software Craftsmanship is a long journey to mastery ● Follow Clean Code principles ● Continuous Refactoring of legacy code ● Code Review and pull request ● Unit Testing of Pipeline ● Integration testing of Pipeline ● Automated testing of Infrastructure as code scripts ● CI/CD of DevOps pipeline scripts
  • 35.

Editor's Notes

  • #18 Functions Smal! Do One Thing One Level of Abstraction per Function Dont use Switch Statement Use Descriptive Names Reduce Function Arguments Use verbs Don’t Repeat Yourself (DRY) The Boy Scout Rule
  • #19 gdfgijdfg
  • #20 gdfgijdfg
  • #23 What are Git hooks? Git hooks are scripts that Git executes before or after events such as: commit, push, and receive. Git hooks are a built-in feature - no need to download anything. Git hooks are run locally. These hook scripts are only limited by a developer's imagination. Some example hook scripts include: