diff --git a/.github/workflows/metrics.yml b/.github/workflows/metrics.yml index 023677b..05c527a 100644 --- a/.github/workflows/metrics.yml +++ b/.github/workflows/metrics.yml @@ -13,7 +13,6 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 - - name: Criar diretório run: mkdir analytics-raw-data @@ -24,10 +23,10 @@ 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-GEROcuidado-Doc" doc - mkdir -p doc/analytics-raw-data - cp -R analytics-raw-data/*.json doc/analytics-raw-data - cd doc/ + git clone --single-branch --branch main "https://x-access-token:${{secrets.API_TOKEN_DOC}}@github.com/fga-eps-mds/2023-2-GEROcuidado-Doc" docs + mkdir -p docs/analytics-raw-data + cp -R analytics-raw-data/*.json docs/analytics-raw-data + cd docs/ git add . git commit -m "Adicionando métricas do repositório ${{ github.event.repository.name }} ${{ github.ref_name }}" git push diff --git a/parser.py b/parser.py new file mode 100644 index 0000000..3b7b495 --- /dev/null +++ b/parser.py @@ -0,0 +1,39 @@ +import json +import requests +import sys +from datetime import datetime + +TODAY = datetime.now() + +METRICS_SONAR = [ + "files", + "functions", + "complexity", + "comment_lines_density", + "duplicated_lines_density", + "coverage", + "ncloc", + "tests", + "test_errors", + "test_failures", + "test_execution_time", + "security_rating", +] + +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] + + response = requests.get( + f'{BASE_URL}{REPO}&metricKeys={",".join(METRICS_SONAR)}&ps=500' + ) + j = json.loads(response.text) + + file_path = f'./analytics-raw-data/fga-eps-mds-{REPO}-{TODAY.strftime("%m-%d-%Y-%H-%M-%S")}-{RELEASE_VERSION}.json' + + with open(file_path, "w") as fp: + fp.write(json.dumps(j)) + fp.close() diff --git a/sonar-project.properties b/sonar-project.properties index 1e259be..6202452 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -3,6 +3,7 @@ sonar.organization=fga-eps-mds-1 sonar.sources=./src +sonar.sources.exclusions=./e2e, /.vscode sonar.tests=./e2e