chore(31835): add sonarqube job + update configuration #3552
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node | |
| # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs | |
| name: Frontend - React Testing Pyramid | |
| on: | |
| push: | |
| paths: | |
| - hivemq-edge-frontend/** | |
| - .github/workflows/frontend-cli.yml | |
| - .github/actions/setup_node/action.yml | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| defaults: | |
| run: | |
| working-directory: ./hivemq-edge-frontend/ | |
| # Cancel previous workflow on a follow-up push event | |
| # https://stackoverflow.com/a/72408109 | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: 👓 Checkout repository | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
| - name: 🏗️ Setup node environment | |
| uses: ./.github/actions/setup_node | |
| with: | |
| working-directory: ./hivemq-edge-frontend/ | |
| - name: 🧪 Run Prettier | |
| run: pnpm lint:prettier | |
| - name: 🧪 Run ESLint | |
| run: pnpm lint:eslint | |
| unit_tests: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: 👓 Checkout repository | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
| - name: 🏗️ Setup node environment | |
| uses: ./.github/actions/setup_node | |
| with: | |
| working-directory: ./hivemq-edge-frontend/ | |
| - name: 🧪 Run Test | |
| run: pnpm test:coverage | |
| - name: 💾 Upload Vitest Code Coverage | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 | |
| with: | |
| name: lcov-vitest | |
| path: hivemq-edge-frontend/coverage-vitest/lcov.info | |
| if-no-files-found: ignore | |
| retention-days: 1 | |
| build_production: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: 👓 Checkout repository | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
| - name: 🏗️ Setup node environment | |
| uses: ./.github/actions/setup_node | |
| with: | |
| working-directory: ./hivemq-edge-frontend/ | |
| - name: 🏗️ Build Application | |
| run: pnpm run build | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 | |
| with: | |
| name: application | |
| path: ./hivemq-edge-frontend/dist | |
| retention-days: 1 | |
| lighthouse: | |
| runs-on: ubuntu-latest | |
| needs: [ build_production ] | |
| steps: | |
| - name: 👓 Checkout repository | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
| - name: Download artifact | |
| uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4 | |
| with: | |
| name: application | |
| path: ./hivemq-edge-frontend/dist | |
| - name: 🚥 Run Lighthouse audits | |
| uses: treosh/lighthouse-ci-action@2f8dda6cf4de7d73b29853c3f29e73a01e297bd8 # v12 | |
| id: lighthouse | |
| with: | |
| temporaryPublicStorage: true # upload lighthouse report to the temporary storage | |
| ## budgetPath: ./budget.json # test performance budgets | |
| uploadArtifacts: true # save results as an action artifacts | |
| configPath: 'hivemq-edge-frontend/.lighthouserc.cjs' | |
| cypress_matrix: | |
| runs-on: ubuntu-latest | |
| continue-on-error: true | |
| needs: [ build_production ] | |
| strategy: | |
| matrix: | |
| cypress: [ | |
| { component: false, spec: "./cypress/e2e/**/*", lcov_target: "E2E" }, | |
| { component: true, spec: "./src/components/**/*", lcov_target: "Components" }, | |
| { component: true, spec: "./src/extensions/**/*", lcov_target: "Extensions" }, | |
| { component: true, spec: "./src/modules/!(Workspace)**/*", lcov_target: "Modules" }, | |
| { component: true, spec: "./src/modules/Workspace/**/*", lcov_target: "Workspace" } | |
| ] | |
| name: Cypress - ${{ matrix.cypress.lcov_target }} | |
| steps: | |
| - name: 👓 Checkout repository | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
| - name: 🏗️ Setup node environment | |
| uses: ./.github/actions/setup_node | |
| with: | |
| working-directory: ./hivemq-edge-frontend/ | |
| run-install: true | |
| - name: Download artifact | |
| uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4 | |
| with: | |
| name: application | |
| path: ./hivemq-edge-frontend/dist | |
| - name: 🧪 Run Cypress suite | |
| uses: cypress-io/github-action@v6 | |
| with: | |
| component: ${{ matrix.cypress.component }} | |
| spec: ${{ matrix.cypress.spec }} | |
| start: pnpm preview --port 3000 | |
| working-directory: ./hivemq-edge-frontend/ | |
| quiet: true | |
| # after the test, store videos | |
| - name: 💾 Upload Cypress - ${{ matrix.cypress.lcov_target }} videos | |
| if: failure() | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 | |
| with: | |
| name: cypress-${{ matrix.cypress.lcov_target }}-videos | |
| path: hivemq-edge-frontend/cypress/videos | |
| if-no-files-found: ignore | |
| retention-days: 1 | |
| - name: 💾 Upload Cypress Code Coverage | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 | |
| with: | |
| name: lcov-cypress-${{ matrix.cypress.lcov_target }} | |
| path: hivemq-edge-frontend/coverage-cypress/lcov.info | |
| if-no-files-found: ignore | |
| retention-days: 1 | |
| combine_code_coverage: | |
| runs-on: ubuntu-latest | |
| needs: [ cypress_matrix, unit_tests ] | |
| # Should we collect partial test results and combine them ? | |
| if: success() || failure() | |
| steps: | |
| - name: Download All LCOV Artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: hivemq-edge-frontend/coverage-combined | |
| pattern: lcov-* | |
| merge-multiple: false | |
| # Should contain the lcov.info summary, in subdirectory named from the tasks | |
| - run: ls -R ./coverage-combined | |
| sonarqube: | |
| name: SonarQube | |
| needs: [ combine_code_coverage ] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | |
| - name: SonarQube Scan | |
| uses: SonarSource/sonarqube-scan-action@v5 | |
| with: | |
| projectBaseDir: hivemq-edge-frontend | |
| env: | |
| SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |