From 2ac42b4b55b1bf27fabf4e5121b284bae30ee476 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Gon=C3=A7alves?= Date: Sun, 4 Aug 2024 10:45:24 -0300 Subject: [PATCH] chore: adapt actions --- .github/workflows/build.yml | 27 ++++++++++++------------ .github/workflows/deploy.yml | 4 ++-- .github/workflows/metrics.yml | 4 ++-- .github/workflows/sonar_teste.yml | 34 ------------------------------- docker-compose.prod.yml | 2 +- parser.py | 14 ++++++++----- sonar-project.properties | 4 ++-- 7 files changed, 30 insertions(+), 59 deletions(-) delete mode 100644 .github/workflows/sonar_teste.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 090a6c5..5812e06 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,10 +4,9 @@ on: branches: - main - develop - - sonar/teste - - release-sonar + - master pull_request: - types: [opened, synchronize, reopened] + types: [opened, synchronize, reopened, closed] jobs: test-unit: name: Test Unit & Scan @@ -21,7 +20,7 @@ jobs: - name: Test Unit id: test-unit run: | - docker-compose -f docker-compose.test.yml up -V --force-recreate --build --abort-on-container-exit --exit-code-from gerocuidado-forum-api-test + docker compose -f docker-compose.test.yml up -V --force-recreate --build --abort-on-container-exit --exit-code-from gerocuidado-forum-api-test env: TEST: unit @@ -31,14 +30,16 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - - name: Sincroniza cobertura de testes com o Codecov - uses: codecov/codecov-action@v3 - with: - token: ${{ secrets.CODECOV_TOKEN }} - fail_ci_if_error: true - flags: jest - name: 2023-2-GEROcuidado-APIForum - verbose: true + # TODO: Check if this is really necessary + # + # - name: Sincroniza cobertura de testes com o Codecov + # uses: codecov/codecov-action@v3 + # with: + # token: ${{ secrets.CODECOV_TOKEN }} + # fail_ci_if_error: true + # flags: jest + # name: 2023-2-GEROcuidado-APIForum + # verbose: true test-e2e: name: Test E2E @@ -52,6 +53,6 @@ jobs: - name: Test E2E id: test-e2e run: | - docker-compose -f docker-compose.test.yml up -V --force-recreate --build --abort-on-container-exit --exit-code-from gerocuidado-forum-api-test + docker compose -f docker-compose.test.yml up -V --force-recreate --build --abort-on-container-exit --exit-code-from gerocuidado-forum-api-test env: TEST: e2e diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index c82e281..bbb6f59 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -19,7 +19,7 @@ jobs: - name: Sending Image to Docker Hub uses: mr-smithers-excellent/docker-build-push@v5 with: - image: gerocuidadodev/gerocuidado-forum-api + image: victorjorge/gerocuidado-forum-api registry: docker.io directory: ./ dockerfile: ./Dockerfile.prod @@ -44,4 +44,4 @@ jobs: script: | cd ${{env.TARGET_DIR}} sudo git pull - sudo docker compose -f docker-compose.prod.yml up --force-recreate --build --pull --remove-orphans -d + sudo docker compose -f docker-compose.prod.yml up --force-recreate --build --pull always --remove-orphans -d diff --git a/.github/workflows/metrics.yml b/.github/workflows/metrics.yml index 05c527a..927b5be 100644 --- a/.github/workflows/metrics.yml +++ b/.github/workflows/metrics.yml @@ -17,13 +17,13 @@ jobs: run: mkdir analytics-raw-data - name: Coletar métricas no SonarCloud - run: python parser.py ${{ github.event.repository.name }} ${{ github.ref_name }} + run: python parser.py fga-eps-mds-1_2024-1-gerocuidado-apiforum ${{ github.ref_name }} ${{ github.event.repository.name }} - name: Envia métricas para repo de Doc 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" docs + git clone --single-branch --branch main "https://x-access-token:${{secrets.API_TOKEN_DOC}}@github.com/fga-eps-mds/2024-1-GEROcuidado-Doc" docs mkdir -p docs/analytics-raw-data cp -R analytics-raw-data/*.json docs/analytics-raw-data cd docs/ diff --git a/.github/workflows/sonar_teste.yml b/.github/workflows/sonar_teste.yml deleted file mode 100644 index 9025523..0000000 --- a/.github/workflows/sonar_teste.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Análise de Código -on: - push: - branches: - - main - - test/sonarcloud - pull_request: - # types: [opened, synchronize, reopened] - branches: - - main -jobs: - sonarcloud: - name: SonarCloud - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Instala dependências - run: yarn - - - name: Executa linter - run: yarn lint - - - name: Executa testes e gera cobertura - run: yarn test:all - - - name: Executa SonarCloud Scan - if: ${{ always() }} - uses: SonarSource/sonarcloud-github-action@master - env: - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} - SONAR_TOKEN: ${{secrets.SONAR_TOKEN}} diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 5368ada..fad7432 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -1,7 +1,7 @@ version: '3.7' services: gerocuidado-forum-api-prod: - image: gerocuidadodev/gerocuidado-forum-api:latest + image: victorjorge/gerocuidado-forum-api:latest container_name: gerocuidado-forum-api-prod environment: - DB_HOST=gerocuidado-forum-db diff --git a/parser.py b/parser.py index 97abe05..a48d63a 100644 --- a/parser.py +++ b/parser.py @@ -23,18 +23,22 @@ "security_rating", ] -BASE_URL = "https://sonarcloud.io/api/measures/component_tree?component=fga-eps-mds_" +BASE_URL = "https://sonarcloud.io/api/measures/component_tree?component=" if __name__ == "__main__": - REPO = sys.argv[1] - RELEASE_VERSION = sys.argv[2] + REPO_COMPONENT_KEY = sys.argv[1] + RELEASE_VERSION = sys.argv[2].replace('/', '') + REPO = sys.argv[3] response = requests.get( - f'{BASE_URL}{REPO}&metricKeys={",".join(METRICS_SONAR)}&ps=500' + f'{BASE_URL}{REPO_COMPONENT_KEY}&metricKeys={",".join(METRICS_SONAR)}&ps=500' ) + + print(response.text) + 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: diff --git a/sonar-project.properties b/sonar-project.properties index 59f9b56..addf871 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,6 +1,6 @@ -sonar.projectKey=fga-eps-mds_2023-2-GEROcuidado-APIForum +sonar.projectKey=fga-eps-mds-1_2024-1-gerocuidado-apiforum sonar.organization=fga-eps-mds-1 -sonar.projectName=2023-2-GEROcuidado-APIForum +sonar.projectName=2024-1-GEROcuidado-APIForum sonar.host.url=https://sonarcloud.io