You are on page 1of 17

Workshop Continuous Integration

Agenda

• Starter exercise
• Why do we need CI?
• CI Demo
• Questions
• Exercises
Starter exercise (15 minutes)

• Plenary or in groups of 6 (project groups)


• Write down:
– What is branching and merging in a Git(lab) project?
– When working on a group project, when do you push to
master-branch?
– How much should you unit-test? Percentage?
– What do you think Continuous integration means?
Why do we need Continuous integration?

• Agile working -> rapid development, many changes


• Merging developers code is messy
• Test, test, test (automatically) -> fix broken code
• Waiting…
So, how do I do CI?

• Merge into shared Version control branch


• Continuously!
• Let that VC tool test the entire project
• Get a report about problems
• Fix problems
• Relax…
Summarizing
Demo by teacher
Lets look at a demo (by teacher)

• Login to Gitlab
• Create GitlabCIDemo project (Create a blank project
and clone/push or use the Gitlab import from url:
https://git.fhict.nl/I872209/simplejavaunittestapp.git)
Demo

• Show code (Dep class and simple string return


method)
• Run unit test at DepTest
• Add yaml file at root called .gitlab-ci.yml, content next
slide
• Edit with editor, reference
https://docs.gitlab.com/ee/ci/yaml/
Demo Yaml content
# Linux only
#before_script:
#- export GRADLE_USER_HOME=$(pwd)/.gradle
#- chmod +x ./gradlew

stages:
- build
- test

build:
stage: build
script:
- ./gradlew build -x test
- ./gradlew.bat --stop
test:
stage: test
script:
- ./gradlew test
- ./gradlew.bat –stop

after_script:
- echo "End CI“
- exit
Explain yaml file

• What to execute using GitLab Runner.


• What decisions to make when specific conditions are
encountered. For example, when a process
succeeds or fails.
Push Yaml to repo

• Push the Yaml to the repo


• Add a runner
How does the Version control tool know how to
test?
• Communicate with Agents or Runners
• Gitlab CI/CD uses Runners
• Because we don’t have a Virtual Private Server(VPS)
we use local runners on our own machine
Install local runner

• Follow the guidelines at


https://docs.gitlab.com/runner/install/
• Register the runner for your project:
https://docs.gitlab.com/runner/register/
• You can use docker(both in install as well as
registration), but it can get complicated to explain,
and we will cover this in a later workshop
Use the runner

• Use the runner to execute the build and test locally


• The runner gets a message from the Gitlab server to
execute Terminal commands locally
• Check the result when pushing to your gitlab
environment
Questions?
Exercises

• See Canvas

You might also like