Wikimedia Research/Documentation/Gitlab

From mediawiki.org

The Research team will maintain and document all code under our team's Gitlab project starting 2022-03-07 (we previously did this in Github). We expect all new projects from the Research team, including the work with formal collaborators and interns, to live on Gitlab. Please read below for more.

Organizing Software code on gitlab[edit]

We organize all code from our projects in wikimedia's gitlab research repos, which are owned by the research team group. Ideally, every project (involving code) should have a repository there.

Getting access[edit]

  • Create an account on gitlab using your existing wikitech account. At this point you can create projects in your own namespace, but you don't have access to the wikimedia's gitlab research repos .
  • Ask your manager (or another owner of the research team group) to add your gitlab account to the research team group. Note that you are required to enable two factor authentication to join the group.

Connecting to gitlab[edit]

You can clone/pull/push via https using an access token, or via ssh. It is preferable to use access tokens.

  1. https: Create an access-token via avatar (top right) -> edit profile -> access tokens. See the documentation for more details. Upon executing a command that requires authentication (e.g. pushing a branch), leave the user empty and enter the access token once a password is requested
    # e.g. to clone the knowledge gaps repo
    git clone https://gitlab.wikimedia.org/repos/research/knowledge-gaps.git
    
    You can increase the default timeout (15min) that the token is cached by using a git credentials cache , e.g. by
    $ git config --global credential.helper cache
    # add this to ~/.gitconfig to set the timeout to 1 hour.
    [credential]
    	helper = cache --timeout=3600
    
  2. ssh: Create an ssh-key and add it to your gitlab-account via avatar (top right) -> edit profile -> ssh keys, see the documentation for more details. Con: this does not work when you want to push code from the cluster (e.g. stat1007).
    # e.g. to clone the knowledge gaps repo
    git clone git@gitlab.wikimedia.org:repos/research/knowledge-gaps.git
    

private and public repos[edit]

When creating repositories in the gitlab research project, the only option is create public projects. In principle, there is an option to set a repository private via the settings, however this should only be done if necessary (e.g. for an analysis sensitive data from, e.g., webrequest logs). The repository will then only be accessible to the members of the research team. Eventually, the aim is to make any code available in a public repository according to WMF's open access policy.

As of 2022-04, all non-public visibility settings have been disabled by the administrator. There is an open phabricator ticket: "Request for Private repos to be enabled" (T305082).

Collaborators[edit]

External[edit]

It is possible to add outside collaborators as longs as they have a wmf gitlab account, and if applicable you can set an expiry data for membership (e.g. for internships with a known end date). Use the "Developer" role for external collaborators.

In order to add to a repo, the following steps need to be performed:

  • create a wikitech-account for the collaborator (if they dont have one)
  • create a gitlab account for the collaborator
  • send the invite for the repo to the gitlab-username (not the email)
  • as a developer, they will not be able to push and merge to protected branches (such as the main branch); you can adapt the permissions for each branch under Settings > Repository > Protected branches