domjtalbot/nx-mesh

View on GitHub
.github/workflows/__code-analysis--sonar.yml

Summary

Maintainability
Test Coverage
name: 'Code Analysis - Sonar'

on:
  workflow_call:
    secrets:
      NX__TRIPPIN__API_KEY:
        description: 'The Trippin API Key'
        required: true
      NX_CLOUD_ACCESS_TOKEN:
        description: 'The NX Cloud API token'
        required: true

concurrency:
  group: code-analysis--sonar-${{ github.workflow }}-${{ github.ref }}

env:
  NX__TRIPPIN__API_KEY: ${{ secrets.NX__TRIPPIN__API_KEY }}
  NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}

jobs:
  sonar:
    runs-on: ubuntu-latest
    steps:
      - name: Check out repository
        uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
        with:
          fetch-depth: 0

      - name: Setup Job
        uses: ./.github/actions/setup-job
        with:
          node_version: 'lts/*'

      - name: Lint Reports
        shell: bash
        run: |
          pnpm nx run-many \
            --target=lint \
            --parallel=4 \
            --all \
            --configuration=reports

      - name: Test Reports
        shell: bash
        run: |
          pnpm nx run-many \
            --target=test \
            --parallel=3 \
            --all \
            --configuration=reports

      - name: Get Nx-mesh version
        id: version
        uses: notiz-dev/github-action-json-property@a5a9c668b16513c737c3e1f8956772c99c73f6e8 # v0.2.0
        with:
          path: 'packages/nx-mesh/package.json'
          prop_path: 'version'

      - name: SonarCloud Scan
        uses: sonarsource/sonarcloud-github-action@db501078e936e4b4c8773d1bb949ba9ddb7b6b6a # v1.9
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
        with:
          args: >
            -Dsonar.projectVersion=${{ steps.version.outputs.prop }}