Git Product home page Git Product logo

intro-to-ci-cd's Introduction

๐Ÿ‘‹ Hello, there!

I'm Steve, and I love building tools to help people build better software.

By day, I'm a Staff Software Engineer at Mailchimp, improving the way we handle audience information and our general involvement in the PHP ecosystem.

PHP is my bread-and-butter, and I love building out SaaS and other products using Laravel. I'm also a WordPress plugin author and core contributor, but my real passion is building code quality tools; it shouldn't come as any surprise that I've spent a lot of time working with CI/CD pipelines and all of the tooling that gets run as part of them.

I'm also a regular conference speaker (or at least was, pre-pandemic), so you may have met me at any number of PHP, WordPress, or other software-related events.

You can learn more about me over at stevegrunwell.com, follow me on Mastodon, or connect with me on LinkedIn.

intro-to-ci-cd's People

Contributors

stevegrunwell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

intro-to-ci-cd's Issues

List of my real life conclusions

My notes are not so fancy but all items come from a real life incident.

These are the zero-coverage tests I force on my clients: syntax check + coding style + static analysis. (they develop their code, I run it)

Here is the note:


Continuous integration and Continuous delivery

How to design and implement CI and CD.

CI

  • Run in a premade container or install packages
  • Display environment information
  • Set access credentials
  • Cache OS and programming language library packages
  • Check package management configuration (validate & normalize)
  • Check outdated packages and known security vulnerabilities
  • Build code
  • Configure application
  • Lint source code
  • Lint template files
  • Check coding style
  • Do static analysis
  • Run tests
  • Check route methods
  • Custom checks and warnings
  • Measure code coverage
  • Start CD by SSH-ing to own server (restrict,command in authorized_keys and DenyUsers in sshd.conf)
  • Wipe sensitive data

CD

  • Possible constrains:
    • successful tests
    • do not run on PR-s
    • our repo
    • specific branch
    • tag in commit message [deploy:prod]
    • deploy head commit only
    • optional manual start (GitLab manual actions)
  • Do not run as root user
  • Keep deploy configuration in a file
  • Log every output to a file, log start and finish to syslog
  • Limit execution time of time-consuming steps (timeout)
  • Optionally back up project files before starting to deploy
  • Create a bot user on the server for git access with SSH key (@CompanyBot)
  • List changes in current project files
  • Check for maintenance mode test -f storage/framework/down , Turn on maintenance mode covering static resource, page, AJAX and API requests
  • Clear caches (configuration, routes, application, template etc.)
  • Disable cron jobs and background workers after clearing caches (email piped to a program)
  • Identify git repository and branch
  • Checkout by commit hash (not by branch HEAD)
  • At least lint the source code
  • Don't deploy testing packages
  • Enable production optimizations in package manager
  • Build code
  • Run database migrations
  • Turn off maintenance mode
  • Populate caches (application, OPcache, wp rewrite flush)
  • Run at least 1 basic functional or unit test (e.g. log in or display dashboard)
  • Check HTML output
  • Special sudo configuration for reloading PHP-FPM or Cachetool
  • Alert on failure
  • "Was down for X seconds"
  • Send email, Slack, Trello or Google Hangouts notification

Coding style / Coding standard

  • Tool: phive install phpcs # squizlabs/php_codesniffer
  • Tool: dealerdirect/phpcodesniffer-composer-installer
  • commenting rules
  • wp-coding-standards/wpcs
  • automattic/phpcs-neutron-standard # automattic/phpcs-neutron-ruleset
  • slevomat/coding-standard
  • object-calisthenics/phpcs-calisthenics-rules
  • consistence/coding-standard

Static analysis

  • Tool: phpstan/phpstan # phpstan/phpstan-shim # phive install phpstan
  • phpstan/phpstan-deprecation-rules
  • phpstan/phpstan-strict-rules
  • szepeviktor/phpstan-wordpress

( live version: https://github.com/szepeviktor/debian-server-tools/blob/master/webserver/Continuous-integration-Continuous-delivery.md )

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.