Webinar - Continuous Integration with GitLab

16
Continuous Integration with Gitlab Presented By: Farley olindata.com April 5, 2016 DevOps, Done Right Continuous Integration with Gitlab Presented by: Andrew Farley [email protected]

Transcript of Webinar - Continuous Integration with GitLab

Page 1: Webinar - Continuous Integration with GitLab

Continuous Integration with Gitlab Presented By: Farley

ol indata.com April 5, 2016

DevOps, Done Right

Continuous Integration with Gitlab

Presented by: Andrew Farley [email protected]

Page 2: Webinar - Continuous Integration with GitLab

Continuous Integration with Gitlab Presented By: Farley

ol indata.com April 5, 2016

Slide

DevOps, Done Right

• Senior DevOps Engineer and Consultant for OlinData

• Specializing in high-scalability engineering on the cloud

• Is an AWS Certified Solutions Architect

• Author and co-author of over 30 iPhone apps and games

• Passionate about open-source and knowledge-sharing

Who am I?

2

Page 3: Webinar - Continuous Integration with GitLab

Continuous Integration with Gitlab Presented By: Farley

ol indata.com April 5, 2016

DevOps, Done Right

Slide

• What is Continuous Integration (CI)?

• Why CI?

• Introduction to Gitlab

• Some ways to use CI

• Your first build with GitLab

• Demo

• Questions?

Overview

3

Page 4: Webinar - Continuous Integration with GitLab

Continuous Integration with Gitlab Presented By: Farley

ol indata.com April 5, 2016

DevOps, Done Right

Slide

• Continuous Integration, or CI, is the practice of “integrating” regularly to prevent merge and code quality problems from occurring to help identify problems early during development

• Not required but highly desirable with multiple developers

• “Integration” means more than simply able to merge the code

• It can include but is not limited to…

• Lint (syntax) checks

• Ensuring the code compiles/builds (for compiled languages)

• Enforcing code quality requirements

• Running automated unit tests

• Enforcing minimum performance requirements

• Generating automated documentation

• Performing continuous delivery

• Triggering activities after success or failure such as automated deployments

What is Continuous Integration?

4

Page 5: Webinar - Continuous Integration with GitLab

Continuous Integration with Gitlab Presented By: Farley

ol indata.com April 5, 2016

DevOps, Done Right

Slide

• In practice, CI-related tasks are initiated off after pushing code to a remote source control server, such as…

