gitlabr

An R client for the GitLab API

https://github.com/thinkr-open/gitlabr

Science Score: 23.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    2 of 20 committers (10.0%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (19.2%) to scientific vocabulary

Keywords

gitlab r r-package rstats

Keywords from Contributors

golemverse shiny shiny-apps shiny-r shinyapps
Last synced: 6 months ago · JSON representation

Repository

An R client for the GitLab API

Basic Info
Statistics
  • Stars: 41
  • Watchers: 2
  • Forks: 16
  • Open Issues: 17
  • Releases: 3
Topics
gitlab r r-package rstats
Created over 5 years ago · Last pushed almost 2 years ago
Metadata Files
Readme Changelog Contributing License Code of conduct

README.Rmd

---
output: github_document
---



```{r, include = FALSE}
knitr::opts_chunk$set(
  cache = TRUE,
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%",
  eval = Sys.getenv("GITLAB_COM_TOKEN", unset = FALSE) # do not eval if token is not available
)
```

# {gitlabr} 


[![CRAN\_Status\_Badge](https://www.r-pkg.org/badges/version/gitlabr)](https://cran.r-project.org/package=gitlabr)
![CRAN\ Downloads\ Badge](https://cranlogs.r-pkg.org/badges/gitlabr)
[![codecov](https://codecov.io/gh/ThinkR-open/gitlabr/graph/badge.svg?token=EVRTX5LST9)](https://app.codecov.io/gh/ThinkR-open/gitlabr)
[![R-CMD-check](https://github.com/ThinkR-open/gitlabr/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/ThinkR-open/gitlabr/actions/workflows/R-CMD-check.yaml)


Never dreamt of creating and managing your GitLab projects from R? 
{gitlabr} is here to help you with that!  
With {gitlabr}, you can interact with GitLab's API to manage your projects, issues, merge requests, pipelines, wikis, and more.  
Now, the automation of your regular tasks with GitLab is just a few lines of R code away.

## Installation

You can install the most recent stable version from CRAN using:

```{r, eval=FALSE}
install.packages("gitlabr")
```

To install the development version using [devtools](https://cran.r-project.org/package=devtools), type:
```{r, eval=FALSE}
install.packages("gitlabr", repos = "https://thinkr-open.r-universe.dev")
```

See the [CONTRIBUTING.md](https://github.com/ThinkR-open/gitlabr/blob/main/CONTRIBUTING.md) for instructions on how to run tests locally and contributor information.

## Recommended GitLab versions

GitLab 11.6 or higher is generally recommended when using {gitlabr} version 2.0.0 or higher. This {gitlabr} version uses the GitLab API v4.

## Quick Start Example

R code using {gitlabr} to perform some common GitLab actions can look like this

- Create a TOKEN on your GitLab instance with scopes: `api`
  + For instance on gitlab.com: `https://gitlab.com/-/profile/personal_access_tokens`
- Store your token in .Renviron as `GITLAB_COM_TOKEN` with `usethis::edit_r_environ()` and restart your session 
- Set a connection to GitLab instance
```{r, cache=FALSE}
library(gitlabr)

# You can verify your token works
# Sys.getenv("GITLAB_COM_TOKEN")

# connect as a fixed user to a GitLab instance for the session
set_gitlab_connection(
  gitlab_url = "https://gitlab.com",
  private_token = Sys.getenv("GITLAB_COM_TOKEN")
)
```

- Find the list of projects available to you
  + Define a limit of pages of projects to search in with `max_page`, otherwise the entire GitLab.com will be downloaded here...
  + Find all parameters available in the API for projects on this page: https://docs.gitlab.com/ee/api/projects.html
    + For instance, we can set `owned = FALSE` to retrieve all projects except ours.
```{r}
# a tibble is returned, as is always by {gitlabr} functions
gl_list_projects(max_page = 2, owned = FALSE)
```

### Work with a specific project

- Explore one of your projects. You can set the name of the project or its ID. The ID is highly recommended, in particular if your project does not appear in the first pages of projects above. 
  + Let's explore [project "repo.rtask"](https://gitlab.com/statnmap/repo.rtask), with `ID = 20384533` on GitLab.com
  
```{r}
my_project <- 20384533 # repo.rtask",
```

- If the default branch is not named `main`, you need to specify it with `gitlabr_options_set()`

```{r}
gitlabr_options_set("gitlabr.main", "master")
```


- List files of the project using `gl_list_files()`
```{r}
gl_list_files(project = my_project)
```

- List issues with `gl_list_issues()`

```{r}
gl_list_issues(project = my_project)
```

- Create an issue

```{r, eval=FALSE}
# create a new issue
new_feature_issue <- gl_create_issue(project = my_project, title = "Implement new feature")

# Your user ID
my_id <- 0000000

# assign issue to me
gl_assign_issue(
  project = my_project,
  issue_id = new_feature_issue$iid,
  assignee_id = my_id
)

# Verify new issue is here
gl_list_issues(project = my_project, state = "opened")

# close issue
gl_close_issue(project = my_project, issue_id = new_feature_issue$iid)$state
```

_Note that recent version of GitLab may have anti-spam on opening issues, leading to ERROR with `gl_create_issue()` if you abuse the API. You will need to open the issue manually in this case._

### Use additional requests

If an API request is not already available in {gitlabr}, function `gitlab()` allows to use any request of the GitLab API .

For instance, the API documentation shows how to create a new project in :

- The verb is `POST`
- The request is `projects`
- Required attributes are `name` or `path` (if `name` not set)
- `default_branch` is an attribute that can be set if wanted, but not required

The corresponding use of `gitlab()` is:

```{r, eval=FALSE}
gitlab(
  req = "projects",
  verb = httr::POST,
  name = "toto",
  default_branch = "main"
)
```

Implement whatever suits your needs !

### Unset connection

```{r}
unset_gitlab_connection()
```

## Using GitLab CI with {gitlabr}

{gitlabr} can also be used to create a `.gitlab-ci.yml` file to test, build and check an R package, a bookdown, ... using GitLab's CI software. Use `gitlabr::use_gitlab_ci()` with a specific `type` in your project and your CI should be ready to start in the next commit.

There are pre-defined templates:  

```{r echo=FALSE, results='asis'}
cat(paste("-", list.files("inst/gitlab-ci/"), collapse = "\n\n"))
```


## Further information

- For an introduction see the `vignette("a-gitlabr", package = "gitlabr")`
- When writing custom extensions ("convenience functions") for {gitlabr} or when you experience any trouble, the very extensive [GitLab API documentation](https://docs.gitlab.com/ce/api/) can be helpful.

# Contributing to {gitlabr}

You're welcome to contribute to {gitlabr} by editing the source code, adding more convenience functions, filing issues, etc. [CONTRIBUTING.md](https://github.com/ThinkR-open/gitlabr/blob/main/CONTRIBUTING.md) compiles some information helpful in that process.


## Code of Conduct

Please note that the gitlabr project is released with a [Contributor Code of Conduct](https://thinkr-open.github.io/gitlabr/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.


_Note that the {gitlabr} package was originally created by [Jirka Lewandowski](https://github.com/jirkalewandowski/gitlabr). The present repository is a fork to be able to continue development of this package._  

Owner

  • Name: ThinkR
  • Login: ThinkR-open
  • Kind: organization
  • Email: welcome@thinkr.fr
  • Location: France

R Engineering, training, and consulting

GitHub Events

Total
  • Issues event: 1
  • Watch event: 1
  • Fork event: 1
Last Year
  • Issues event: 1
  • Watch event: 1
  • Fork event: 1

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 440
  • Total Committers: 20
  • Avg Commits per committer: 22.0
  • Development Distribution Score (DDS): 0.573
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Jirka Lewandowski j****i@p****e 188
statnmap s****n@t****r 139
Jirka Lewandowski j****i@w****u 48
Lars Dalby l****y@g****m 22
mpolano p****o@g****m 10
jennybc j****y@s****a 7
ALanguillaume a****e@g****m 4
margot m****t@t****r 3
Damian Gola d****a@e****e 3
Yohann Msx 4****x 2
Jonathan Kitt j****t@i****r 2
Kevin Cazelles k****e@u****a 2
Marco Polano m****o@t****t 2
yohann y****n@t****r 2
Andrew Collier a****w@f****v 1
Jiaxiang Li j****0@b****u 1
Konrad Rudolph k****h@r****m 1
Murielle Delmotte m****e@t****r 1
Yoshinobu Ishizaki y****i@m****m 1
Romain LESUR r****r@g****m 1

Issues and Pull Requests

Last synced: 7 months ago

All Time
  • Total issues: 75
  • Total pull requests: 48
  • Average time to close issues: about 1 year
  • Average time to close pull requests: 3 months
  • Total issue authors: 22
  • Total pull request authors: 13
  • Average comments per issue: 1.59
  • Average comments per pull request: 0.77
  • Merged pull requests: 34
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 2
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 2
  • Pull request authors: 0
  • Average comments per issue: 0.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • statnmap (46)
  • MargotBr (4)
  • ymansiaux (3)
  • ColinFay (2)
  • MurielleDelmotte (2)
  • ALanguillaume (2)
  • davidcarayon (1)
  • csgillespie (1)
  • billdenney (1)
  • a-dacko (1)
  • mpolano (1)
  • markrobinsonuzh (1)
  • LBeaulaton (1)
  • KatarzynaGraczyk (1)
  • ei-ds (1)
Pull Request Authors
  • statnmap (40)
  • ymansiaux (4)
  • datawookie (3)
  • ALanguillaume (2)
  • mpolano (2)
  • LDalby (2)
  • klmr (2)
  • KittJonathan (1)
  • Yoshinobu-Ishizaki (1)
  • VincentGuyader (1)
  • KevCaz (1)
  • ei-ds (1)
  • MargotBr (1)
Top Labels
Issue Labels
gitlab-ci (17) documentation (7) good first issue (7) hacktoberfest-accepted (5) help wanted (5) bug (4) enhancement (3) v2.2.0 (2) Difficulty: advanced (2) v2.1.0 (1) wontfix (1)
Pull Request Labels
hacktoberfest-accepted (2)

Packages

  • Total packages: 1
  • Total downloads:
    • cran 808 last-month
  • Total docker downloads: 43,566
  • Total dependent packages: 0
  • Total dependent repositories: 6
  • Total versions: 9
  • Total maintainers: 1
cran.r-project.org: gitlabr

Access to the 'GitLab' API

  • Versions: 9
  • Dependent Packages: 0
  • Dependent Repositories: 6
  • Downloads: 808 Last month
  • Docker Downloads: 43,566
Rankings
Docker downloads count: 0.6%
Forks count: 5.8%
Stargazers count: 8.3%
Dependent repos count: 12.0%
Average: 12.6%
Downloads: 20.2%
Dependent packages count: 28.8%
Last synced: 7 months ago

Dependencies

DESCRIPTION cran
  • R >= 3.1.2 depends
  • arpr * imports
  • base64enc * imports
  • dplyr >= 0.4.3 imports
  • httr >= 1.1.0 imports
  • magrittr * imports
  • purrr >= 0.2.2 imports
  • shiny >= 0.13.0 imports
  • stringr * imports
  • tibble >= 1.1 imports
  • utils * imports
  • knitr * suggests
  • rmarkdown * suggests
  • testthat >= 3.0.0 suggests
  • yaml * suggests
.github/workflows/R-CMD-check.yaml actions
  • actions/checkout v3 composite
  • r-lib/actions/check-r-package v2 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/pkgdown.yaml actions
  • JamesIves/github-pages-deploy-action v4.4.1 composite
  • actions/checkout v3 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/test-coverage.yaml actions
  • actions/checkout v3 composite
  • actions/upload-artifact v3 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
Dockerfile docker
  • rocker/r-devel latest build
dev/testor/DESCRIPTION cran