CI/CD Con Gitlab

CI/CD Con Gitlab

0f9c9bbecc4067b9bce445cb11ed5d53?s=128

David Padilla

June 22, 2017
Tweet

Transcript

  1. CI/CD con Gitlab David Padilla @dabit

  2. David Padilla @dabit

  3. @micheladaio

  4. CI/CD con Gitlab

  5. CI/CD

  6. Integración Continua CI

  7. Entrega Continua CD

  8. Despliegue Continuo CD

  9. Pruebas Automatizadas

  10. Test Driven Development

  11. Nuestro proceso

  12. Desarrollo Merge Request Peer Review Review QA Staging Más QA

    UAT Producción
  13. Desarrollo Merge Request Peer Review Review QA Staging Más QA

    UAT Producción
  14. None
  15. Control de versiones (git) Merge Requests / Retroalimentación Orquesta deploys

    Corre pruebas Registry de Docker
  16. None
  17. require 'application_system_test_case' class HomepagesTest < ApplicationSystemTestCase test 'homepage' do visit

    root_path assert_content 'SGNext' end end
  18. require 'application_system_test_case' class HomepagesTest < ApplicationSystemTestCase test 'homepage' do visit

    root_path assert_content 'SGNext' end end
  19. require 'application_system_test_case' class HomepagesTest < ApplicationSystemTestCase test 'homepage' do visit

    root_path assert_content 'SGNext' end end
  20. None
  21. None
  22. Como Usuario cuando voy a la pagina principal quiero ver

    el slogan "La mejor conferencia de México"
  23. require 'application_system_test_case' class HomepagesTest < ApplicationSystemTestCase test 'homepage' do visit

    root_path assert_content 'SGNext' end end
  24. require 'application_system_test_case' class HomepagesTest < ApplicationSystemTestCase test 'homepage' do visit

    root_path assert_content 'SGNext' assert_content 'La mejor conferencia de Mexico' end end
  25. None
  26. None
  27. <div class="row align-items-center"> <div class="col-md-12"> <div class="jumbotron"> <h1 class="display-3">SGNext</h1> <p

    class="lead"> La mejor conferencia de Mexico </p> </div> </div> </div>
  28. <div class="row align-items-center"> <div class="col-md-12"> <div class="jumbotron"> <h1 class="display-3">SGNext</h1> <p

    class="lead"> La mejor conferencia de Mexico </p> </div> </div> </div>
  29. <div class="row align-items-center"> <div class="col-md-12"> <div class="jumbotron"> <h1 class="display-3">SGNext</h1> <p

    class="lead"> La mejor conferencia de Mexico </p> </div> </div> </div>
  30. None
  31. None
  32. $ git checkout -b slogan $ git add . $

    git commit -m "Nuevo slogan" [slogan d287522] Nuevo slogan 2 files changed, 2 insertions(+)
  33. None
  34. None
  35. None
  36. None
  37. None
  38. None
  39. None
  40. None
  41. None
  42. None
  43. None
  44. require 'application_system_test_case' class HomepagesTest < ApplicationSystemTestCase test 'homepage' do visit

    root_path assert_content 'SGNext' assert_content 'La mejor conferencia de México' end end
  45. <div class="row align-items-center"> <div class="col-md-12"> <div class="jumbotron"> <h1 class="display-3">SGNext</h1> <p

    class="lead"> La mejor conferencia de México </p> </div> </div> </div>
  46. None
  47. None
  48. None
  49. None
  50. None
  51. None
  52. None
  53. None
  54. None
  55. None
  56. None
  57. None
  58. None
  59. FROM ruby:2.4.1 ENV PHANTOM_JS="phantomjs-2.1.1-linux-x86_64" RUN apt-get update RUN apt-get install

    -y software-properties-common apt-transport-https RUN add-apt-repository "deb https://cli-assets.heroku.com/branches/stable/apt ./" RUN curl -L https://cli-assets.heroku.com/apt/release.key | apt-key add - RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list RUN curl -sL https://deb.nodesource.com/setup_6.x | bash - RUN apt-get update && \ apt-get upgrade -y RUN apt-get install -y build-essential chrpath libssl-dev libxft-dev \ libfreetype6 libfreetype6-dev libfontconfig1 libfontconfig1-dev qt5-default \ libqt5webkit5-dev gstreamer1.0-plugins-base gstreamer1.0-tools \ gstreamer1.0-x imagemagick cmake yarn nodejs RUN apt-get install heroku RUN gem install dpl RUN curl -L -O https://bitbucket.org/ariya/phantomjs/downloads/$PHANTOM_JS.tar.bz2 RUN tar xvjf $PHANTOM_JS.tar.bz2 && \ mv $PHANTOM_JS /usr/local/share && \ ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/local/bin
  60. FROM ruby:2.4.1 ENV PHANTOM_JS="phantomjs-2.1.1-linux-x86_64" RUN apt-get update RUN apt-get install

    -y software-properties-common apt-transport-https RUN add-apt-repository "deb https://cli-assets.heroku.com/branches/stable/apt ./" RUN curl -L https://cli-assets.heroku.com/apt/release.key | apt-key add - RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list RUN curl -sL https://deb.nodesource.com/setup_6.x | bash - RUN apt-get update && \ apt-get upgrade -y RUN apt-get install -y build-essential chrpath libssl-dev libxft-dev \ libfreetype6 libfreetype6-dev libfontconfig1 libfontconfig1-dev qt5-default \ libqt5webkit5-dev gstreamer1.0-plugins-base gstreamer1.0-tools \ gstreamer1.0-x imagemagick cmake yarn nodejs RUN apt-get install heroku RUN gem install dpl RUN curl -L -O https://bitbucket.org/ariya/phantomjs/downloads/$PHANTOM_JS.tar.bz2 RUN tar xvjf $PHANTOM_JS.tar.bz2 && \ mv $PHANTOM_JS /usr/local/share && \ ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/local/bin
  61. FROM ruby:2.4.1 ENV PHANTOM_JS="phantomjs-2.1.1-linux-x86_64" RUN apt-get update RUN apt-get install

    -y software-properties-common apt-transport-https RUN add-apt-repository "deb https://cli-assets.heroku.com/branches/stable/apt ./" RUN curl -L https://cli-assets.heroku.com/apt/release.key | apt-key add - RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list RUN curl -sL https://deb.nodesource.com/setup_6.x | bash - RUN apt-get update && \ apt-get upgrade -y RUN apt-get install -y build-essential chrpath libssl-dev libxft-dev \ libfreetype6 libfreetype6-dev libfontconfig1 libfontconfig1-dev qt5-default \ libqt5webkit5-dev gstreamer1.0-plugins-base gstreamer1.0-tools \ gstreamer1.0-x imagemagick cmake yarn nodejs RUN apt-get install heroku RUN gem install dpl RUN curl -L -O https://bitbucket.org/ariya/phantomjs/downloads/$PHANTOM_JS.tar.bz2 RUN tar xvjf $PHANTOM_JS.tar.bz2 && \ mv $PHANTOM_JS /usr/local/share && \ ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/local/bin
  62. FROM ruby:2.4.1 ENV PHANTOM_JS="phantomjs-2.1.1-linux-x86_64" RUN apt-get update RUN apt-get install

    -y software-properties-common apt-transport-https RUN add-apt-repository "deb https://cli-assets.heroku.com/branches/stable/apt ./" RUN curl -L https://cli-assets.heroku.com/apt/release.key | apt-key add - RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list RUN curl -sL https://deb.nodesource.com/setup_6.x | bash - RUN apt-get update && \ apt-get upgrade -y RUN apt-get install -y build-essential chrpath libssl-dev libxft-dev \ libfreetype6 libfreetype6-dev libfontconfig1 libfontconfig1-dev qt5-default \ libqt5webkit5-dev gstreamer1.0-plugins-base gstreamer1.0-tools \ gstreamer1.0-x imagemagick cmake yarn nodejs RUN apt-get install heroku RUN gem install dpl RUN curl -L -O https://bitbucket.org/ariya/phantomjs/downloads/$PHANTOM_JS.tar.bz2 RUN tar xvjf $PHANTOM_JS.tar.bz2 && \ mv $PHANTOM_JS /usr/local/share && \ ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/local/bin
  63. None
  64. .gitlab-ci.yml

  65. image: registry.michelada.io/demos/sgnext/image services: - postgres stages: - test - review

    - staging - production variables: DISABLE_SPRING: 'true' before_script: - gem install bundler --no-ri --no-rdoc - rm -rf vendor/ruby/2.4.0/cache/bundler/git || true - ruby -v cache: paths: - vendor/ruby - node_modules build: stage: test script: - bundle install -j $(nproc) --path vendor --full-index --clean - bin/yarn - cp config/database.ci.yml config/database.yml - bundle exec rails db:create RAILS_ENV=test - bundle exec rails db:test:prepare RAILS_ENV=test - bundle exec rails test - bundle exec rails test:system deploy_review: stage: review script: - gem install dpl - heroku apps:fork --from $HEROKU_STAGING_APP --to $CI_ENVIRONMENT_SLUG || true - dpl --provider=heroku --app=$CI_ENVIRONMENT_SLUG --api-key=$HEROKU_API_KEY - heroku run rake db:migrate --app=$CI_ENVIRONMENT_SLUG environment: name: review/$CI_BUILD_REF_NAME url: https://$CI_ENVIRONMENT_SLUG.herokuapp.com only: - branches except: - master staging: stage: staging environment: staging script: - gem install dpl - dpl --provider=heroku --app=$HEROKU_STAGING_APP --api-key=$HEROKU_API_KEY - heroku run rake db:migrate --app=$HEROKU_STAGING_APP only: - master production: stage: production environment: production script: - gem install dpl - dpl --provider=heroku --app=$HEROKU_PROD_APP --api-key=$HEROKU_API_KEY - heroku run rake db:migrate --app=$HEROKU_PROD_APP only: - master when: manual
  66. image: registry.michelada.io/demos/sgnext/image services: - postgres stages: - test - review

    - staging - production variables: DISABLE_SPRING: 'true' before_script: - gem install bundler --no-ri --no-rdoc - rm -rf vendor/ruby/2.4.0/cache/bundler/git || true - ruby -v cache: paths: - vendor/ruby - node_modules build: stage: test script:
  67. image: registry.michelada.io/demos/sgnext/image services: - postgres stages: - test - review

    - staging - production variables: DISABLE_SPRING: 'true' before_script: - gem install bundler --no-ri --no-rdoc - rm -rf vendor/ruby/2.4.0/cache/bundler/git || true - ruby -v cache: paths: - vendor/ruby - node_modules build: stage: test script:
  68. image: registry.michelada.io/demos/sgnext/image services: - postgres stages: - test - review

    - staging - production variables: DISABLE_SPRING: 'true' before_script: - gem install bundler --no-ri --no-rdoc - rm -rf vendor/ruby/2.4.0/cache/bundler/git || true - ruby -v cache: paths: - vendor/ruby - node_modules build: stage: test script:
  69. image: registry.michelada.io/demos/sgnext/image services: - postgres stages: - test - review

    - staging - production variables: DISABLE_SPRING: 'true' before_script: - gem install bundler --no-ri --no-rdoc - rm -rf vendor/ruby/2.4.0/cache/bundler/git || true - ruby -v cache: paths: - vendor/ruby - node_modules build: stage: test script:
  70. - gem install bundler --no-ri --no-rdoc - rm -rf vendor/ruby/2.4.0/cache/bundler/git

    || true - ruby -v cache: paths: - vendor/ruby - node_modules build: stage: test script: - bundle install -j $(nproc) --path vendor --full-index --clean - bin/yarn - cp config/database.ci.yml config/database.yml - bundle exec rails db:create RAILS_ENV=test - bundle exec rails db:test:prepare RAILS_ENV=test - bundle exec rails test - bundle exec rails test:system deploy_review: stage: review script: - gem install dpl - heroku apps:fork --from $HEROKU_STAGING_APP --to $CI_ENVIRONMENT_SLUG || true - dpl --provider=heroku --app=$CI_ENVIRONMENT_SLUG --api-key=$HEROKU_API_KEY - heroku run rake db:migrate --app=$CI_ENVIRONMENT_SLUG environment: name: review/$CI_BUILD_REF_NAME url: https://$CI_ENVIRONMENT_SLUG.herokuapp.com
  71. - gem install bundler --no-ri --no-rdoc - rm -rf vendor/ruby/2.4.0/cache/bundler/git

    || true - ruby -v cache: paths: - vendor/ruby - node_modules build: stage: test script: - bundle install -j $(nproc) --path vendor --full-index --clean - bin/yarn - cp config/database.ci.yml config/database.yml - bundle exec rails db:create RAILS_ENV=test - bundle exec rails db:test:prepare RAILS_ENV=test - bundle exec rails test - bundle exec rails test:system deploy_review: stage: review script: - gem install dpl - heroku apps:fork --from $HEROKU_STAGING_APP --to $CI_ENVIRONMENT_SLUG || true - dpl --provider=heroku --app=$CI_ENVIRONMENT_SLUG --api-key=$HEROKU_API_KEY - heroku run rake db:migrate --app=$CI_ENVIRONMENT_SLUG environment: name: review/$CI_BUILD_REF_NAME url: https://$CI_ENVIRONMENT_SLUG.herokuapp.com
  72. staging: stage: staging environment: staging script: - gem install dpl

    - dpl --provider=heroku --app=$HEROKU_STAGING_APP --api-key=$HEROKU_API_KEY - heroku run rake db:migrate --app=$HEROKU_STAGING_APP only: - master production: stage: production environment: production script: - gem install dpl - dpl --provider=heroku --app=$HEROKU_PROD_APP --api-key=$HEROKU_API_KEY - heroku run rake db:migrate --app=$HEROKU_PROD_APP only: - master when: manual rubocop: stage: test script: - bundle install -j $(nproc) --path vendor - bundle exec rubocop
  73. staging: stage: staging environment: staging script: - gem install dpl

    - dpl --provider=heroku --app=$HEROKU_STAGING_APP --api-key=$HEROKU_API_KEY - heroku run rake db:migrate --app=$HEROKU_STAGING_APP only: - master production: stage: production environment: production script: - gem install dpl - dpl --provider=heroku --app=$HEROKU_PROD_APP --api-key=$HEROKU_API_KEY - heroku run rake db:migrate --app=$HEROKU_PROD_APP only: - master when: manual rubocop: stage: test script: - bundle install -j $(nproc) --path vendor - bundle exec rubocop
  74. Agnóstico

  75. - gem install bundler --no-ri --no-rdoc - rm -rf vendor/ruby/2.4.0/cache/bundler/git

    || true - ruby -v cache: paths: - vendor/ruby - node_modules build: stage: test script: - bundle install -j $(nproc) --path vendor --full-index --clean - bin/yarn - cp config/database.ci.yml config/database.yml - bundle exec rails db:create RAILS_ENV=test - bundle exec rails db:test:prepare RAILS_ENV=test - bundle exec rails test - bundle exec rails test:system deploy_review: stage: review script: - gem install dpl - heroku apps:fork --from $HEROKU_STAGING_APP --to $CI_ENVIRONMENT_SLUG || true - dpl --provider=heroku --app=$CI_ENVIRONMENT_SLUG --api-key=$HEROKU_API_KEY - heroku run rake db:migrate --app=$CI_ENVIRONMENT_SLUG environment: name: review/$CI_BUILD_REF_NAME url: https://$CI_ENVIRONMENT_SLUG.herokuapp.com
  76. iOS build_project: stage: build script: - xcodebuild clean -project ProjectName.xcodeproj

    -scheme SchemeName | xcpretty - xcodebuild test -project ProjectName.xcodeproj -scheme SchemeName -destination 'platform=iOS Simulator,name=iPhone 6s,OS=9.2' | xcpretty -s
  77. php image: php:5.6 before_script: # Install dependencies - bash ci/docker_install.sh

    > /dev/null test:app: script: - phpunit --configuration phpunit_myapp.xml
  78. Instalación

  79. gitlab.com

  80. None
  81. None
  82. None
  83. TATFT

  84. Prueba todo el bendito tiempo

  85. Gracias @dabit