From d921287e612a9086b3b97e75a7c086c64734866d Mon Sep 17 00:00:00 2001 From: Gonzalo Diaz Date: Mon, 18 Aug 2025 15:32:26 -0400 Subject: [PATCH] [REFACTOR] [Github Actions] codecov and sonarcloud now runs in parallel --- .github/workflows/node-coverage.js.yml | 58 +++++++++++++++++++++----- 1 file changed, 48 insertions(+), 10 deletions(-) diff --git a/.github/workflows/node-coverage.js.yml b/.github/workflows/node-coverage.js.yml index 05b54abb..0d71b0f7 100644 --- a/.github/workflows/node-coverage.js.yml +++ b/.github/workflows/node-coverage.js.yml @@ -1,19 +1,18 @@ --- - name: Node.js CI Coverage on: # yamllint disable-line rule:truthy push: branches: ["main"] pull_request: - # The branches below must be a subset of the branches above branches: ["main"] workflow_dispatch: jobs: - coverage: - name: NodeJS CI Coverage + build-and-test: + name: Build, Lint & Test runs-on: ubuntu-24.04 + steps: - name: Checkout repository uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 @@ -23,23 +22,62 @@ jobs: - name: Set up Node.js uses: actions/setup-node@v4 with: - node-version: 22.x + node-version: 24.x - name: Install dependencies run: npm ci --verbose + - name: Lint + run: npm run lint + - name: Run the tests run: npm run jest:ci -- --coverage - - name: Upload coverage reports to Codecov with GitHub Action + # Subir cobertura como artifact para que otros jobs lo usen + - name: Upload coverage artifact + uses: actions/upload-artifact@v4 + with: + name: coverage-report + path: coverage # o la carpeta donde jest genera los reportes + + + codecov: + name: Upload to Codecov + runs-on: ubuntu-24.04 + needs: build-and-test + + steps: + - name: Download coverage artifact + uses: actions/download-artifact@v4 + with: + name: coverage-report + path: coverage + + - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v5 with: - token: ${{ secrets.CODECOV_TOKEN }} # required - verbose: true # optional (default = false) + token: ${{ secrets.CODECOV_TOKEN }} + verbose: true + + sonarqube: + name: Analyze with SonarQube + runs-on: ubuntu-24.04 + needs: build-and-test + + steps: + - name: Checkout repository + uses: actions/checkout@v5 + with: + fetch-depth: 0 + + - name: Download coverage artifact + uses: actions/download-artifact@v4 + with: + name: coverage-report + path: coverage - - name: Analyze with SonarQube / SonarCloud + - name: SonarQube Scan uses: SonarSource/sonarqube-scan-action@master env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - # Needed to get PR information, if any GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}