You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kvrocks.apache.org by "jihuayu (via GitHub)" <gi...@apache.org> on 2024/01/24 11:43:26 UTC

[PR] Fix sonar action can't get PR number [kvrocks]

jihuayu opened a new pull request, #2048:
URL: https://github.com/apache/kvrocks/pull/2048

   We only save PR info in the CI action pull_request event.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix sonar action can't get PR number [kvrocks]

Posted by "PragmaTwice (via GitHub)" <gi...@apache.org>.
PragmaTwice merged PR #2048:
URL: https://github.com/apache/kvrocks/pull/2048


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix sonar action can't get PR number [kvrocks]

Posted by "git-hulk (via GitHub)" <gi...@apache.org>.
git-hulk commented on code in PR #2048:
URL: https://github.com/apache/kvrocks/pull/2048#discussion_r1464896407


##########
.github/workflows/sonar.yaml:
##########
@@ -39,30 +39,45 @@ jobs:
         uses: actions/github-script@v6
         with:
           script: |
-            let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
-               owner: context.repo.owner,
-               repo: context.repo.repo,
-               run_id: context.payload.workflow_run.id,
-            });
-            let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
-              return artifact.name == "sonarcloud-data"
-            })[0];
-            let download = await github.rest.actions.downloadArtifact({
-               owner: context.repo.owner,
-               repo: context.repo.repo,
-               artifact_id: matchArtifact.id,
-               archive_format: 'zip',
-            });
-            let fs = require('fs');
-            fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/sonarcloud-data.zip`, Buffer.from(download.data));
+            async function getData(name) {
+              let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
+                owner: context.repo.owner,
+                repo: context.repo.repo,
+                run_id: context.payload.workflow_run.id,
+              });
+              let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
+                return artifact.name == name
+              })[0];
+              if(!matchArtifact) return;
+              let download = await github.rest.actions.downloadArtifact({
+                owner: context.repo.owner,
+                repo: context.repo.repo,
+                artifact_id: matchArtifact.id,
+                archive_format: 'zip',
+              });
+              let fs = require('fs');
+              fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/${name}.zip`, Buffer.from(download.data));
+            }
+            await getData("sonarcloud-data");
+            await getData("pr");

Review Comment:
   OK, thanks for your reference. That said, this artifact is only visible in the current run.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix sonar action can't get PR number [kvrocks]

Posted by "jihuayu (via GitHub)" <gi...@apache.org>.
jihuayu commented on code in PR #2048:
URL: https://github.com/apache/kvrocks/pull/2048#discussion_r1465616958


##########
.github/workflows/kvrocks.yaml:
##########
@@ -327,7 +327,20 @@ jobs:
         with:
           name: sonarcloud-data
           path: ${{ env.SONARCLOUD_OUTPUT_DIR }}
-
+          
+      - name: Save PR info
+        if: ${{ (github.event_name == 'pull_request') && matrix.sonarcloud }}
+        run: |
+          mkdir -p ./pr
+          echo "number=${{ github.event.number }}" >> ./pr/info
+          
+      - name: Upload PR info
+        uses: actions/upload-artifact@v3
+        if: ${{ matrix.sonarcloud }}
+        with:
+          name: pr
+          path: pr/

Review Comment:
   You are right, Thank you.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix sonar action can't get PR number [kvrocks]

Posted by "jihuayu (via GitHub)" <gi...@apache.org>.
jihuayu commented on code in PR #2048:
URL: https://github.com/apache/kvrocks/pull/2048#discussion_r1464831984


##########
.github/workflows/sonar.yaml:
##########
@@ -39,30 +39,45 @@ jobs:
         uses: actions/github-script@v6
         with:
           script: |
-            let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
-               owner: context.repo.owner,
-               repo: context.repo.repo,
-               run_id: context.payload.workflow_run.id,
-            });
-            let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
-              return artifact.name == "sonarcloud-data"
-            })[0];
-            let download = await github.rest.actions.downloadArtifact({
-               owner: context.repo.owner,
-               repo: context.repo.repo,
-               artifact_id: matchArtifact.id,
-               archive_format: 'zip',
-            });
-            let fs = require('fs');
-            fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/sonarcloud-data.zip`, Buffer.from(download.data));
+            async function getData(name) {
+              let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
+                owner: context.repo.owner,
+                repo: context.repo.repo,
+                run_id: context.payload.workflow_run.id,
+              });
+              let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
+                return artifact.name == name
+              })[0];
+              if(!matchArtifact) return;
+              let download = await github.rest.actions.downloadArtifact({
+                owner: context.repo.owner,
+                repo: context.repo.repo,
+                artifact_id: matchArtifact.id,
+                archive_format: 'zip',
+              });
+              let fs = require('fs');
+              fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/${name}.zip`, Buffer.from(download.data));
+            }
+            await getData("sonarcloud-data");
+            await getData("pr");

Review Comment:
   No, this is a Github action doc example.
   https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#using-data-from-the-triggering-workflow



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix sonar action can't get PR number [kvrocks]

