Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

US001 E US004 #52

Closed
wants to merge 69 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
a686061
fix: sonar version and properties
leonardomilv3 Jul 10, 2024
de42840
Update README.md
AdneMoretti Jul 25, 2024
ac88c4d
Merge pull request #1 from fga-eps-mds/fix/sonar
leonardomilv3 Jul 25, 2024
037e30c
Feat: add norm diff command
thgomes Jul 27, 2024
837ed07
Chore: add parser to norm diff command
thgomes Jul 27, 2024
8aad936
feat: Adiciona comando diff
brenno-silva Jul 27, 2024
40d76f1
feat: Adiciona testes ao diff
brenno-silva Jul 28, 2024
9fc994e
fix: Ajusta linter
brenno-silva Jul 28, 2024
848e03e
BUG006 - Adição de parâmetro e tratamento de erros
MorettiGS Jul 28, 2024
12cf70a
Merge branch 'develop' of github.com:fga-eps-mds/2024.1-MeasureSoftGr…
MorettiGS Jul 28, 2024
c2a6c40
BUG006 Flake e correções de testes
MorettiGS Jul 28, 2024
ffcd3ce
Fix: adjust read planned file function name
thgomes Jul 28, 2024
a78a891
Test: add tests to test norm diff command
thgomes Jul 28, 2024
d3964dd
Fix: adjust lint of cmd norm diff files
thgomes Jul 29, 2024
9c9e39d
BUG006 - Correção de testes
MorettiGS Jul 29, 2024
74218e6
BUG006 - Corrigindo texto de informação do '-lb'
MorettiGS Jul 29, 2024
b5a3883
Merge pull request #4 from fga-eps-mds/thiago/feature/US004
thgomes Jul 29, 2024
6b03605
Merge branch 'develop' into feature/1-adiciona-diff
brenno-silva Jul 29, 2024
3df16b3
Merge pull request #2 from fga-eps-mds/feature/1-adiciona-diff
brenno-silva Jul 29, 2024
94fefd9
Merge branch 'develop' of github.com:fga-eps-mds/2024.1-MeasureSoftGr…
MorettiGS Jul 29, 2024
9346cf2
Merge pull request #3 from fga-eps-mds/BUG006
MorettiGS Jul 29, 2024
45a4fb9
BUG007 - Corrigir modo de consulta de workflows para CI_feedback_time
andremralves Jul 29, 2024
ae73071
Merge pull request #5 from fga-eps-mds/BUG007
andremralves Jul 29, 2024
f82114a
ENH002 - Tratamento do filtro por datas no CLI
MorettiGS Jul 30, 2024
53d9093
ENH002 - Adição de testes
MorettiGS Jul 31, 2024
97bb60a
Merge pull request #6 from fga-eps-mds/ENH002
AdneMoretti Aug 1, 2024
50af65a
Update default workflow
andremralves Aug 1, 2024
f8ba4e9
BUG008 - Inicio de implementação da separação do calculate
MorettiGS Aug 1, 2024
4b84edf
Merge pull request #7 from fga-eps-mds/BUG007-update
MorettiGS Aug 1, 2024
925cfb1
Fix workflow input type
andremralves Aug 2, 2024
8d0bd85
Update dependencies and project version to v3.2.0
andremralves Aug 2, 2024
0b5028c
Enable publish by tags
andremralves Aug 2, 2024
75d6663
bug(calculate): separação da agregação de métricas
MorettiGS Aug 2, 2024
08e747c
Update requirements.txt
andremralves Aug 2, 2024
845627b
bug(calculate_separado): alterando calculate para separação e corrigi…
MorettiGS Aug 2, 2024
89e4d29
Merge branch 'develop' of github.com:fga-eps-mds/2024.1-MeasureSoftGr…
MorettiGS Aug 2, 2024
3a9165c
Fix workflow flag
andremralves Aug 2, 2024
d764e2a
Update to v3.2.1
andremralves Aug 2, 2024
a7812e2
fix: add treatment to json files not found in extraction
thgomes Aug 15, 2024
935a561
feat: Altera import e export da diff
brenno-silva Aug 18, 2024
3e0dc97
fix: Ajusta testes
brenno-silva Aug 19, 2024
e3ab130
Merge branch 'develop' of github.com:fga-eps-mds/2024.1-MeasureSoftGr…
MorettiGS Aug 20, 2024
7c0d350
fix(bug/008): adaptação inicial à forma correta de separação
MorettiGS Aug 20, 2024
6d49cdd
fix(bug/008): completando separação do calculate entre github e sonar
MorettiGS Aug 20, 2024
e784442
tests(bug/008): testes de aggregate e novos arquivos
MorettiGS Aug 21, 2024
271403c
fix: adjust lint of cmd extract file
thgomes Aug 21, 2024
5e10551
refactor: rename norm_diff command
thgomes Aug 21, 2024
4955f1d
fix: adjust message of norm_diff
thgomes Aug 21, 2024
55751e5
refactor: change norm_diff parameter and help instructions
thgomes Aug 21, 2024
00419de
chore: add message to interpret norm diff value
thgomes Aug 21, 2024
833320c
chore: add treatment to invalid values in planned and developed files
thgomes Aug 21, 2024
a851667
test: add tests to verify treatment of values biggers than one in pla…
thgomes Aug 21, 2024
265dfe3
fix: verify values lower than zero either in norm diff values verific…
thgomes Aug 21, 2024
9c03c2f
tests(bug/008): testes para cálculo separado
MorettiGS Aug 21, 2024
5f74a92
tests(bug/008): ajuste de teste do tsqmi
MorettiGS Aug 21, 2024
a550495
fix(bug/008): Correções do -h para informações
MorettiGS Aug 21, 2024
2f78de9
fix(bug/008): correções de linter
MorettiGS Aug 21, 2024
6c5d071
fix(bug/008): pequenas refatorações
MorettiGS Aug 21, 2024
bf55065
fix/tests(bug/008): pequena correção de teste
MorettiGS Aug 21, 2024
3a543ca
Merge pull request #11 from fga-eps-mds/bug/008
AdneMoretti Aug 21, 2024
7ef50b3
fix: adjust lint
thgomes Aug 21, 2024
b8f376a
fix: adjust lint of tests
thgomes Aug 21, 2024
337615b
Merge branch 'develop' into feature/1-ajusta-diff
brenno-silva Aug 21, 2024
34c0f36
Merge pull request #10 from fga-eps-mds/thiago/refactor/US004
brenno-silva Aug 21, 2024
4c5f00a
Merge pull request #9 from fga-eps-mds/feature/1-ajusta-diff
brenno-silva Aug 21, 2024
47e382f
test: adjust test of json files not found in extract command
thgomes Aug 21, 2024
c9aa4df
Merge pull request #12 from fga-eps-mds/thiago/fix/BUG022
ciceroff Aug 21, 2024
b1c5cfb
feat: atualizando versões para deploy
MorettiGS Aug 21, 2024
b4d884e
fix: ajusta textos e validações da diff e norm_diff
brenno-silva Sep 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/metrics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
run: |
git config --global user.email "${{secrets.USER_EMAIL}}"
git config --global user.name "${{secrets.USER_NAME}}"
git clone --single-branch --branch main "https://x-access-token:${{secrets.API_TOKEN_DOC}}@github.com/fga-eps-mds/2023.2-MeasureSoftGram-DOC" doc
git clone --single-branch --branch main "https://x-access-token:${{secrets.API_TOKEN_DOC}}@github.com/fga-eps-mds/2024.1-MeasureSoftGram-DOC" doc
mkdir -p doc/analytics-raw-data
cp -R analytics-raw-data/*.json doc/analytics-raw-data
cd doc/
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ jobs:
run: python -m twine upload -u __token__ -p ${{ secrets.TEST_PYPI_API_TOKEN }} --repository testpypi dist/*

- name: Publish package on pypi
#if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
run: python -m twine upload -u __token__ -p ${{ secrets.PYPI_API_TOKEN }} dist/*
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ jobs:
run: tox

- name: Scanner do SonarCloud
uses: SonarSource/sonarcloud-github-action@v1.8
uses: SonarSource/sonarcloud-github-action@v2.3.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

- name: Envia cobertura para o Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4.0.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: ./
Expand Down
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ __pycache__/
venv/
ENV/
.tox
msgram-cli-venv
.python-version

# Distribution / packaging
.Python
Expand Down Expand Up @@ -46,3 +48,9 @@ analytics-raw-data/
**/*.log

