Просмотр исходного кода

ci: restore emqx app standalone tests

Those were accidentally removed during a refactoring.

They are needed because we provide the `emqx` application as a standalone dependency for
plugins.
Thales Macedo Garitezi 2 лет назад
Родитель
Сommit
8a6bb6f5f3

+ 9 - 0
.github/workflows/_pr_entrypoint.yaml

@@ -146,6 +146,15 @@ jobs:
           path: ${{ matrix.profile }}.zip
           retention-days: 1
 
+  run_emqx_app_tests:
+    needs:
+      - sanity-checks
+      - compile
+    uses: ./.github/workflows/run_emqx_app_tests.yaml
+    with:
+      runner: ${{ needs.sanity-checks.outputs.runner }}
+      builder: ${{ needs.sanity-checks.outputs.builder }}
+
   run_test_cases:
     needs:
       - sanity-checks

+ 9 - 0
.github/workflows/_push-entrypoint.yaml

@@ -158,6 +158,15 @@ jobs:
           path: ${{ matrix.profile }}.zip
           retention-days: 1
 
+  run_emqx_app_tests:
+    needs:
+      - sanity-checks
+      - compile
+    uses: ./.github/workflows/run_emqx_app_tests.yaml
+    with:
+      runner: ${{ needs.sanity-checks.outputs.runner }}
+      builder: ${{ needs.sanity-checks.outputs.builder }}
+
   run_test_cases:
     if: needs.prepare.outputs.release != 'true'
     needs:

+ 67 - 0
.github/workflows/run_emqx_app_tests.yaml

@@ -0,0 +1,67 @@
+name: Check emqx app standalone
+
+# These tests are needed because we provide the `emqx` application as a standalone
+# dependency for plugins.
+
+concurrency:
+  group: test-standalone-${{ github.event_name }}-${{ github.ref }}
+  cancel-in-progress: true
+
+on:
+  workflow_call:
+    inputs:
+      runner:
+        required: true
+        type: string
+      builder:
+        required: true
+        type: string
+
+env:
+  IS_CI: "yes"
+
+jobs:
+  run_emqx_app_tests:
+    runs-on: ${{ inputs.runner }}
+    container: "ghcr.io/emqx/emqx-builder/${{ matrix.builder }}:${{ matrix.elixir}}-${{ matrix.otp }}-ubuntu22.04"
+
+    defaults:
+      run:
+        shell: bash
+
+    steps:
+    - uses: actions/checkout@v3
+      with:
+        fetch-depth: 0
+    - name: run
+      run: |
+        git config --global --add safe.directory "$GITHUB_WORKSPACE"
+        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
+          repo="${GITHUB_REPOSITORY}"
+          git remote -v
+          remote="$(git remote -v | grep -E "github\.com(:|/)$repo((\.git)|(\s))" | grep fetch | awk '{print $1}')"
+          git fetch "$remote" "$GITHUB_BASE_REF"
+          compare_base="$remote/$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
+        cp rebar3 apps/emqx/
+        cd apps/emqx
+        ./rebar3 xref
+        ./rebar3 dialyzer
+        ./rebar3 eunit -v
+        ./rebar3 ct --name 'test@127.0.0.1' -v --readable=true
+        ./rebar3 proper -d test/props
+    - uses: actions/upload-artifact@v3
+      if: failure()
+      with:
+        name: logs-${{ matrix.runs-on }}
+        path: apps/emqx/_build/test/logs