OpenTermsArchive / engine

Tracks contractual documents and exposes changes to the terms of online services.
https://opentermsarchive.org
European Union Public License 1.2
105 stars 29 forks source link

Add Gitlab functionalities #1095

Open fabianospinelli opened 3 days ago

fabianospinelli commented 3 days ago

Here the list of file changed or added in order to add the ability to use GitLab instead of GitHub as store repo. For each file, a simple description is given to describe its purpose within the application and the changes made for GitLab:

env.example It's the file that contains the tokens for the repositories. In addition to the original GITHUB_TOKEN variable, 2 new variables were added, GITLAB_TOKEN (used for the declarations-related repository) and GITLAB_RELEASES_TOKEN (used for the versions-related repository on which to save datasets in ZIP file format). config/default.json The file was modified by adding some new elements within the JSON structure of the file. In the "reminder" element, the same structure as "githubIssues" was added but named "gitlabIssues". In the "declaration" field the name of the repository should be given in the form "/" engine/src/index.js The file is the module related to the declarations tracking procedure (performed with the "npx ota track" command). It has been modified by adding checks for the presence of GitHub and GitLab tokens. In either case, the relevant Reporter (for GitHub) or ReporterGitLab (for GitLab) classes are instantiated. engine/src/reporterGitlab/gitlab.js This file contains the definition of the Gitlab class and all its related methods for operating on a repository: getRepositoryLabels, createLabel, createIssues, setIssueLabels, openIssue, closeIssue, getIssue, addCommentToIssue, closeIssueWithCommentIfExists, and createOrUpdateIssue. It contains some settings such as the url where to reach the API of the GitLab respo you want to use (for example: https://gitlab.com/api/v4 ) engine/src/reporterGitlab/index.js This file contains the definition of the Reporter class related to the use of GitLab. Within it, the related methods of the GitLab class described above are invoked. engine/src/reporterGitlab/labels.json This file contains, via a JSON structure, the list of labels that must be present on the repository in order to properly create issues. In case no labels are present in the repository thanks to this file they are automatically created during the first run. engine/src/reporterGitlab/labels.test.js It's a Javascript file used to test the file "labels.json" to verify that all the info inserted complains with the GitLab constraints. engine/scripts/dataset/index.js The file is the module related to the creation of releases and datasets (performed with the "npx ota dataset" command). It has been modified by adding checks for the presence of GitHub and GitLab tokens. In either case, the relevant publishRelease (for GitHub) or publishReleaseGitLab (for GitLab) classes are instantiated. engine/scripts/dataset/assets/README.templateGitLab.js This file contains the template with all the texts and links that are used into every releases created during the "dataset" process. engine/scripts/dataset/publishGitLab/index.js The file contains the function to publish a release on a GitLab repository. This function creates a release and the zip file that is attached as asset link to the release.

MattiSG commented 3 days ago

Since merging code into the codebase entails long-term maintenance commitment, we will also need automated tests to pass before considering review. If you'd like to speed up the review process for this GitLab integration to be available within your organisation, please consider sponsoring!