Skip to content

Commit d0aeec9

Browse files
committed
Initial commit
Signed-off-by: Santiago Dueñas <sduenas@bitergia.com>
0 parents  commit d0aeec9

28 files changed

Lines changed: 2812 additions & 0 deletions

.flake8

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[flake8]
2+
exclude = .git, .eggs, __pycache__, build, dist, docs, docker, migrations
3+
ignore = E129, E402, F841, W504 E128
4+
max-line-length = 130

.github/workflows/changelog.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Check changelog file included
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'sortinghat/**'
7+
8+
jobs:
9+
check-changelog:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: bitergia/release-tools-check-changelog@master

.github/workflows/release.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: release
2+
3+
on:
4+
push:
5+
tags:
6+
- '*.*.*'
7+
- '*.*.*-*'
8+
9+
jobs:
10+
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Build package using Poetry and store result
15+
uses: chaoss/grimoirelab-github-actions/build@master
16+
with:
17+
artifact-name: sh-eclipse-foundation-dist
18+
artifact-path: dist
19+
20+
tests:
21+
needs: [build]
22+
runs-on: ubuntu-latest
23+
services:
24+
mysql:
25+
image: mariadb:10.5
26+
env:
27+
MYSQL_ROOT_PASSWORD: root
28+
ports:
29+
- 3306:3306
30+
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
31+
32+
name: Python ${{ matrix.python-version }} for ES ${{ matrix.elasticsearch-version }}
33+
strategy:
34+
matrix:
35+
python-version: [3.9, 3.10, 3.11]
36+
37+
steps:
38+
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # 3.1.0
39+
40+
- name: Download distribution artifact
41+
uses: actions/download-artifact@fb598a63ae348fa914e94cd0ff38f362e927b741 # v3.0.0
42+
with:
43+
name: sh-eclipse-foundation-dist
44+
path: dist
45+
46+
- name: Set up Python ${{ matrix.python-version }}
47+
uses: actions/setup-python@13ae5bb136fac2878aff31522b9efb785519f984 # v4.3.0
48+
with:
49+
python-version: ${{ matrix.python-version }}
50+
51+
- name: Install dev dependencies
52+
run: |
53+
curl -sSL https://install.python-poetry.org | python3 -
54+
echo "PATH=$HOME/.poetry/bin:$PATH" >> $GITHUB_ENV
55+
poetry install --only dev
56+
57+
- name: Set MySQL mode
58+
env:
59+
DB_HOST: 127.0.0.1
60+
DB_PORT: ${{ job.services.mysql.ports[3306] }}
61+
run: |
62+
mysql --host $DB_HOST --port $DB_PORT -uroot -proot -e "SET GLOBAL sql_mode = 'NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'";
63+
64+
- name: Test package
65+
run: |
66+
PACKAGE=`(cd dist && ls *whl)` && echo $PACKAGE
67+
poetry run pip install --pre ./dist/$PACKAGE
68+
poetry run python manage.py test --settings=config.settings.testing
69+
70+
release:
71+
needs: [tests]
72+
runs-on: ubuntu-latest
73+
permissions:
74+
contents: write
75+
steps:
76+
- name: Create a new release on the repository
77+
uses: chaoss/grimoirelab-github-actions/release@master
78+
with:
79+
github-token: ${{ secrets.GITHUB_TOKEN }}
80+
81+
publish:
82+
needs: [tests]
83+
runs-on: ubuntu-latest
84+
steps:
85+
- name: Publish the package on PyPI
86+
uses: chaoss/grimoirelab-github-actions/publish@master
87+
with:
88+
artifact-name: sh-eclipse-foundation-dist
89+
artifact-path: dist
90+
pypi-api-token: ${{ secrets.PYPI_API_TOKEN }}

.github/workflows/tests.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: tests
2+
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
tags:
8+
- '!**'
9+
pull_request:
10+
branches:
11+
- '**'
12+
13+
jobs:
14+
15+
backend:
16+
17+
services:
18+
mysql:
19+
image: mariadb:10.5
20+
env:
21+
MYSQL_ROOT_PASSWORD: root
22+
ports:
23+
- 3306:3306
24+
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
25+
26+
strategy:
27+
matrix:
28+
python-version: [3.9, 3.10, 3.11]
29+
30+
runs-on: ubuntu-latest
31+
name: Python ${{ matrix.python-version }}
32+
steps:
33+
- name: Checkout
34+
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # 3.1.0
35+
- name: Set up Python ${{ matrix.python-version }}
36+
uses: actions/setup-python@13ae5bb136fac2878aff31522b9efb785519f984 # v4.3.0
37+
with:
38+
python-version: ${{ matrix.python-version }}
39+
- name: Install poetry
40+
run: |
41+
curl -sSL https://install.python-poetry.org | python3 -
42+
echo "PATH=$HOME/.poetry/bin:$PATH" >> $GITHUB_ENV
43+
- name: Install dependencies
44+
run: |
45+
poetry install -vvv
46+
poetry run pip install -r requirements_dev.txt
47+
- name: Set MySQL mode
48+
env:
49+
DB_HOST: 127.0.0.1
50+
DB_PORT: ${{ job.services.mysql.ports[3306] }}
51+
run: |
52+
mysql --host $DB_HOST --port $DB_PORT -uroot -proot -e "SET GLOBAL sql_mode = 'NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'";
53+
- name: Lint with flake8
54+
run: |
55+
poetry run flake8
56+
- name: Tests
57+
run: |
58+
poetry run python manage.py test --settings=config.settings.testing

