Quellcode durchsuchen

Merge pull request #2398 from ameijer/atm/debug-code-cov

Atm/debug code cov
Cliff Colvin vor 2 Jahren
Ursprung
Commit
5f5f8fff73
2 geänderte Dateien mit 22 neuen und 7 gelöschten Zeilen
  1. 14 2
      .github/workflows/build-test.yaml
  2. 8 5
      .github/workflows/sonar.yaml

+ 14 - 2
.github/workflows/build-test.yaml

@@ -45,12 +45,24 @@ jobs:
         name: Build
         run: |
           just build-local
+      - name: get-pr-info
+        shell: bash
+        env:
+          PR_NUM: ${{ github.event.number }}
+        run: |
+          echo $PR_NUM > pr_num.txt
+          echo $GITHUB_BASE_REF > base.txt
+          echo $GITHUB_HEAD_REF > head.txt
       - name: Upload code coverage
         uses: actions/upload-artifact@v3
         with:
           name: oc-code-coverage
-          path: coverage.out
-
+          path: |
+           coverage.out
+           pr_num.txt
+           base.txt
+           head.txt
+      
   frontend:
     runs-on: ubuntu-latest
     steps:

+ 8 - 5
.github/workflows/sonar.yaml

@@ -36,8 +36,11 @@ jobs:
             fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/oc-code-coverage.zip`, Buffer.from(download.data));
       - name: 'Unzip code coverage'
         run: unzip oc-code-coverage.zip -d coverage
-      - name: Dump context
-        uses: crazy-max/ghaction-dump-context@v2
+      - name: set env vars 
+        run: | 
+          echo "SONAR_PR_NUM=$(cat coverage/pr_num.txt)" >> $GITHUB_ENV
+          echo "SONAR_BASE=$(cat coverage/base.txt)" >> $GITHUB_ENV
+          echo "SONAR_HEAD=$(cat coverage/head.txt)" >> $GITHUB_ENV
       - name: SonarCloud Scan
         uses: sonarsource/sonarcloud-github-action@master
         env:
@@ -46,8 +49,8 @@ jobs:
         with:
           args: >
             -Dsonar.scm.revision=${{ github.event.workflow_run.head_sha }}
-            -Dsonar.pullrequest.key=${{ github.event.workflow_run.pull_requests[0].number }}
-            -Dsonar.pullrequest.branch=${{ github.event.workflow_run.pull_requests[0].head.ref }}
-            -Dsonar.pullrequest.base=${{ github.event.workflow_run.pull_requests[0].base.ref }}
+            -Dsonar.pullrequest.key=${{ env.SONAR_PR_NUM }}
+            -Dsonar.pullrequest.branch=${{ env.SONAR_HEAD }}
+            -Dsonar.pullrequest.base=${{ env.SONAR_BASE }}
             -Dsonar.projectKey=opencost_opencost
             -Dsonar.organization=opencost