Posted by "git-hulk (via GitHub)" <gi...@apache.org>.
git-hulk commented on code in PR #2048:
URL: https://github.com/apache/kvrocks/pull/2048#discussion_r1464819715


##########
.github/workflows/sonar.yaml:
##########
@@ -39,30 +39,45 @@ jobs:
         uses: actions/github-script@v6
         with:
           script: |
-            let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
-               owner: context.repo.owner,
-               repo: context.repo.repo,
-               run_id: context.payload.workflow_run.id,
-            });
-            let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
-              return artifact.name == "sonarcloud-data"
-            })[0];
-            let download = await github.rest.actions.downloadArtifact({
-               owner: context.repo.owner,
-               repo: context.repo.repo,
-               artifact_id: matchArtifact.id,
-               archive_format: 'zip',
-            });
-            let fs = require('fs');
-            fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/sonarcloud-data.zip`, Buffer.from(download.data));
+            async function getData(name) {
+              let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
+                owner: context.repo.owner,
+                repo: context.repo.repo,
+                run_id: context.payload.workflow_run.id,
+              });
+              let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
+                return artifact.name == name
+              })[0];
+              if(!matchArtifact) return;
+              let download = await github.rest.actions.downloadArtifact({
+                owner: context.repo.owner,
+                repo: context.repo.repo,
+                artifact_id: matchArtifact.id,
+                archive_format: 'zip',
+              });
+              let fs = require('fs');
+              fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/${name}.zip`, Buffer.from(download.data));
+            }
+            await getData("sonarcloud-data");
+            await getData("pr");

Review Comment:
   May it get the wrong PR number while two PRs are running at the same time?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix sonar action can't get PR number [kvrocks]

Posted by "git-hulk (via GitHub)" <gi...@apache.org>.
git-hulk commented on code in PR #2048:
URL: https://github.com/apache/kvrocks/pull/2048#discussion_r1465995469


##########
.github/workflows/kvrocks.yaml:
##########
@@ -480,4 +480,4 @@ jobs:
             exit 1
           fi
       - name: Sentinel
-        run: true
+        run: true

Review Comment:
   Keep the empty line at the end of the file.
   ```suggestion
           run: true
    
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix sonar action can't get PR number [kvrocks]

Posted by "jihuayu (via GitHub)" <gi...@apache.org>.
jihuayu commented on code in PR #2048:
URL: https://github.com/apache/kvrocks/pull/2048#discussion_r1465616958


##########
.github/workflows/kvrocks.yaml:
##########
@@ -327,7 +327,20 @@ jobs:
         with:
           name: sonarcloud-data
           path: ${{ env.SONARCLOUD_OUTPUT_DIR }}
-
+          
+      - name: Save PR info
+        if: ${{ (github.event_name == 'pull_request') && matrix.sonarcloud }}
+        run: |
+          mkdir -p ./pr
+          echo "number=${{ github.event.number }}" >> ./pr/info
+          
+      - name: Upload PR info
+        uses: actions/upload-artifact@v3
+        if: ${{ matrix.sonarcloud }}
+        with:
+          name: pr
+          path: pr/

Review Comment:
   You are right, Thank you. I will do it after #2049 has been merged.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix sonar action can't get PR number [kvrocks]

Posted by "PragmaTwice (via GitHub)" <gi...@apache.org>.
PragmaTwice commented on code in PR #2048:
URL: https://github.com/apache/kvrocks/pull/2048#discussion_r1464841046


##########
.github/workflows/kvrocks.yaml:
##########
@@ -327,7 +327,20 @@ jobs:
         with:
           name: sonarcloud-data
           path: ${{ env.SONARCLOUD_OUTPUT_DIR }}
-
+          
+      - name: Save PR info
+        if: ${{ (github.event_name == 'pull_request') && matrix.sonarcloud }}
+        run: |
+          mkdir -p ./pr
+          echo "number=${{ github.event.number }}" >> ./pr/info
+          
+      - name: Upload PR info
+        uses: actions/upload-artifact@v3
+        if: ${{ matrix.sonarcloud }}
+        with:
+          name: pr
+          path: pr/

Review Comment:
   You can just add a new file to ${{ env.SONARCLOUD_OUTPUT_DIR }}.



##########
.github/workflows/kvrocks.yaml:
##########
@@ -327,7 +327,20 @@ jobs:
         with:
           name: sonarcloud-data
           path: ${{ env.SONARCLOUD_OUTPUT_DIR }}
-
+          
+      - name: Save PR info
+        if: ${{ (github.event_name == 'pull_request') && matrix.sonarcloud }}
+        run: |
+          mkdir -p ./pr
+          echo "number=${{ github.event.number }}" >> ./pr/info
+          
+      - name: Upload PR info
+        uses: actions/upload-artifact@v3
+        if: ${{ matrix.sonarcloud }}
+        with:
+          name: pr
+          path: pr/

Review Comment:
   You can just add a new file to `${{ env.SONARCLOUD_OUTPUT_DIR }}`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org