Setting up a Scientific Software Project using GitLab: From “Zero” to “Hero”
US-RSE Education & Training Seminar Series
Marshall McDonnell (mcdonnellmt@ornl.gov)
Oak Ridge National Laboratory
ORNL is managed by UT-Battelle LLC for the US Department of Energy
1
1
Introduction
2
2
What do I do at Oak Ridge National Laboratory (ORNL)?
3
3
Why talk about GitLab?
4
4
Why talk about GitLab?
5
5
DISCLAIMER
6
6
Help during tutorial
7
7
Legend for presentation
Keyboard typing image from from Flaticon.com
1
8
8
Introduction to GitLab
9
9
GitLab
10
10
11
11
GitLab vs. GitHub
12
12
GitLab vs. GitHub
13
13
Creating a GitLab Account
14
14
Create a GitLab Account
15
15
Create a GitLab Account
16
16
Create a GitLab Account using Google SSO
17
17
Create a GitLab Account using GitHub SSO
18
18
Create a GitLab Account using Twitter SSO
19
19
Create a GitLab Account using Bitbucket SSO
20
20
Create a GitLab Account using Salesforce SSO
21
21
Which “Create a GitLab Account” option to use?
22
22
Which “Create a GitLab Account” option to use?
23
23
Let’s create our GitLab account…
HANDS-ON:
24
24
Create a GitLab Account using Username + Password
1
2
3
25
25
Create a GitLab Account using Username + Password
1
2
3
4
5
26
26
Create a GitLab Account using Username + Password
1
2
3
5
6
4
27
27
Create a GitLab Account using Username + Password
28
28
Working with Projects and Groups in GitLab
29
29
Yet, we have to get started somewhere…
Objectives:
HANDS-ON:
30
30
Get to your GitLab dashboard
31
31
Make a project in GitLab
32
32
Make a project in GitLab
33
33
Make a project in GitLab
34
34
Make a project in GitLab
35
35
OR
Without README initialized
With README initialized
36
36
Make a group in GitLab
1
2
37
37
Make a group in GitLab
38
38
Make a group in GitLab
39
39
Make a group in GitLab
40
40
Groups / Subgroups / Projects example from GitLab
Group
Subgroup
Subgroup
Project
Project
41
41
…vs. GitHub
Organization
Repository
42
42
Move project into the group
1
2
3
4
43
43
Conclusion
44
44
Fork / Clone Existing Projects in GitLab
45
45
Bring in pre-existing projects…
Objective:
HANDS-ON / DEMO:
46
46
Fork an existing GitLab project into your group
47
47
Fork an existing GitLab project into your group
1
48
48
Fork an existing GitLab project into your group
49
49
Fork an existing GitLab project into your group
50
50
Clone an existing GitLab project into your group
git clone git@gitlab.com:my-new-group/my-new-repo.git
1
2
51
51
Clone an existing GitLab project into your group
1
2
3
52
52
Clone an existing GitLab project into your group
origin git@gitlab.com:my-new-group/my-new-repo.git (fetch)
origin git@gitlab.com:my-new-group/my-new-repo.git (push)
git remote set-url origin git@gitlab.com:my-new-group/my-new-repo-clone.git
git push -u origin main
53
53
Clone an existing GitLab project into your group
54
54
Clone an existing GitLab project into your group
55
55
Conclusion
56
56
Working with Issues to Organize Project Work in GitLab
57
57
How GitLab can help you manage your work
Objectives:
HANDS-ON:
58
58
Create an issue
1
2
59
59
Create an issue
1
2
3
60
60
Create a label
1
2
61
61
Create a label
1
2
3
4
5
62
62
Create a label
63
63
Create a label
1
2
3
64
64
Create a group label
1
3
4
2
65
65
Create a group label
versus…
66
66
Create a group label
1
2
2
3
67
67
Create a group label
1
2
68
68
Make a feature branch from this issue
1
2
3
69
69
Use Web IDE
70
70
Use Web IDE
1
2
71
71
Use Web IDE
1
2
3
4
5
6
72
72
Create a Merge Request to address the issue
1
4
2
3
73
73
Create a Merge Request to address the issue
1
2
74
74
Create a Merge Request to address the issue
75
75
Create a Merge Request to address the issue
1
2
76
76
Conclusion
77
77
Issues Templates, Issue Boards, and Milestones in GitLab
78
78
How GitLab can help you manage your changes
Objectives:
HANDS-ON:
79
79
Add an issue template
80
80
Add an issue template
1
2
81
81
Add an issue template
Templates courtesy of John Hetrick, Principal Architect in Software Engineering Group
1
2
3
82
82
Add an issue template
1
2
3
4
5
83
83
Add an issue template
1
2
3
4
5
6
7
8
84
84
Create an issue board
85
85
Create an issue board
1
2
86
86
Create an issue board
87
87
Create an issue board
1
2
3
88
88
Create an issue board
89
89
Add a milestone
1
2
90
90
Add a milestone
1
2
3
4
5
91
91
Add a milestone
1
2
3
92
92
Add a milestone
1
2
93
93
Advice on Issue Board vs. Milestones + extra
94
94
Conclusion
95
95
Continuous Integration in GitLab: Automating Code Checks
96
96
Continuous Integration (CI)
Image from: https://docs.gitlab.com/ee/ci/introduction/index.html#gitlab-cicd-workflow
97
97
GitLab CI vs. GitHub Actions
98
98
How GitLab can help you automate code checks
Objectives:
HANDS-ON:
99
99
Setup CI pipeline
100
100
Setup CI pipeline
1
2
4
3
101
101
Setup CI pipeline
102
102
Setup CI pipeline
1
103
103
Find CI pipeline after setup
1
2
104
104
What do I need to run CI?
Runner
Runner
Runner
Project
Project
Project
105
105
What do I need to run CI?
*Maybe look into infrastructure-as-code to manage…
Runner
Runner
Runner
Project
Project
Project
Compute images from from Flaticon.com
106
106
Conclusion
107
107
Software Artifacts and Continuous Delivery / Deployment in GitLab
108
108
What about my software artifacts?
109
109
Continuous Delivery / Deployment (CD)
Image from: https://docs.gitlab.com/ee/ci/introduction/index.html#gitlab-cicd-workflow
110
110
Wait… continuous delivery and continuous deployment… what is the difference???
Figure from: https://www.atlassian.com/continuous-delivery/principles/continuous-integration-vs-delivery-vs-deployment
111
111
Extend CI to publish artifacts
Objective:
HANDS-ON / DEMO:
NOTE: This part will be less hands-on and more demonstration
112
112
Add a packaging step to .gitlab-ci.yml
113
113
Add a packaging step to .gitlab-ci.yml
package:
stage: deploy
script:
- pip install build twine
- python -m build
- TWINE_PASSWORD=${CI_JOB_TOKEN} TWINE_USERNAME=gitlab-ci-token python -m twine upload --repository-url ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi dist/*
only:
- tags
114
114
Add a packaging step to .gitlab-ci.yml
package:
stage: deploy
script:
- pip install build twine
- python -m build
- TWINE_PASSWORD=${CI_JOB_TOKEN} TWINE_USERNAME=gitlab-ci-token python -m twine upload --repository-url ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi dist/*
only:
- tags
115
115
Add a packaging step to .gitlab-ci.yml
1
2
3
116
116
Add a packaging step to .gitlab-ci.yml
3
1
2
117
117
Add a packaging step to .gitlab-ci.yml
1
2
3
4
118
118
Add a packaging step to .gitlab-ci.yml
1
2
3
119
119
Add a container build + publish step to .gitlab-ci.yml
120
120
Add a container build + publish step to .gitlab-ci.yml
image: python:latest
services:
- docker:dind
…
container-build:
image: docker:latest
before_script:
- docker --version
script:
- docker build -t mcpi .
121
121
Add a container build + publish step to .gitlab-ci.yml
image: python:latest
services:
- docker:dind
…
container-build:
image: docker:latest
before_script:
- docker --version
script:
- docker build -t mcpi .
122
122
Add a container build + publish step to .gitlab-ci.yml
1
2
123
123
Add a container build + publish step to .gitlab-ci.yml
container-package:
stage: deploy
image: docker:latest
before_script:
- docker --version
- docker login --username=$CI_REGISTRY_USER --password=$CI_REGISTRY_PASSWORD $CI_REGISTRY
script:
- docker build -t mcpi .
- docker tag mcpi $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_NAME:$CI_COMMIT_SHORT_SHA
- docker tag mcpi $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_NAME:latest
- docker push $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_NAME:$CI_COMMIT_SHORT_SHA
- docker push $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_NAME:latest
124
124
Add a container build + publish step to .gitlab-ci.yml
container-package:
stage: deploy
image: docker:latest
before_script:
- docker --version
- docker login --username=$CI_REGISTRY_USER --password=$CI_REGISTRY_PASSWORD $CI_REGISTRY
script:
- docker build -t mcpi .
- docker tag mcpi $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_NAME:$CI_COMMIT_SHORT_SHA
- docker tag mcpi $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_NAME:latest
- docker push $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_NAME:$CI_COMMIT_SHORT_SHA
- docker push $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_NAME:latest
125
125
Add a container build + publish step to .gitlab-ci.yml
1
2
3
4
126
126
Add a container build + publish step to .gitlab-ci.yml
127
127
Conclusion
128
128
Last Few Notes…
129
129
Diverse team of software engineers, scientists, students…
130
130
Example of Project Team => Gitlab Roles
Project Role | GitLab Role | Explanation |
Principal Investigator / Lead Developer | Owner / Maintainer | Full control of software project in GitLab |
Research Software Engineer / Computational Scientist / Scientific Software Developer / Operations Engineer | Maintainer / Developer | Developer who will use the platform regularly; provide enough permissions to cover for others in higher-permission roles |
Junior Developers / Students / Interns | Developer / Reporter / Guest | Limit permissions to map to scope of work; guardrails for stuff like deleting a project / force push |
Collaborators / Non-Developer Experimental or Instrument Scientist | Reporter / Guest | Can help create issues to report bugs or request new features; mostly view-only role |
131
131
Visibility of Projects and Groups
Group
Project in Group
1
2
1
2
132
132
Example ORNL Scientific Project in GitLab
133
133
Example GitHub vs. GitLab for ORNL Project
134
134
Conclusions and Wrap-up
135
135
Conclusions
136
136
Thank you!
Questions?
Feedback:
137
137
Extra Exercises / Homework
138
138
Exercises not covered in the live hands-on…
HANDS-ON / DEMO:
139
139
Setting up SSH keys locally with GitLab
140
140
Setting up SSH keys locally with GitLab
141
141
Setting up SSH keys locally with GitLab
3
1
2
4
5
6
142
142
Setting up SSH keys locally with GitLab
ECDSA key fingerprint is SHA256:HbW3g8zUjNSksFbqTiUWPWg2Bq1x8xdGUrliXFzSnUw.
Are you sure you want to continue connecting (yes/no/[fingerprint])?
143
143
Upload a pre-existing project to the repository
144
144
Additional practice for forking and cloning
145
145
Backup Slides
146
146
Add an Epic
147
147
More on “what is GitLab”?
Figure from: https://about.gitlab.com/topics/devops/
148
148
But… what is DevOps?
DevOps is a combination of software developers (dev) and operations (ops). It is defined as a software engineering methodology which aims to integrate the work of software development and software operations teams by facilitating a culture of collaboration and shared responsibility.
Figure from: https://about.gitlab.com/topics/devops/
149
149
Where is all this GitLab “DevOps stuff?
150
150
What if I need a deployment?
151
151
Where do I run software services?
152
152
What is Infrastructure-as-Code?
153
153
Infrastructure-as-Code vs. Configuration Management?
154
154
What is the Use Case for Infrastructure-as-Code?
155
155
What are the benefits using Infrastructure-as-Code?
Benefits for the adoption of IaC are:
Case studies exemplifying the IaC benefits:
[1] Puppet Labs, “Ambit Energy’s customer story for deploying 1,200 times faster due to IaC with Puppet” 2021. [Online]. Available: https://puppet.com/resources/customer-story/ambit-energy
[2] R. M. Mark Salam, “Up and to the right” 2021. [Online]. Available: https://www.hashicorp.com/case-studies/tmx-group
[3] Pulumi, “Pulumi’s case study for snowflake, a data platform.” [Online]. Available: https://www.pulumi.com/case-studies/snowflake
156
156
What are the tools for Infrastructure-as-Code?
*more “configuration management” tools than IaC-specific
157
157
What are the tools for Infrastructure-as-Code?
*more “configuration management” tools than IaC-specific
158
158
Revisited: IaC vs. Configuration Management?
159
159
What is Terraform?
160
160
How does Terraform work?
161
161
Terraform as a Team via CI/CD Pipeline
162
Networking
Servers
Infrastructure “Recipe”
Automated Pipeline
162
162