setup.py

# Vim
*.swp

# ctags
tags
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# 2023-2 MeasureSoftGram-CLI

# 2024-1 MeasureSoftGram-CLI
Command line project to MeasureSoftGram
## Badges

[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=fga-eps-mds_2023-1-MeasureSoftGram-CLI&metric=code_smells)](https://sonarcloud.io/summary/new_code?id=fga-eps-mds_2023-1-MeasureSoftGram-CLI)
Expand Down
20 changes: 10 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "msgram"
version = "3.1.9"
version = "3.2.2"
description = "The msgram CLI is a command-line interface to use MeasureSoftGram software"
readme = "README.md"
authors = [
Expand All @@ -20,20 +20,20 @@ classifiers = [
"Topic :: Utilities",
]
keywords = ["core", "measures", "quality", "algebraic model"]
requires-python = ">=3.8"
requires-python = ">=3.9"
dependencies = [
"requests==2.28.1",
"requests~=2.32.3",
"pytz",
"typing~=3.7.4.3",
"tabulate==0.8.10",
"termcolor==1.1.0",
"pandas~=2.0.0",
"setuptools~=60.2.0",
"tabulate~=0.9.0",
"termcolor~=2.4.0",
"pandas~=2.2.2",
"setuptools~=72.1.0",
"python-dotenv",
"rich",
"validators==0.20.0",
"msgram-core==1.4.5",
"msgram-parser==1.1.3",
"validators~=0.33.0",
"msgram-core~=1.4.9",
"msgram-parser~=1.2.1",
"anytree"
]

Expand Down
16 changes: 8 additions & 8 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
###### Install local application in development mode. This will grab install_requires from setup.py.
-e .
requests~=2.28.1
pandas~=2.0.0
requests~=2.32.3
pandas~=2.2.0
typing~=3.7.4.3
tabulate~=0.8.10
tabulate~=0.9.0
pytz~=2022.2.1
termcolor~=1.1.0
setuptools~=60.2.0
termcolor~=2.4.0
setuptools~=72.1.0
python-dotenv
rich
validators==0.20.0
msgram-core==1.4.5
msgram-parser==1.1.3
validators==0.33.0
msgram-core~=1.4.9
msgram-parser~=1.2.1
anytree
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sonar.projectKey=fga-eps-mds_2023-2-MeasureSoftGram-CLI
sonar.projectKey=fga-eps-mds_2024.1-MeasureSoftGram-CLI
sonar.organization=fga-eps-mds-1

sonar.python.version=3
Expand Down
142 changes: 30 additions & 112 deletions src/cli/aggregate_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
]

measures = {}
measures["sonar"] = [
measures["sonarqube"] = [
"passed_tests",
"test_builds",
"test_errors",
Expand All @@ -37,22 +37,16 @@
measures["github"] = ["team_throughput", "ci_feedback_time"]


def should_process_sonar_metrics(config):
def should_process_metrics(config):
for characteristic in config.get("characteristics", []):
for subcharacteristic in characteristic.get("subcharacteristics", []):
for measure in subcharacteristic.get("measures", []):
if measure.get("key") in measures["sonar"]:
return True
return False


def should_process_github_metrics(config):
for characteristic in config.get("characteristics", []):
for subcharacteristic in characteristic.get("subcharacteristics", []):
for measure in subcharacteristic.get("measures", []):
if measure.get("key") in measures["github"]:
return True
return False
if (
measure.get("key") not in measures["sonarqube"]
and measure.get("key") not in measures["github"]
):
return False
return True


def read_msgram(file_path):
Expand Down Expand Up @@ -96,134 +90,58 @@ def save_metrics(file_name, metrics):
print_info(f"> [blue] Metrics saved to: {output_file_path}\n")


def process_sonar_metrics(folder_path, msgram_files, github_files):
def process_metrics(folder_path, msgram_files):
processed_files = []

for file in msgram_files:
if file not in github_files:
print_info(f"> [blue] Processing {file}")
sonar_metrics_dict = read_msgram(os.path.join(folder_path, file))
print_info(f"> [blue] Processing {file}")
metrics_dict = read_msgram(os.path.join(folder_path, file))

if not sonar_metrics_dict:
print_error(f"> [red] Error to read sonar metrics in: {folder_path}\n")
return False
if not metrics_dict:
print_error(f"> [red] Error to read metrics in: {folder_path}\n")
return False

processed_files.append((file, sonar_metrics_dict))
processed_files.append((file, metrics_dict))

return processed_files


def process_github_metrics(folder_path, github_files, metrics):
if not github_files:
print_error(f"> [red] GitHub files not found in the directory: {folder_path}\n")
return False

print_info(f"> [blue] GitHub metrics found in: {folder_path}\n")

github_metrics_list = []

for github_file_name in github_files:
github_file_path = os.path.join(folder_path, github_file_name)
github_file_content = read_msgram(github_file_path)

if not github_file_content:
print_error(f"> [red] Error to read github metrics in: {github_file_path}\n")
continue

github_key = next(iter(github_file_content.keys() - metrics["sonar"]), "")

github_metrics = [
{
"metric": metric,
"value": next(
(
m["value"]
for m in github_file_content[github_key]
if m["metric"] == metric
),
None,
),
}
for metric in metrics["github"]
]

github_metrics_list.append((github_file_name, github_metrics))

return github_metrics_list


def find_common_part(sonar_filename, github_result):
sonar_filename_root, _ = os.path.splitext(sonar_filename)

sonar_parts = sonar_filename_root.split('-')
if len(sonar_parts) >= 7:
sonar_key = '-'.join(sonar_parts[:7])

for github_filename, github_metrics in github_result:
github_filename_root, _ = os.path.splitext(github_filename)

if sonar_key in github_filename_root:
return github_metrics

return False


def aggregate_metrics(folder_path, config: json):
def aggregate_metrics(input_format, folder_path, config: json):
msgram_files = list_msgram_files(folder_path)

if not msgram_files:
print_error("> [red]Error: Can not read msgram files in provided directory")
return False

github_files = [file for file in msgram_files if file.startswith("github_")]

sonar_files = [file for file in msgram_files if file not in github_files]
file_content = {}

sonar_result = []
github_result = []
result = []

have_metrics = False

config_has_github = should_process_github_metrics(config)

if config_has_github:
github_result = process_github_metrics(
folder_path, github_files, metrics
if should_process_metrics(config):
result = process_metrics(
folder_path, github_files if input_format == "github" else sonar_files
)

if not github_result:
if not result:
print_error("> [red]Error: Unexpected result from process_github_metrics")
return False

have_metrics = True

if should_process_sonar_metrics(config):
sonar_result = process_sonar_metrics(folder_path, msgram_files, github_files)

if not sonar_result:
print_error("> [red]Error: Unexpected result from process_sonar_metrics")
return False

have_metrics = True
else:
print_error("> [red]Error: Unexpected measures from should_process_metrics")
return False

if not have_metrics:
print_error("> [red]Error: No metrics where found in the .msgram files")
print_error(
f"> [red]Error: No metrics where found in the .msgram files from the type: {input_format}"
)
return False

for sonar_filename, file_content in sonar_result:
github_metrics = find_common_part(sonar_filename, github_result)

if github_metrics:
file_content["github_metrics"] = github_metrics
elif config_has_github:
print_error(
f"> [red]Error: The configuration provided by the user requires github metrics\n"
f" but there was not found github metrics associated with the file:\n"
f" {sonar_filename}"
)

return False

save_metrics(os.path.join(folder_path, sonar_filename), file_content)
for filename, file_content in result:
save_metrics(os.path.join(folder_path, filename), file_content)

return True
1 change: 1 addition & 0 deletions src/cli/commands/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from src.cli.commands.cmd_init import command_init
from src.cli.commands.cmd_extract import command_extract
from src.cli.commands.cmd_calculate import command_calculate
from src.cli.commands.cmd_norm_diff import command_norm_diff
Loading
Loading