Skip to content

How to run grimoirelab gitee?

Chenqi Shan edited this page Sep 16, 2022 · 12 revisions

Getting started

There are different options to run grimoirelab-gitee, considerring that our first coming users would be developers(just a guess...), so let's start with Source code and docker-compose.

Some hints would be highlighted here to reduce expected/possible troubles during the installations(because I met them before :)), but some steps might be missied in the first few versions. When you met problems, just pop up issues and we will help you.

Run with source code and docker-compose

(verified by ubuntu18.04, with root user)

By this option, ElasticSearch, Kibiter and MariaDB would be installed by docker-compose as the infrastructure. For the rest of the other grimoirelab related modules, they would be installed using the source code with help of build_grimoirelab.

1. Set enough virtual memory to secure ElasiticSearch up(reference):

  • option 1: sysctl -w vm.max_map_count=262144 that is only valid for current session.
  • option 2: update vm.max_map_count setting in /etc/sysctl.conf.

2. Run docker-compose

Please choose one docker-compose according to your actual situation.

2a. Run docker-compose(ElasticSearch & MariaDB & Hatstallreference):

If you haven't installed docker-compose, it is time to do it before next step(https://docs.docker.com/compose/install/)

$ cd /root
$ git clone https://github.com/open-metrics-code/grimoirelab.git
$ cd grimoirelab/docker-compose
$ docker-compose -f docker-compose-elk-gitee.yml up -d

You can check if ElasticSearch and Kibiter was up by check

http://localhost:5601/

You can check if MariaDB was up by:

$ docker exec -it docker-compose_mariadb_1 bash
$ mysql -u root -proot -e 'SHOW DATABASES;'

2b. Run docker-compose(Opensearch & MariaDB & Hatstall):

$ cd /root
$ git clone https://github.com/open-metrics-code/grimoirelab.git
$ cd grimoirelab/docker-compose
$ docker-compose -f docker-compose-opensearch-gitee.yml up -d

2c. Run docker-compose(MariaDB & Hatstall):

If you have already finished OpenSearch or ElasticSearch local installation, you could also run mariadb&hatstall docker only.

$ cd /root
$ git clone https://github.com/open-metrics-code/grimoirelab.git
$ cd grimoirelab/docker-compose
$ docker-compose -f docker-compose-mariadb-hatstall.yml up -d

3. Build source code(reference)

Build all modules by the latest release of GrimoireLab:

$ cd ~/grimoirelab/utils
$ ./build_grimoirelab -l debug --logfile /root/tmp/log --build --install --check \
  --relfile ../releases/latest --reposdir /root/repos \
 --install_venv /root/ivenv

4. Install Gitee modules

Tips:

  • We would use python develp mode, to allow you to conveniently modify your code after it’s installed to the (virtual) environment, and have the changes take effect immediately.
  • Tips: sudo or root user would avoid some unexpected cases happened, like modules cannot be installed successfully.
  1. Activate virtual environment:
$ source ~/ivenv/bin/activate
  1. Install perceval-gitee:
$ cd /root/repos
$ git clone https://github.com/chaoss/grimoirelab-perceval-gitee.git
$ cd grimoirelab-perceval-gitee
$ python3 setup.py develop

You could check if perceval-gitee was intalled seccessfully by pip3 list:

perceval-gitee      0.1.0     /root/repos/grimoirelab-perceval-gitee
  1. Install grimoire-elk-gitee:
$ cd /root/repos
$ git clone https://github.com/chaoss/grimoirelab-elk-gitee.git
$ cd grimoirelab-elk-gitee
$ python3 setup.py develop

You could check if perceval-gitee was intalled seccessfully by pip3 list:

grimoire-elk-gitee  0.1.0     /root/repos_grimoirelab/grimoirelab-elk-gitee
  1. Replace grimoire-elk with new one: (to support backend plugin solution, you can find related discussion here)
$ pip3 uninstall grimoire-elk
$ rm -rf /root/repos/grimoire-elk
$ cd /root/repos/grimoireelk
$ python3 setup.py develop

You could check if grimoire-elk was intalled seccessfully by pip3 list:

grimoire-elk        0.86.0    /root/repos_grimoirelab/grimoireelk

5. Run Grimoirelab

Tips: you need to configure your projects file and setup-gitee.cfg file before running it.

$ cd /root/grimoirelab/default-grimoirelab-settings/
$ sirmordred -c setup-gitee.cfg

6. How to debug for Grimoirelab-gitee

Python file micro.py is the entrance of sirmordred. You could change --enrich to --raw to run the collection phases.

You could also change gitee:repo to gitee:issue or gitee:pull to fetch data from issues or prs.

$ cd /root/repos-new/sirmordred/sirmordred/utils/
$ python micro.py --enrich --debug --cfg ./setup.cfg --backends gitee:repo  --logs-dir 

If you use vscode to debug the code, following is an example for .vscode/launch.json.

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "justMyCode": false,
            "cwd": "${fileDirname}",
            "args": [
                "--enrich",
                "--debug",
                "--cfg",
                "/root/grimoirelab/default-grimoirelab-settings/setup-gitee.cfg",
                "--backends",
                "gitee:repo",
                "--logs-dir",
                "logs"]
        }
    ]
}