Slide 1

Slide 1 text

CI/CD con Gitlab David Padilla @dabit

Slide 2

Slide 2 text

David Padilla @dabit

Slide 3

Slide 3 text

@micheladaio

Slide 4

Slide 4 text

CI/CD con Gitlab

Slide 5

Slide 5 text

CI/CD

Slide 6

Slide 6 text

Integración Continua CI

Slide 7

Slide 7 text

Entrega Continua CD

Slide 8

Slide 8 text

Despliegue Continuo CD

Slide 9

Slide 9 text

Pruebas Automatizadas

Slide 10

Slide 10 text

Test Driven Development

Slide 11

Slide 11 text

Nuestro proceso

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

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

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

Control de versiones (git) Merge Requests / Retroalimentación Orquesta deploys Corre pruebas Registry de Docker

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

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

Slide 19

Slide 19 text

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

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

Como Usuario cuando voy a la pagina principal quiero ver el slogan "La mejor conferencia de México"

Slide 23

Slide 23 text

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

Slide 24

Slide 24 text

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

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

SGNext

La mejor conferencia de Mexico

Slide 28

Slide 28 text

SGNext

La mejor conferencia de Mexico

Slide 29

Slide 29 text

SGNext

La mejor conferencia de Mexico

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

$ git checkout -b slogan $ git add . $ git commit -m "Nuevo slogan" [slogan d287522] Nuevo slogan 2 files changed, 2 insertions(+)

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

No content

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

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

Slide 45

Slide 45 text

SGNext

La mejor conferencia de México

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

No content

Slide 48

Slide 48 text

No content

Slide 49

Slide 49 text

No content

Slide 50

Slide 50 text

No content

Slide 51

Slide 51 text

No content

Slide 52

Slide 52 text

No content

Slide 53

Slide 53 text

No content

Slide 54

Slide 54 text

No content

Slide 55

Slide 55 text

No content

Slide 56

Slide 56 text

No content

Slide 57

Slide 57 text

No content

Slide 58

Slide 58 text

No content

Slide 59

Slide 59 text

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

Slide 60

Slide 60 text

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

Slide 61

Slide 61 text

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

Slide 62

Slide 62 text

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

Slide 63

Slide 63 text

No content

Slide 64

Slide 64 text

.gitlab-ci.yml

Slide 65

Slide 65 text

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

Slide 66

Slide 66 text

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:

Slide 67

Slide 67 text

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:

Slide 68

Slide 68 text

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:

Slide 69

Slide 69 text

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:

Slide 70

Slide 70 text

- 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

Slide 71

Slide 71 text

- 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

Slide 72

Slide 72 text

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

Slide 73

Slide 73 text

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

Slide 74

Slide 74 text

Agnóstico

Slide 75

Slide 75 text

- 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

Slide 76

Slide 76 text

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

Slide 77

Slide 77 text

php image: php:5.6 before_script: # Install dependencies - bash ci/docker_install.sh > /dev/null test:app: script: - phpunit --configuration phpunit_myapp.xml

Slide 78

Slide 78 text

Instalación

Slide 79

Slide 79 text

gitlab.com

Slide 80

Slide 80 text

No content

Slide 81

Slide 81 text

No content

Slide 82

Slide 82 text

No content

Slide 83

Slide 83 text

TATFT

Slide 84

Slide 84 text

Prueba todo el bendito tiempo

Slide 85

Slide 85 text

Gracias @dabit