run_emqx_app_tests.yaml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. name: Check emqx app standalone
  2. # These tests are needed because we provide the `emqx` application as a standalone
  3. # dependency for plugins.
  4. concurrency:
  5. group: test-standalone-${{ github.event_name }}-${{ github.ref }}
  6. cancel-in-progress: true
  7. on:
  8. workflow_call:
  9. inputs:
  10. builder:
  11. required: true
  12. type: string
  13. before_ref:
  14. required: true
  15. type: string
  16. after_ref:
  17. required: true
  18. type: string
  19. env:
  20. IS_CI: "yes"
  21. permissions:
  22. contents: read
  23. jobs:
  24. prepare_matrix:
  25. runs-on: ${{ endsWith(github.repository, '/emqx') && 'ubuntu-22.04' || fromJSON('["self-hosted","ephemeral","linux","x64"]') }}
  26. container: ${{ inputs.builder }}
  27. defaults:
  28. run:
  29. shell: bash
  30. outputs:
  31. matrix: ${{ steps.matrix.outputs.matrix }}
  32. skip: ${{ steps.matrix.outputs.skip }}
  33. steps:
  34. - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
  35. with:
  36. fetch-depth: 0
  37. - name: prepare test matrix
  38. id: matrix
  39. env:
  40. BEFORE_REF: ${{ inputs.before_ref }}
  41. AFTER_REF: ${{ inputs.after_ref }}
  42. run: |
  43. git config --global --add safe.directory "$GITHUB_WORKSPACE"
  44. changed_files="$(git diff --name-only ${BEFORE_REF} ${AFTER_REF} apps/emqx)"
  45. if [ "$changed_files" = '' ]; then
  46. echo "nothing changed in apps/emqx, ignored."
  47. echo 'matrix=[]' | tee -a $GITHUB_OUTPUT
  48. echo 'skip=true' | tee -a $GITHUB_OUTPUT
  49. exit 0
  50. else
  51. echo 'skip=false' | tee -a $GITHUB_OUTPUT
  52. echo 'matrix=[{"type": "eunit_proper_and_static"},{"type": "1_4"},{"type": "2_4"},{"type": "3_4"},{"type": "4_4"}]' | tee -a $GITHUB_OUTPUT
  53. fi
  54. run_emqx_app_tests:
  55. if: needs.prepare_matrix.outputs.skip != 'true'
  56. needs:
  57. - prepare_matrix
  58. runs-on: ${{ endsWith(github.repository, '/emqx') && 'ubuntu-22.04' || fromJSON('["self-hosted","ephemeral","linux","x64"]') }}
  59. container: ${{ inputs.builder }}
  60. strategy:
  61. fail-fast: false
  62. matrix:
  63. include: ${{ fromJson(needs.prepare_matrix.outputs.matrix) }}
  64. defaults:
  65. run:
  66. shell: bash
  67. steps:
  68. - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
  69. with:
  70. fetch-depth: 0
  71. - name: run
  72. run: |
  73. git config --global --add safe.directory "$GITHUB_WORKSPACE"
  74. make ensure-rebar3
  75. cp rebar3 apps/emqx/
  76. cd apps/emqx
  77. if [[ ${{ matrix.type }} == "eunit_proper_and_static" ]]; then
  78. ./rebar3 xref
  79. ./rebar3 dialyzer
  80. ./rebar3 eunit -v --name 'eunit@127.0.0.1'
  81. ./rebar3 proper -d test/props
  82. else
  83. export SUITEGROUP=${{ matrix.type }}
  84. SUITES=$(../../scripts/find-suites.sh apps/emqx | \
  85. sed -e 's|apps/emqx/test/||g' | \
  86. sed -Ee 's|,?apps/emqx/integration_test/.*||g' | \
  87. sed -e 's/\.erl//g')
  88. echo "Suites: $SUITES"
  89. ./rebar3 as standalone_test ct --name 'test@127.0.0.1' -v --readable=true --suite="$SUITES"
  90. fi
  91. - name: compress logs
  92. if: failure()
  93. run: tar -czf logs.tar.gz apps/emqx/_build/{,standalone_test+}test/logs || true
  94. - uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
  95. if: failure()
  96. with:
  97. name: logs-emqx-app-tests-${{ matrix.type }}
  98. path: logs.tar.gz
  99. compression-level: 0
  100. retention-days: 7