Skip to content

Commit fdb4257

Browse files
committed
feat: year review for GitHub and GitLab (#181) (#186)
Add scripts in Python to request GitHub and GitLab API to compute some figures and metrics for a given year. Assisted-by: GPT-4o-mini (Dinootoo) Signed-off-by: Pierre-Yves Lapersonne <[email protected]>
1 parent 26a1916 commit fdb4257

12 files changed

+766
-4
lines changed

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
toolbox/github/data
2+
toolbox/github/.env
3+
24
toolbox/diver/data
35
toolbox/diver/.floss-toolbox/data
6+
47
toolbox/gitlab/data
8+
toolbox/gitlab/.env
9+
510
toolbox/utils/text-generator/_templates/new-GitHub-repository-contributors.fr.template.txt.result
611
toolbox/utils/third-party-generator/components.csv.result
712
toolbox/utils/third-party-generator/THIRD-PARTY.md.result
813
toolbox/utils/third-party-generator/__pycache__
914
toolbox/utils/_/__pycache__/
1015
toolbox/utils/reuse/.reuse/
16+
1117
toolbox/LicensesInventory/.pytest_cache
1218
toolbox/LicensesInventory/sources/__pycache__
1319
toolbox/LicensesInventory/sources/*/__pycache__

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12+
- GitHub and GitLab year review ([#181](https://github.com/Orange-OpenSource/floss-toolbox/issues/181))
1213
- Samples for common files to add in projects ([#184](https://github.com/Orange-OpenSource/floss-toolbox/issues/184))
1314

1415
## [2.21.0](https://github.com/Orange-OpenSource/floss-toolbox/compare/2.21.0..2.20.0) - 2024-09-164

LICENSES/BSD-3-Clause.txt

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Copyright <YEAR> <COPYRIGHT HOLDER>
2+
3+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4+
5+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6+
7+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8+
9+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10+
11+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

THIRD-PARTY.md

+9
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ Copyright (c) 2009-2017 Wynn Netherland, Adam Stacoviak, Erik Michaels-Ober
2727
*octokit.rb* is distributed under the terms and conditions of the [MIT License](https://opensource.org/license/MIT).
2828
You may download the source code on the [following website](https://github.com/octokit/octokit.rb).
2929

30+
### python-dotenv
31+
32+
Version 1.0.1
33+
34+
Copyright (c) 2014, Saurabh Kumar (python-dotenv), 2013, Ted Tieken (django-dotenv-rw), 2013, Jacob Kaplan-Moss (django-dotenv)
35+
36+
*python-dotenv* is distributed under the terms and conditions of the [BSD 3-Clause License](https://opensource.org/license/BSD-3-clause).
37+
You may download the source code on the [following website](https://github.com/theskumar/python-dotenv).
38+
3039
### Ruby Git
3140

3241
Version 1.18.0

toolbox/github/README.md

+34-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Table of Contents
1919
* [Get repositories which seems to be empty or have not enough files](#get-repositories-which-seems-to-be-empty-or-have-not-enough-files)
2020
* [Define users permissions for all projects to "push"](#define-users-permissions-for-all-projects-to-push)
2121
* [Define teams permissions for all projects to "push"](#define-teams-permissions-for-all-projects-to-push)
22+
* [Make a year review of the GitHub organization](#make-a-year-review-of-the-github-organization)
2223
* [Play with GitHub CLI (GH)](#play-with-github-cli-gh)
2324
* [Prerequisites](#prerequisites-1)
2425
* [Prepare project](#prepare-project-1)
@@ -208,6 +209,38 @@ Permissions will be set to "read".
208209
bash GitHubWizard.sh set-teams-permissions-to-read
209210
```
210211

212+
### Make a year review of the GitHub organization
213+
214+
_Keywords: #organisation #GitHub #KPI #year #review_
215+
216+
You will need to define a *.env* file with the GitHub API token for key *GITHUB_API_TOKEN*, the organization name and some settings.
217+
Here the organization name is *Orange-OpenSource*, replace with your own and add the suitable token.
218+
219+
See for example:
220+
```text
221+
GITHUB_API_TOKEN=your-token
222+
ORGANIZATION_NAME=Orange-OpenSource
223+
TOP_N_PROG_LANG=5
224+
TOP_N_LEAST_PROG_LANG=5
225+
TOP_N_LICENSES=5
226+
TOP_N_CONTRIBUTORS_OVERALL=10
227+
TOP_N_CONTRIBUTORS_FOR_YEAR=10
228+
TOP_N_REPOS_MOST_COMMITS=5
229+
```
230+
231+
Run the following command to compute a year review of the organization
232+
233+
```shell
234+
# Do not forget to install dependencies
235+
pip install -r requirements.txt
236+
237+
# For year 2024
238+
python3.8 github-year-review.py --year 2024
239+
240+
# For year 20°24 and commits counts computing (can be time expansive)
241+
python3.8 github-year-review.py --year 2024 --count-commits
242+
```
243+
211244
# Play with GitHub CLI (GH)
212245

213246
## Prerequisites
@@ -304,4 +337,4 @@ brew install gitleaks
304337

305338
You need to define in the _configuration.rb_ files the Github organisation at **GITHUB_ORGANIZATION_NAME** and also your GitHub personal token at **GITHUB_PERSONAL_ACCESS_TOKEN**.
306339

307-
**You should also have your _git_ environment ready i.e. add your SSH private key if you clone by SSH for example. _gh_ must be installed, and _python3_ be ready. Obviously _gitleaks_ must be installed**
340+
**You should also have your _git_ environment ready i.e. add your SSH private key if you clone by SSH for example. _gh_ must be installed, and _python3_ be ready. Obviously _gitleaks_ must be installed**

toolbox/github/dry-run.sh

+5-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
# Since...............: 10/03/2023
1414
# Description.........: Make a dry-run of the github module to check if everything is ready to use
15-
# Version.............: 1.2.0
15+
# Version.............: 1.3.0
1616

1717
set -eu
1818

@@ -108,6 +108,10 @@ CheckIfFileExists "./utils/GitHubWrapper.rb"
108108
CheckIfFileExists "./utils/GitWrapper.rb"
109109
CheckIfFileExists "./utils/IO.rb"
110110

111+
CheckIfFileExists "./github-year-review.py"
112+
CheckIfFileExists "./requirements.txt"
113+
CheckIfFileExists "./.env" # Warning: not versioned but mandatory for Python script above
114+
111115
# Runtimes and tools
112116
# ------------------
113117

0 commit comments

Comments
 (0)