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

orpiske 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 b74b53c  (chores) ci: added support for commenting about the status of 
the tests after verification
b74b53c is described below

commit b74b53cbf2735522031cecd0ba3b4f5e89a5c1b2
Author: Otavio Rodolfo Piske <[email protected]>
AuthorDate: Thu Mar 31 14:12:03 2022 +0200

    (chores) ci: added support for commenting about the status of the tests 
after verification
---
 .github/actions/quick-test/action.yaml   |  2 +-
 .github/actions/quick-test/quick-test.sh | 15 ++++-----------
 .github/workflows/component-pr.yaml      | 33 +++++++++++++++++++++++++++++++-
 3 files changed, 37 insertions(+), 13 deletions(-)

diff --git a/.github/actions/quick-test/action.yaml 
b/.github/actions/quick-test/action.yaml
index 2da51ec..5e99e8e 100644
--- a/.github/actions/quick-test/action.yaml
+++ b/.github/actions/quick-test/action.yaml
@@ -27,7 +27,7 @@ runs:
       run: ${{ github.action_path }}/quick-test.sh ${{ inputs.start-commit }} 
${{ inputs.end-commit }}
       shell: bash
     - name: archive logs
-      uses: actions/upload-artifact@v2
+      uses: actions/upload-artifact@v3
       if: always()
       with:
         name: test-logs
diff --git a/.github/actions/quick-test/quick-test.sh 
b/.github/actions/quick-test/quick-test.sh
index 2c787c3..67122dc 100755
--- a/.github/actions/quick-test/quick-test.sh
+++ b/.github/actions/quick-test/quick-test.sh
@@ -78,22 +78,17 @@ function main() {
   local total=$(echo "${components}" | grep -v -e '^$' | wc -l)
 
   if [[ ${total} -eq 0 ]]; then
-    echo "::set-output name=result:: :camel: There are (likely) no components 
to be tested in this PR"
-    echo "::set-output name=component-count::0"
-    echo "::set-output name=failures-count::0"
+    echo "result=There are (likely) no components to be tested in this PR" > 
"${logDir}"/results.txt
     exit 0
   else
     if [[ ${total} -gt 10 ]]; then
-      echo "::set-output name=result:: :camel: There are too many components 
to be tested in this PR"
-      echo "::set-output name=component-count::0"
-      echo "::set-output name=failures-count::0"
+      echo "result=There are too many components to be tested in this PR"  > 
"${logDir}"/results.txt
       exit 0
     fi
   fi
 
   echo "It will test the following ${total} components:"
   echo "${components}"
-  echo "::set-output name=component-count::${total}"
 
   current=0
   mkdir -p "${logDir}"
@@ -103,13 +98,11 @@ function main() {
   done
 
   if [[ ${failures} -eq 0 ]]; then
-    echo "::set-output name=result:: :heavy_check_mark: Finished verification: 
${total} verified / ${failures} failed"
+    echo "result=:heavy_check_mark: Finished verification: ${total} verified / 
${failures} failed" > "${logDir}"/results.txt
   else
-    echo "::set-output name=result:: :x: Finished verification: ${total} 
verified / ${failures} failed"
+    echo "result=:x: Finished verification: ${total} verified / ${failures} 
failed" > "${logDir}"/results.txt
   fi
 
-
-  echo "::set-output name=failures-count::${failures}"
   exit "${failures}"
 }
 
diff --git a/.github/workflows/component-pr.yaml 
b/.github/workflows/component-pr.yaml
index 730df2a..8a28c77 100644
--- a/.github/workflows/component-pr.yaml
+++ b/.github/workflows/component-pr.yaml
@@ -24,6 +24,10 @@ on:
       - reopened
     paths:
       - 'components/**'
+  workflow_run:
+    workflows: [ "main pr build" ]
+    types:
+      - completed
 
 jobs:
   process:
@@ -31,6 +35,33 @@ jobs:
     runs-on: ubuntu-latest
     steps:
       - uses: actions/github-script@v6
+        if: |
+          github.event_name == 'pull_request_target' &&
+            (github.event.action == 'opened' ||
+             github.event.action == 'reopened')
+        with:
+          github-token: ${{ secrets.GITHUB_TOKEN }}
+          script: |
+            github.rest.issues.createComment({
+              issue_number: context.issue.number,
+              owner: context.repo.owner,
+              repo: context.repo.repo,
+              body: `This PR changes components and will be tested 
automatically`
+            })
+      - name: Download a single artifact
+        uses: actions/download-artifact@v3
+        if: |
+          github.event_name == 'workflow_run'
+        with:
+          name: test-logs
+      - name: Get the test result
+        if: |
+          github.event_name == 'workflow_run'
+        run: |
+          cat automated-build-log/results.txt >> $GITHUB_ENV
+      - uses: actions/github-script@v6
+        if: |
+          github.event_name == 'workflow_run'
         with:
           github-token: ${{ secrets.GITHUB_TOKEN }}
           script: |
@@ -40,5 +71,5 @@ jobs:
               issue_number: context.issue.number,
               owner: context.repo.owner,
               repo: context.repo.repo,
-              body: `This PR changes components and will be tested 
automatically`
+              body: "${{ env.result }}
             })

Reply via email to