You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by nf...@apache.org on 2023/05/31 08:21:46 UTC

[camel] branch main updated: component-test - Move the comment update into the github action

This is an automated email from the ASF dual-hosted git repository.

nfilotto pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new e80bbb2a089 component-test - Move the comment update into the github action
e80bbb2a089 is described below

commit e80bbb2a08992ba02a8a83d99b1421f192efa41f
Author: Nicolas Filotto <nf...@talend.com>
AuthorDate: Wed May 31 10:21:23 2023 +0200

    component-test - Move the comment update into the github action
---
 .github/actions/component-test/action.yaml       | 54 ++++++++++++++++++++++--
 .github/actions/component-test/component-test.sh | 10 ++---
 .github/workflows/pr-comment.yml                 | 46 +++-----------------
 3 files changed, 63 insertions(+), 47 deletions(-)

diff --git a/.github/actions/component-test/action.yaml b/.github/actions/component-test/action.yaml
index 15ae080b8ca..ba45de16848 100644
--- a/.github/actions/component-test/action.yaml
+++ b/.github/actions/component-test/action.yaml
@@ -18,6 +18,12 @@
 name: "Component Test Runner"
 description: "Runs tests of corresponding to the given comment"
 inputs:
+  pr-id:
+    description: 'Id of the pull request to update'
+    required: true
+  comment-id:
+    description: 'Id of the comment to process'
+    required: true
   comment-body:
     description: 'Body of the comment to process'
     required: true
@@ -28,7 +34,7 @@ runs:
       uses: ./.github/actions/install-mvnd
     - name: maven build
       shell: bash
-      run: ${{ github.action_path }}/component-test.sh ${{ steps.install-mvnd.outputs.mvnd-dir }}/mvnd true "${{ inputs.comment-body }}" build.log
+      run: ${{ github.action_path }}/component-test.sh ${{ steps.install-mvnd.outputs.mvnd-dir }}/mvnd "${{ inputs.comment-body }}" true build.log
     - name: archive logs
       uses: actions/upload-artifact@v3
       if: always()
@@ -37,11 +43,53 @@ runs:
         path: build.log
     - name: maven test
       shell: bash
-      run: ${{ github.action_path }}/component-test.sh ${{ steps.install-mvnd.outputs.mvnd-dir }}/mvnd false "${{ inputs.comment-body }}" tests.log
+      run: ${{ github.action_path }}/component-test.sh ${{ steps.install-mvnd.outputs.mvnd-dir }}/mvnd "${{ inputs.comment-body }}" false tests.log
     - name: archive logs
       uses: actions/upload-artifact@v3
       if: always()
       with:
         name: tests.log
         path: tests.log
-
+    - name: Dump GitHub context
+      env:
+        GITHUB_CONTEXT: ${{ toJson(github) }}
+      run: |
+        echo "$GITHUB_CONTEXT"
+    - name: Success comment
+      if: success()
+      uses: actions/github-script@v6
+      with:
+        github-token: ${{ secrets.GITHUB_TOKEN }}
+        script: |
+          await github.rest.issues.updateComment({
+                owner: context.repo.owner,
+                repo: context.repo.repo,
+                issue_number: ${{ inputs.pr-id }},
+                comment_id: ${{ inputs.comment-id }},
+                body: `${{ inputs.comment-body }}
+          **Result** :white_check_mark: The tests passed successfully`
+          });
+    - name: Failure comment
+      if: failure()
+      uses: actions/github-script@v6
+      with:
+        github-token: ${{ secrets.GITHUB_TOKEN }}
+        script: |
+          var artifacts = await github.rest.actions.listWorkflowRunArtifacts({
+             owner: context.repo.owner,
+             repo: context.repo.repo,
+             run_id: ${{ github.event.workflow_run.id }}
+          });
+          var message = `${{ inputs.comment-body }}
+          **Result** :x: The tests failed please check the logs below:
+          `
+          for (const artifact in artifacts.data.artifacts) {
+            message += `* [*${artifact.name}*](${artifact.url})`
+          }
+          await github.rest.issues.updateComment({
+                owner: context.repo.owner,
+                repo: context.repo.repo,
+                issue_number: ${{ inputs.pr-id }},
+                comment_id: ${{ inputs.comment-id }},
+                body: message
+          });
diff --git a/.github/actions/component-test/component-test.sh b/.github/actions/component-test/component-test.sh
index 4236dc12a61..eb79f13ca4f 100755
--- a/.github/actions/component-test/component-test.sh
+++ b/.github/actions/component-test/component-test.sh
@@ -16,13 +16,13 @@
 #
 
 # Modify maven options here if needed
-MVN_DEFAULT_OPTS="-Dmaven.compiler.fork=true -Dsurefire.rerunFailingTestsCount=2 -Dfailsafe.rerunFailingTestsCount=2 -Dci.env.name=github.com"
+MVN_DEFAULT_OPTS="-Dmaven.compiler.fork=true -Dsurefire.rerunFailingTestsCount=2 -Dfailsafe.rerunFailingTestsCount=2 -Dci.env.name=github.com -Dmvnd.threads=2 -V -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 --no-transfer-progress -e"
 MVN_OPTS=${MVN_OPTS:-$MVN_DEFAULT_OPTS}
 
 function main() {
   local mavenBinary=${1}
-  local fastBuild=${2}
-  local commentBody=${3}
+  local commentBody=${2}
+  local fastBuild=${3}
   local log=${4}
 
   if [[ ${commentBody} = /component-test* ]] ; then
@@ -45,10 +45,10 @@ function main() {
 
   if [[ ${fastBuild} = "true" ]] ; then
     echo "Launching a fast build against the projects ${pl} and their dependencies"
-    $mavenBinary -l $log -Dmvnd.threads=2 -V -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 --no-transfer-progress -e -Pfastinstall install -pl "$pl" -am
+    $mavenBinary -l $log -Pfastinstall install -pl "$pl" -am
   else
     echo "Launching tests of the projects ${pl}"
-    $mavenBinary -l $log -Dmvnd.threads=2 -V -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 --no-transfer-progress -e install -pl "$pl"
+    $mavenBinary -l $log install -pl "$pl"
   fi
 }
 
diff --git a/.github/workflows/pr-comment.yml b/.github/workflows/pr-comment.yml
index 5dc26b35a2f..ea891a66e80 100644
--- a/.github/workflows/pr-comment.yml
+++ b/.github/workflows/pr-comment.yml
@@ -54,47 +54,15 @@ jobs:
           distribution: 'temurin'
           java-version: ${{ matrix.java }}
           cache: 'maven'
+      - name: Dump GitHub context
+        env:
+          GITHUB_CONTEXT: ${{ toJson(github) }}
+        run: |
+          echo "$GITHUB_CONTEXT"
       - id: test
         name: Component test execution
         uses: ./.github/actions/component-test
         with:
+          pr-id: ${{ github.event.issue.number.id }}
+          comment-id: ${{ github.event.comment.id }}
           comment-body: ${{ github.event.comment.body }}
-      - name: Success comment
-        if: success()
-        uses: actions/github-script@v6
-        with:
-          github-token: ${{ secrets.GITHUB_TOKEN }}
-          script: |
-            await github.rest.issues.updateComment({
-                  owner: context.repo.owner,
-                  repo: context.repo.repo,
-                  issue_number: context.issue.number,
-                  comment_id: ${{ github.event.comment.id }},
-                  body: `${{ github.event.comment.body }}
-            **Result** :white_check_mark: The tests passed successfully`
-            });
-      - name: Failure comment
-        if: failure()
-        uses: actions/github-script@v6
-        with:
-          github-token: ${{ secrets.GITHUB_TOKEN }}
-          script: |
-            var artifacts = await github.rest.actions.listWorkflowRunArtifacts({
-               owner: context.repo.owner,
-               repo: context.repo.repo,
-               run_id: ${{github.event.workflow_run.id }},
-            });
-            var message = `${{ github.event.comment.body }}
-            **Result** :x: The tests failed please check the logs below:
-            `
-            for (artifact in artifacts.data.artifacts) {
-              message += `* [*${artifact.name}*](${artifact.url})`
-            }
-            await github.rest.issues.updateComment({
-                  owner: context.repo.owner,
-                  repo: context.repo.repo,
-                  issue_number: context.issue.number,
-                  comment_id: ${{ github.event.comment.id }},
-                  body: message
-            });
-