• GitHub (https://github.com)

• GitLab (https://gitlab.com)

• BitBucket (https://bitbucket.org)

• SourceForge (https://sourceforge.net)

• There are various managed / SaaS CI providers that integrate with a number of the above services including…

• CircleCI (https://circleci.com)

• TravisCI (https://travis-ci.org)

• And there are managed solutions to do the same if you have legal or security reasons to not be able to ship your code to a SaaS provider

• Jenkins (https://jenkins.io/)

• Hudson (http://hudson-ci.org)

Continuous Integration continued…

5

Page 6: Webinar - Continuous Integration with GitLab

Continuous Integration with Gitlab Presented By: Farley

ol indata.com April 5, 2016

DevOps, Done Right

Slide

What is GitLab?

6

https://gitlab.comNOTE: OlinData and the presenter are not a client or partner of GitLab Inc., merely a fellow consumer and active user of their platform

• GitLab is an open-source managed Source Code Management (SCM) Repository

• GitLab is a cloud-hosted or managed alternative to GitHub, though typically hosted on your own server.

• Their feature-sets are comparable, especially with Enterprise GitLab.

• Ideal for customers with legal reasons to keep their code off SaaS and cloud-based SCM solutions like GitHub.

Page 7: Webinar - Continuous Integration with GitLab

Continuous Integration with Gitlab Presented By: Farley

ol indata.com April 5, 2016

DevOps, Done Right

Slide

Typical CI Workflow

7

Multiple Developers/Teams Push Code

SCM System Receives Code, Initiates CI

CI Builds Project (if necessary)

Automated Tests OccurReport (failed) Results to team via Email or other integrations (eg: Slack)

If necessary, fix failing builds

Page 8: Webinar - Continuous Integration with GitLab

Continuous Integration with Gitlab Presented By: Farley

ol indata.com April 5, 2016

DevOps, Done Right

Slide

Gradual CI Adoption

8

Bug Reported

Developers Fix Bug + Test Case

Continuous Integration

• Without CI currently on your system, you can gradually begin to add CI even while in a maintenance mode.

• Every time you fix a bug, write a test to ensure that bug does not occur again.

• Example: Users can sign up for a website with a space in front of their email address or name, which then leads to confusion when they can not login to a system.

• #1: Fix the bug (however you might fix it, either by stripping the newlines, or by rejecting the user input)

• #2: Write a test case using the right tool (in this case, possibly Selenium) to verify that the input fields and form only accept the valid input.

• With this in place as your system continues to evolve and change you can be sure new code any current or future developer writes will not cause that same bug to emerge again.

Deploy

Page 9: Webinar - Continuous Integration with GitLab

Continuous Integration with Gitlab Presented By: Farley

ol indata.com April 5, 2016

DevOps, Done Right

Slide

• Instead of wasting tons of time performing QA at or after deploying new code, you can make QA part of the development process.

• Enforcing code-style guidelines makes it easier for developers to work together and take over for one-another, and makes it easier for new developers.

• Allows your developers to find problems early during their development, making debugging and deployment much easier.

Why CI?

9

Page 10: Webinar - Continuous Integration with GitLab

Continuous Integration with Gitlab Presented By: Farley

ol indata.com April 5, 2016

DevOps, Done Right

Slide

Continuous Integration Uses

10

• Ensuring that code compiles and executes properly

Page 11: Webinar - Continuous Integration with GitLab

Continuous Integration with Gitlab Presented By: Farley

ol indata.com April 5, 2016

DevOps, Done Right

Slide

Continuous Integration Uses

11

• Ensuring the code follows your code style or compliance rules

Page 12: Webinar - Continuous Integration with GitLab

Continuous Integration with Gitlab Presented By: Farley

ol indata.com April 5, 2016

DevOps, Done Right

Slide

Continuous Integration Uses

12

• Code passes a series of unit tests and ensuring minimum performance

Page 13: Webinar - Continuous Integration with GitLab

Continuous Integration with Gitlab Presented By: Farley

ol indata.com April 5, 2016

DevOps, Done Right

Slide

• Assuming you have gitlab setup, you still need to setup a “runner” to be able to execute your builds.

• Runner can be on the Gitlab server or on a throwaway server on a cloud-provider

• You’ll want to follow the install instructions from https://gitlab.com/gitlab-org/gitlab-ci-multi-runner

• You’ll also need your token runner token from: https://YOURGITLABURL/admin/runners

Prepare For Your First Build

13

Page 14: Webinar - Continuous Integration with GitLab

Continuous Integration with Gitlab Presented By: Farley

ol indata.com April 5, 2016

DevOps, Done Right

Slide

• All you need to do now, assuming your project is already in gitlab, is add a “.gitlab-ci.yml” file.

• For more about this file, please refer to the official documentation: http://doc.gitlab.com/ee/ci/yaml/README.html

Your First Build

14

Page 15: Webinar - Continuous Integration with GitLab

Continuous Integration with Gitlab Presented By: Farley

ol indata.com April 5, 2016

DevOps, Done Right

Slide

Demo

15

https://github.com/olindata/sample-gitlabci-ruby-project or

https://github.com/olindata/sample-gitlabci-cpp-projectDemo Projects

Page 16: Webinar - Continuous Integration with GitLab

Continuous Integration with Gitlab Presented By: Farley

ol indata.com April 5, 2016

DevOps, Done Right

Thanks!Questions?

Ask them now, or… http://olindata.com

[email protected]

All trademarks, service marks, trade names, trade dress, product names and logos appearing on this presentation are the property of their respective owners. All rights reserved.