GitLab#

The CC-IN2P3 hosts an instance of GitLab dedicated for research purposes at https://gitlab.in2p3.fr/.

With a University or CNRS credentials, one can login or create an account.

../_images/gitlab_in2p3.png

Fig. 21 Log in with your CNRS (Janus) or University credentials#

External collaborators can also have access, as soon as their host university is part of the edugain network.

Tip

One should have a look at the CCIN2P3 documentation beforehand to get all the instructions, and refrain from using the register now link.

Gitlab configuration#

Go to your SSH profile and add your public SSH key.

It is a good practise to activate the two-factor authentication here

Create a first personal project#

As an example, we’ll create a project to host a jupyter book, with:

  • source files managed by git

  • automatic update of the static html website using gitlab-ci

  • website hosted by gitlab-pages

Let’s create a first blank project:

https://gitlab.in2p3.fr/projects/new#create_from_template

From your laptop, clone the corresponding repository, using the Clone with SSH link given from the project main page.

$ git clone git@gitlab.in2p3.fr:myname/my-project.git
$ cd my-project

You can check the name of the default branch by doing:

$ git branch
 main

Now let’s populate the repository with a jupyter book:

python -m venv .venv 
source .venv/bin/activate
pip install -U jupyter-book

jupyter-book create mynewbook/

We don’t want our virtual environment to reside in the repo. Let’s mask it from git

echo ".venv" >> .gitignore

Tip

See https://jupyterbook.org/en/stable/start/create.html for more information on jupyter books.

Now, add, commit and push the source files into the main branch:

git add .gitignore
git add mynewbook/*
git commit -a
git push

Automatic build using gitlab-ci#

CI stands for continuous integration. By adding a .gitlab-ci.yml in your project directory, a ci process will run after any new push to the repository.

One can directly use the recipes provided by example project, like this one

Copy the content of this example into your project directory and push it to the main branch. You should be able to see the progress of the build from the build/pipeline menu of gitlab:

https://gitlab.in2p3.fr/myname/my-project/-/pipelines

One usually uses the CI to automatically perform some tests on the new pushed code.

Gitlab pages#

The gitlab-pages tool allows you to serve any static website associated to your repository.

To do so, html source files have to be copied into its public directory, like done in the .gitlab-ci.yml example above.

If your project is public, the website will be accessible to anyone. For private project, one has to log-in to gitlab beforehand.

The default URL will be : https://myname.pages.in2p3.fr/my-project/

Git workflow#

So far, we only used the main branch to directly commit and push our changes to the source files hosted by the repository.

When working and developing in a collaborative mode, it is recommended to use the issue and merge request facilities of GitLab, which allows you to attach your changes to a specific subject and let your collaborators know about it (or even make them review your contributions).

For more on git and git workflows, see: