From 992765a7eeb960f02c9dc64db5b7339c001ea852 Mon Sep 17 00:00:00 2001
From: brown <1173781832@qq.com>
Date: Sun, 28 Aug 2022 00:51:25 +0800
Subject: [PATCH] CI: improve ci by modify upload condition (#4731)

No data and logs are uploaded when a job runs successfully, and vice versa, improving the efficiency of ci job execution.

Approved by: @sukki37
---
 .github/workflows/ci.yml | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 1461f383d..f8c266a5c 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -32,7 +32,7 @@ jobs:
           make ut
 
       - uses: actions/upload-artifact@v2
-        if: ${{ always() && !cancelled() }}
+        if: ${{ failure() }}
         continue-on-error: true
         with:
           name: ut_linux_x86_reports
@@ -58,7 +58,7 @@ jobs:
           make ut
 
       - uses: actions/upload-artifact@v2
-        if: ${{ always() && !cancelled() }}
+        if: ${{ failure() }}
         continue-on-error: true
         with:
           name: ut_darwin_x86_reports
@@ -84,7 +84,7 @@ jobs:
           make ut
 
       - uses: actions/upload-artifact@v2
-        if: ${{ always() && !cancelled() }}
+        if: ${{ failure() }}
         continue-on-error: true
         with:
           name: ut_linux_arm_reports
@@ -142,12 +142,11 @@ jobs:
           ./run.sh -n -g -p $GITHUB_WORKSPACE/head/test/cases 2>&1
 
       - name: Check mo-service Status
-        if: ${{ always() }}
+        if: ${{ always() && !cancelled() }}
         run: |
           if [ "$(ps -ef | grep 'mo-service' | grep -v "grep" | wc -l)" -gt 0 ]; then pkill -9 mo-service; else echo 'current mo-service has already crashed'; exit 1; fi
         
       - name: remove some files
-        if: ${{ always() }}
         continue-on-error: true
         run: |
           cd $GITHUB_WORKSPACE
@@ -156,7 +155,7 @@ jobs:
           rm -rf ./mo-tester/lib
 
       - uses: actions/upload-artifact@v2
-        if: ${{ always() && !cancelled() }}
+        if: ${{ failure() }}
         continue-on-error: true
         with:
           name: linux_x86_ci_reports
@@ -214,12 +213,11 @@ jobs:
           ./run.sh -n -g -p $GITHUB_WORKSPACE/head/test/cases 2>&1
 
       - name: Check mo-service Status
-        if: ${{ always() }}
+        if: ${{ always() && !cancelled() }}
         run: |
           if [ "$(ps -ef | grep 'mo-service' | grep -v "grep" | wc -l)" -gt 0 ]; then pkill -9 mo-service; else echo 'current mo-service has already crashed'; exit 1; fi
         
       - name: remove some files
-        if: ${{ always() }}
         continue-on-error: true
         run: |
           cd $GITHUB_WORKSPACE
@@ -228,7 +226,7 @@ jobs:
           rm -rf ./mo-tester/lib
 
       - uses: actions/upload-artifact@v2
-        if: ${{ always() && !cancelled() }}
+        if: ${{ failure() }}
         continue-on-error: true
         with:
           name: ci_linux_arm_reports
@@ -284,12 +282,11 @@ jobs:
           ./run.sh -n -g -p $GITHUB_WORKSPACE/head/test/cases 2>&1
 
       - name: Check MO-Service Status
-        if: ${{ always() }}
+        if: ${{ always() && !cancelled() }}
         run: |
           if [ "$(ps -ef | grep 'mo-service' | grep -v "grep" | wc -l)" -gt 0 ]; then pkill -9 mo-service; else echo 'current mo-service has already crashed'; exit 1; fi
         
       - name: remove some files
-        if: ${{ always() }}
         continue-on-error: true
         run: |
           cd $GITHUB_WORKSPACE
@@ -298,7 +295,7 @@ jobs:
           rm -rf ./mo-tester/lib
 
       - uses: actions/upload-artifact@v2
-        if: ${{ always() && !cancelled() }}
+        if: ${{ failure() }}
         continue-on-error: true
         with:
           name: ci_darwin_x86_reports
@@ -333,4 +330,4 @@ jobs:
         run: |
           cd $GITHUB_WORKSPACE
           make static-check
-          
\ No newline at end of file
+          
-- 
GitLab