From 201b4eb8b74b355be5bf645f33fe9589fa32e13c Mon Sep 17 00:00:00 2001 From: Daithi Hearn Date: Wed, 4 Oct 2023 00:29:39 +0200 Subject: [PATCH 1/2] test: switching to automatic sonar analysis --- .github/workflows/unit-tests.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 56c5f16..3d3ce6f 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -21,8 +21,8 @@ jobs: run: yarn install --frozen-lockfile - name: Test and coverage run: yarn jest --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 }} + # - 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 }} From 5b2e299cc074fd23fc66aac1159bc3d6c2d88e8e Mon Sep 17 00:00:00 2001 From: Daithi Hearn Date: Wed, 4 Oct 2023 00:38:40 +0200 Subject: [PATCH 2/2] test: sonar config --- .github/workflows/unit-tests.yml | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 3d3ce6f..28c4dd1 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -21,8 +21,19 @@ jobs: run: yarn install --frozen-lockfile - name: Test and coverage run: yarn jest --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 }} + - name: Sonar Args + id: sonar-args + run: | + if [[ ${{ github.ref }} == 'refs/heads/main' ]]; then + echo "SONAR_ARGS=-Dsonar.branch.name=main" >> $GITHUB_OUTPUT + else + echo "SONAR_ARGS=-Dsonar.branch.target=main -Dsonar.branch.name=${{ github.head_ref }}" >> $GITHUB_OUTPUT + fi + + - name: SonarCloud Scan + uses: sonarsource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + with: + args: ${{ steps.sonar-args.outputs.SONAR_ARGS }}