From aa28b602186e5b2d75719d1b3cba21c82bd8afa2 Mon Sep 17 00:00:00 2001 From: Rafael Ortega Bueno Date: Tue, 3 Sep 2024 21:05:38 -0300 Subject: [PATCH] chore: update GitHub workflows to integrate Sonar; refactor tests and security workflows --- .github/workflows/coordinate.yml | 21 +++++++++++++++++++++ .github/workflows/infosec.yml | 23 ++++++++++++----------- .github/workflows/sonar.yml | 24 ------------------------ .github/workflows/tests.yml | 25 +++++++++++++++++++++---- README.md | 1 + 5 files changed, 55 insertions(+), 39 deletions(-) create mode 100644 .github/workflows/coordinate.yml delete mode 100644 .github/workflows/sonar.yml diff --git a/.github/workflows/coordinate.yml b/.github/workflows/coordinate.yml new file mode 100644 index 0000000..8b72969 --- /dev/null +++ b/.github/workflows/coordinate.yml @@ -0,0 +1,21 @@ +name: Coordinate Workflows +on: + push: + branches: + - production + - staging + pull_request: + types: [opened, synchronize, reopened] +jobs: + quality-assurance: + uses: ./.github/workflows/tests.yml + with: + coverage-path: coverage/lcov.info + + information-security: + needs: quality-assurance + name: information-security + uses: ./.github/workflows/infosec.yml + with: + coverage-path: coverage/lcov.info + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/infosec.yml b/.github/workflows/infosec.yml index 7ff200a..1bf9367 100644 --- a/.github/workflows/infosec.yml +++ b/.github/workflows/infosec.yml @@ -1,15 +1,16 @@ -name: Application security +name: Information Security Workflow on: - push: - branches: - - production - - master - - main - pull_request: - types: [opened, synchronize, reopened] + workflow_call: + inputs: + coverage-path: + required: false + type: string jobs: - scans: - uses: madeiramadeirabr/private_action-information-security-validators/.github/workflows/main.yml@production - secrets: inherit \ No newline at end of file + application-security: + name: actions + uses: madeiramadeirabr/private_action-information-security-validators/.github/workflows/main.yml@development + with: + coverage-path: ${{ inputs.coverage-path }} + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/sonar.yml b/.github/workflows/sonar.yml deleted file mode 100644 index 694256d..0000000 --- a/.github/workflows/sonar.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: Execute the SonarCloud Quality Gateway Analisys -on: - push: - branches: - - production - pull_request: - types: [opened, synchronize, reopened] -jobs: - sonarcloud: - name: SonarCloud - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: Install dependencies - run: npm install - - name: Test and coverage - run: npm run test:coverage - - name: SonarCloud Scan - uses: SonarSource/sonarcloud-github-action@master - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ce285e1..d4acc85 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,7 +1,11 @@ +name: Run tests on pull_request + on: - pull_request: - branches: - - "production" + workflow_call: + inputs: + coverage-path: + required: false + type: string jobs: unit-tests: @@ -24,4 +28,17 @@ jobs: run: npm run build - name: Run tests - run: npm run test:coverage \ No newline at end of file + run: npm run test:coverage + + - name: Upload coverage + uses: actions/upload-artifact@v4 + with: + name: coverage-report + path: ${{ inputs.coverage-path }} + + - name: Check test status + run: | + if [ ${{ job.status }} -ne 0 ]; then + echo "Tests failed. Can't merge." + exit 1 + fi \ No newline at end of file diff --git a/README.md b/README.md index 659f2de..14b791f 100644 --- a/README.md +++ b/README.md @@ -20,4 +20,5 @@ Aberto para qualquer equipe atualizar e implementar funcionalidades - [Documentação técnica](./docs/README.md) - [Instalação](./docs/instalacao.md) - [Como utilizar](./docs/uso.md) + - [Como usar o padrão de eventos MMRFC 5](./docs/standard-events.md) - [Executando os testes](./docs/tests.md)