.gitignore

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Python files
2+
*.pyc
3+
*.pyo
4+
build
5+
6+
# Local env files
7+
.env.local
8+
.env.*.local
9+
10+
# Log files
11+
npm-debug.log*
12+
yarn-debug.log*
13+
yarn-error.log*
14+
15+
# Editor directories and files
16+
.idea
17+
.vscode
18+
*.suo
19+
*.ntvs*
20+
*.njsproj
21+
*.sln
22+
*.sw?
23+
.project
24+
.pydevproject
25+
.settings
26+
27+
# Documentation
28+
.eggs/
29+
docs/_build/
30+
docs/source

AUTHORS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Jose Javier Merchante <jjmerchante@bitergia.com>
2+
Santiago Dueñas <sduenas@bitergia.com>
3+

README.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# sortinghat-eclipse-foundation
2+
3+
SortingHat backend to import identities from Eclipse Foundation
4+
5+
## Requirements
6+
7+
- Python >= 3.9
8+
9+
You will also need some other libraries for running the tool, you can find the
10+
whole list of dependencies in [pyproject.toml](pyproject.toml) file.
11+
12+
## Installation
13+
14+
There are several ways to install sortinghat-eclipse-foundation on your system: packages or source
15+
code using Poetry or pip.
16+
17+
### PyPI
18+
19+
sortinghat-eclipse-foundation can be installed using pip, a tool for installing Python packages.
20+
To do it, run the next command:
21+
```
22+
$ pip install sortinghat-eclipse-foundation
23+
```
24+
25+
### Source code
26+
27+
To install from the source code you will need to clone the repository first:
28+
```
29+
$ git clone https://github.com/bitergia-analytics/sortinghat-eclipse-foundation
30+
$ cd sortinghat-eclipse-foundation
31+
```
32+
33+
Then use pip or Poetry to install the package along with its dependencies.
34+
35+
#### Pip
36+
37+
To install the package from local directory run the following command:
38+
```
39+
$ pip install .
40+
```
41+
In case you are a developer, you should install sortinghat-eclipse-foundation in editable mode:
42+
```
43+
$ pip install -e .
44+
```
45+
46+
#### Poetry
47+
48+
We use [poetry](https://python-poetry.org/) for dependency management and
49+
packaging. You can install it following its [documentation](https://python-poetry.org/docs/#installation).
50+
Once you have installed it, you can install sortinghat-openinfra and the dependencies in
51+
a project isolated environment using:
52+
```
53+
$ poetry install
54+
```
55+
To spaw a new shell within the virtual environment use:
56+
```
57+
$ poetry shell
58+
```
59+
60+
## Usage
61+
62+
Install this SortingHat backend to import identities from the Eclipse Foundation.
63+
You can use this importer using the API or the UI. The name of the backend is
64+
`EclipseFoundation`. You will have to provide the credentials on the settings file
65+
in order to access the Eclipse Foundation API:
66+
67+
- `ECLIPSE_FOUNDATION_USER_ID`: username on the Eclipse Foundation platform.
68+
- `ECLIPSE_FOUNDATION_PASSWORD`: password for the previous user.
69+
70+
The user will also have the next permissions for reading the identities:
71+
72+
- `eclipsefdn_view_all_profiles`

config/__init__.py

Whitespace-only changes.

config/settings/__init__.py

Whitespace-only changes.

config/settings/testing.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
"""
2+
SortingHat configuration for testing
3+
"""
4+
5+
import logging
6+
import sys
7+
8+
# Graphene logs SortingHat exceptions and Django prints them
9+
# to the standard error output. This code prevents Django
10+
# kind of errors are not shown.
11+
if len(sys.argv) > 1 and sys.argv[1] == 'test':
12+
logging.disable(logging.CRITICAL)
13+
14+
15+
SILENCED_SYSTEM_CHECKS = ["django_mysql.E016"]
16+
17+
SECRET_KEY = 'fake-key'
18+
19+
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
20+
21+
INSTALLED_APPS = [
22+
'django.contrib.auth',
23+
'django.contrib.contenttypes',
24+
'graphene_django',
25+
'sortinghat.core',
26+
]
27+
28+
SQL_MODE = [
29+
'NO_ZERO_IN_DATE',
30+
'NO_ZERO_DATE',
31+
'ERROR_FOR_DIVISION_BY_ZERO',
32+
'NO_AUTO_CREATE_USER',
33+
'NO_ENGINE_SUBSTITUTION',
34+
]
35+
36+
DATABASES = {
37+
'default': {
38+
'ENGINE': 'django.db.backends.mysql',
39+
'USER': 'root',
40+
'PASSWORD': 'root',
41+
'NAME': 'sortinghat_db',
42+
'OPTIONS': {
43+
'charset': 'utf8mb4',
44+
'sql_mode': ','.join(SQL_MODE)
45+
},
46+
'TEST': {
47+
'NAME': 'testhat',
48+
'CHARSET': 'utf8mb4',
49+
'COLLATION': 'utf8mb4_unicode_520_ci',
50+
},
51+
'HOST': '127.0.0.1',
52+
'PORT': 3306
53+
}
54+
}
55+
56+
USE_TZ = True

0 commit comments

Comments
 (0)