Przeglądaj źródła

ci: no need to test apps/emqx if nothing changed in this sub-dir

Zaiming (Stone) Shi 3 lat temu
rodzic
commit
94239d98df
1 zmienionych plików z 19 dodań i 1 usunięć
  1. 19 1
      .github/workflows/run_emqx_app_tests.yaml

+ 19 - 1
.github/workflows/run_emqx_app_tests.yaml

@@ -30,11 +30,17 @@ jobs:
         arch:
         arch:
           - amd64
           - amd64
 
 
-    runs-on: ubuntu-20.04
+    runs-on: aws-amd64
     container: "ghcr.io/emqx/emqx-builder/5.0-10:${{ matrix.elixir}}-${{ matrix.otp }}-${{ matrix.os }}"
     container: "ghcr.io/emqx/emqx-builder/5.0-10:${{ matrix.elixir}}-${{ matrix.otp }}-${{ matrix.os }}"
 
 
+    defaults:
+      run:
+        shell: bash
+
     steps:
     steps:
     - uses: actions/checkout@v2
     - uses: actions/checkout@v2
+      with:
+        fetch-depth: 0
     - name: Get deps git refs for cache
     - name: Get deps git refs for cache
       id: deps-refs
       id: deps-refs
       run: |
       run: |
@@ -47,6 +53,18 @@ jobs:
         key: ${{ matrix.os }}-${{ matrix.otp }}-${{ matrix.arch }}-${{ steps.deps-refs.outputs.DEP_QUICER_REF }}
         key: ${{ matrix.os }}-${{ matrix.otp }}-${{ matrix.arch }}-${{ steps.deps-refs.outputs.DEP_QUICER_REF }}
     - name: run
     - name: run
       run: |
       run: |
+        echo "git diff base: $GITHUB_BASE_REF"
+        if [[ "$GITHUB_BASE_REF" =~ [0-9a-f]{8,40} ]]; then
+          # base is a commit sha1
+          compare_base="$GITHUB_BASE_REF"
+        else
+          compare_base="origin/$GITHUB_BASE_REF"
+        fi
+        changed_files="$(git diff --name-only ${compare_base}...HEAD apps/emqx)"
+        if [ "$changed_files" = '' ]; then
+          echo "nothing changed in apps/emqx, ignored."
+          exit 0
+        fi
         make ensure-rebar3
         make ensure-rebar3
         cp rebar3 apps/emqx/
         cp rebar3 apps/emqx/
         cd apps/emqx
         cd apps/emqx