Skip to content

Commit

Permalink
Merge pull request fga-eps-mds#39 from fga-eps-mds/develop
Browse files Browse the repository at this point in the history
Sincronização dos repositórios 2023-2
  • Loading branch information
RcleydsonR authored Mar 27, 2024
2 parents 57f0643 + db93e4f commit d544bb8
Show file tree
Hide file tree
Showing 23 changed files with 938 additions and 491 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Build
on:
push:
branches:
- develop
pull_request:
types: [opened, synchronize, reopened]
jobs:
sonarcloud:
name: SonarCloud
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
3 changes: 2 additions & 1 deletion .github/workflows/metrics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches: [main, develop]
tags:
- "v*"
workflow_dispatch:

jobs:
release:
Expand All @@ -24,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-1-MeasureSoftGram-Doc" doc
git clone --single-branch --branch main "https://x-access-token:${{secrets.API_TOKEN_DOC}}@github.com/fga-eps-mds/2023.2-MeasureSoftGram-DOC" doc
mkdir -p doc/analytics-raw-data
cp -R analytics-raw-data/*.json doc/analytics-raw-data
cd doc
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/msgram-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: MSG Action
on:
pull_request:
branches: [ develop ]
types: [opened, closed, reopened, synchronize]
workflow_dispatch:
jobs:
msgram_job:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: 2023.2 Action MeasureSoftGram
uses: fga-eps-mds/[email protected]
id: msgram
with:
githubToken: ${{ secrets.GITHUB_TOKEN }} # Token do GitHub
sonarProjectKey: "fga-eps-mds_2023-2-MeasureSoftGram-Core" # (opcional) Chave do projeto no SonarQube
msgramServiceToken: ${{ secrets.MSGRAM_SERVICE_TOKEN }} # Token para acessar o serviço MeasureSoftGram
productName: "MeasureSoftGram" # Nome do produto
3 changes: 2 additions & 1 deletion .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches: [ develop ]
tags:
- "v*"
workflow_dispatch:

jobs:
deploy:
Expand Down Expand Up @@ -32,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/*
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 2023-1-MeasureSoftGram-Core
# 2023-2 MeasureSoftGram-Core

## Badges

Expand Down
1 change: 0 additions & 1 deletion parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
BASE_URL = "https://sonarcloud.io/api/measures/component_tree?component=fga-eps-mds_"

if __name__ == "__main__":

REPO = sys.argv[1]
RELEASE_VERSION = sys.argv[2]

Expand Down
2 changes: 1 addition & 1 deletion 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_core"
version = "1.3.3"
version = "1.4.5"
description = "The MeasureSoftGram-Core is a Software system for continuous quality of product observation and multidimensional use in continuous design engineering software and is where you have the innovative mathematical models for software analysis."
readme = "README.md"
authors = [
Expand Down
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-1-MeasureSoftGram-Core
sonar.projectKey=fga-eps-mds_2023-2-MeasureSoftGram-Core
sonar.organization=fga-eps-mds-1

sonar.python.version=3
Expand Down
104 changes: 98 additions & 6 deletions src/core/aggregated_normalized_measures.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ def non_complex_files_density(

files_in_thresholds_bool_index = complex_files_density <= max_threshold
files_functions_gt_zero_bool_index = files_functions > 0
x = complex_files_density[files_in_thresholds_bool_index * files_functions_gt_zero_bool_index]
x = complex_files_density[
files_in_thresholds_bool_index * files_functions_gt_zero_bool_index
]

interpretation_function_value = transformations.interpretation_function(
x=x,
Expand All @@ -60,7 +62,9 @@ def non_complex_files_density(
return aggregated_and_normalized_measure


def commented_files_density(data_frame, min_threshold: float = 10, max_threshold: float = 30):
def commented_files_density(
data_frame, min_threshold: float = 10, max_threshold: float = 30
):
"""
Calculates commented files density.
Expand Down Expand Up @@ -104,7 +108,9 @@ def commented_files_density(data_frame, min_threshold: float = 10, max_threshold
return aggregated_and_normalized_measure


def absence_of_duplications(data_frame, min_threshold: float = 0, max_threshold: float = 5.0):
def absence_of_duplications(
data_frame, min_threshold: float = 0, max_threshold: float = 5.0
):
"""
Calculates duplicated files absence (em3).
Expand All @@ -113,7 +119,9 @@ def absence_of_duplications(data_frame, min_threshold: float = 0, max_threshold:
"""
files_duplicated_lines_density = data_frame["duplicated_lines_density"] # m5 metric

Checker.check_metric_values(files_duplicated_lines_density, "duplicated_lines_density")
Checker.check_metric_values(
files_duplicated_lines_density, "duplicated_lines_density"
)

if len(files_duplicated_lines_density) == 0:
return 0.0
Expand Down Expand Up @@ -177,7 +185,9 @@ def test_coverage(
return aggregated_and_normalized_measure


def fast_test_builds(data_frame, min_threshold: float = 0, max_threshold: float = 300000):
def fast_test_builds(
data_frame, min_threshold: float = 0, max_threshold: float = 300000
):
"""
Calculates fast test builds (em5)
This function gets the dataframe metrics
Expand Down Expand Up @@ -256,6 +266,88 @@ def passed_tests(data_frame, min_threshold: float = 0, max_threshold: float = 1)
gain_interpretation=1,
)

aggregated_and_normalized_measure = transformations.calculate_measure(interpretation_function_value)
aggregated_and_normalized_measure = transformations.calculate_measure(
interpretation_function_value
)

return aggregated_and_normalized_measure


def team_throughput(
data_frame,
min_threshold: float = 45,
max_threshold: float = 100,
):
"""
Calculates team throughput (em7).
This function gets the dataframe metrics
and returns the team throughput measure (em7).
"""
total_issues = data_frame["total_issues"]
resolved_issues = data_frame["resolved_issues"]

Checker.check_metric_value(total_issues, "total_issues")
Checker.check_metric_value(resolved_issues, "resolved_issues")

Checker.check_threshold(min_threshold, max_threshold, "team_throughput")

team_throughput_value = ems_functions.get_team_throughput(
data={
"total_issues": int(total_issues),
"resolved_issues": int(resolved_issues),
}
)

interpretation_function_value = transformations.interpretation_function(
x=team_throughput_value,
min_threshold=min_threshold,
max_threshold=max_threshold,
gain_interpretation=1,
)

aggregated_and_normalized_measure = transformations.calculate_measure(
interpretation_function_value
)

return aggregated_and_normalized_measure


def ci_feedback_time(
data_frame,
min_threshold: float = 1,
max_threshold: float = 900,
):
"""
Calculates CI Feedback Time (em8).
This function gets the dataframe metrics
and returns the CI Feedback Time (em8).
"""
total_builds = data_frame["total_builds"]
sum_ci_feedback_times = data_frame["sum_ci_feedback_times"]

Checker.check_metric_value(total_builds, "total_builds")
Checker.check_metric_value(sum_ci_feedback_times, "sum_ci_feedback_times")

Checker.check_threshold(min_threshold, max_threshold, "ci_feedback_time")

ci_feedback_time_value = ems_functions.get_ci_feedback_time(
data={
"total_builds": int(total_builds),
"sum_ci_feedback_times": int(sum_ci_feedback_times),
}
)

interpretation_function_value = transformations.interpretation_function(
x=ci_feedback_time_value,
min_threshold=min_threshold,
max_threshold=max_threshold,
gain_interpretation=1,
)

aggregated_and_normalized_measure = transformations.calculate_measure(
interpretation_function_value
)

return aggregated_and_normalized_measure
38 changes: 21 additions & 17 deletions src/core/measures_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,25 +183,29 @@ def get_test_coverage(data: dict):
return coverage, number_of_files


# def calculate_em7(data: dict):
# """
# Calculates team throughput (em7).
def get_team_throughput(data: dict[str, int]):
"""
Calculates team throughput (em7)
This function calculates the team throughput measure (em7)
used to assess the testing status sub characteristic.
"""

total_issues = data["total_issues"]
resolved_issues = data["resolved_issues"]

# This function calculates the team throughput measure (em7)
# used to assess the functional completeness subcharacteristic.
# """
# resolved_issues_with_us_label = data[
# "number_of_resolved_issues_with_US_label_in_the_last_x_days"
# ]
return 100 * (resolved_issues / total_issues)

# total_issues_with_us_label = data[
# "total_number_of_issues_with_US_label_in_the_last_x_days"
# ]

# x, y = create_coordinate_pair(0, 1, reverse_y=True)
def get_ci_feedback_time(data: dict[str, int]):
"""
Calculates CI Feedback Time (em8)
This function calculates the CI Feedback Time measure (em8)
used to assess the testing status sub characteristic.
"""

# if7 = np.divide(resolved_issues_with_us_label, total_issues_with_us_label)
total_builds = data["total_builds"]
sum_ci_feedback_times = data["sum_ci_feedback_times"]

# if np.isnan(if7) or np.isinf(if7):
# return 0
# return np.interp(if7, x, y)
return sum_ci_feedback_times // total_builds
Loading

0 comments on commit d544bb8

Please sign in to comment.