Breaking Bad Habits with GitLab CI

152 views

Published on

Short story demonstrating features of GitLab CI

Published in: Technology
1 Comment
3 Likes
Statistics
Notes
No Downloads
Views
Total views
152
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
1
Comments
1
Likes
3
Embeds 0
No embeds

No notes for slide

Breaking Bad Habits with GitLab CI

  1. 1. Breaking Bad habits with GitLab CI Ivan Nemytchenko | RubyConf Taiwan | December 2, 2016
  2. 2. Ivan Nemytchenko → Russian, live in Serbia → Ruby developer since 2006 → Co-found 2 outsource agencies → Team lead, Project manager, etc → Coorganized 2 IT conferences → Developer advocate at GitLab → inem.at → @inem
  3. 3. RailsHurts.com
  4. 4. How to Stop being Rails developer
  5. 5. Why talk about GitLab? → big monolythic RoR application → open source → monthly releases → open processes (google for GitLab handbook) → 140 people (all remote) → 100.000+ companies use it → GitLab.com is free
  6. 6. GitLab has been started as an attempt to build open source alternative to GitHub
  7. 7. Breaking Bad with GitLab CI
  8. 8. Breaking Bad Habits with GitLab CI
  9. 9. Habit of not automating routine operations
  10. 10. CatGrep Sophisticated Technologies inc. → file1.txt → file2.txt
  11. 11. CatGrep Sophisticated Technologies inc. The code is on GitLab.com
  12. 12. Requirement #1 Concatenation result should contain "Hello world"
  13. 13. cat file1.txt file2.txt | grep -q "Hello world"
  14. 14. Run first test inside CI
  15. 15. Run first test inside CI .gitlab-ci.yml
  16. 16. Run first test inside CI test: script: cat file1.txt file2.txt | grep -q 'Hello world'
  17. 17. Run first test inside CI
  18. 18. Run first test inside CI
  19. 19. Requirement #2 Package code before sending it to customer
  20. 20. Package code test: script: cat file1.txt file2.txt | grep -q 'Hello world' package: script: cat file1.txt file2.txt | gzip > package.gz
  21. 21. Package code
  22. 22. Make results of your build downloadable
  23. 23. Make results of your build downloadable
  24. 24. Make results of your build downloadable
  25. 25. Make results of your build downloadable test: script: cat file1.txt file2.txt | grep -q 'Hello world' package: script: cat file1.txt file2.txt | gzip > packaged.gz artifacts: paths: - packaged.gz
  26. 26. Run jobs sequentially
  27. 27. Run jobs sequentially
  28. 28. Speeding up the build
  29. 29. Removing Duplication
  30. 30. Learning what Docker image to use
  31. 31. Learning what Docker image to use
  32. 32. Learning what Docker image to use image: alpine
  33. 33. Learning what Docker image to use
  34. 34. Learning what Docker image to use
  35. 35. Requirement #3 ISO instead of GZIP
  36. 36. Dealing with complex scenarios
  37. 37. Dealing with complex scenarios script: - apk add -U cdrkit - mkisofs -o ./packaged.iso ./compiled.txt
  38. 38. → 3 stages → passing files between stages → downloadable artifacts → optimized execution time → custom pipeline
  39. 39. Requirement #4 Publish a website, containing packages
  40. 40. Publish a website aws s3 cp ./ s3://yourbucket/ --recursive
  41. 41. Publish a website
  42. 42. Publish a website
  43. 43. First Automated Deployment → awscli can be installed using pip → pip goes together with python
  44. 44. First Automated Deployment s3: image: python stage: deploy script: - pip install awscli - aws s3 cp ./ s3://yourbucket/ --recursive
  45. 45. First Automated Deployment AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
  46. 46. First Automated Deployment
  47. 47. Keeping Secret Things Secret
  48. 48. Keeping Secret Things Secret Settings → Variables
  49. 49. Keeping Secret Things Secret s3: image: python stage: deploy script: - pip install awscli - aws s3 cp ./ s3://yourbucket/ --recursive
  50. 50. Keeping Secret Things Secret
  51. 51. Requirement #5 Two developers on the project
  52. 52. Two developers on the project
  53. 53. Two developers on the project
  54. 54. Requirement #6 Need a separate place for testing
  55. 55. Separate place for testing GitLab Pages
  56. 56. Host website using GitLab Pages → your job should be named "pages" → put your files into "public" folder → specify "artifacts" section with this "public" folder
  57. 57. Host website using GitLab Pages http://<username>.gitlab.io/<projectname>
  58. 58. Host website using GitLab Pages pages: stage: deploy image: alpine script: - mkdir -p ./public && cp ./*.* ./public/ artifacts: paths: - public except: - master
  59. 59. Separate place for testing s3: image: python stage: deploy script: - pip install awscli - aws s3 cp ./ s3://yourbucket/ --recursive only: - master pages: image: alpine stage: deploy script: - mkdir -p ./public && cp ./*.* ./public/ artifacts: paths: - public except: - master
  60. 60. Separate place for testing
  61. 61. Separate place for testing
  62. 62. Separate place for testing
  63. 63. Using Environments
  64. 64. Using Environments
  65. 65. Using Environments
  66. 66. Requirement #7 Do not mess up production
  67. 67. Do not mess up production
  68. 68. Do not mess up production
  69. 69. You can afford CI even for small projects!
  70. 70. Why no ruby?
  71. 71. Questions? @inem ivan@gitlab.com → bit.ly/gitlab-ci

×