run_emqx_app_tests.yaml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
  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_3"},{"type": "2_3"},{"type": "3_3"}]' | 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@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
  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. - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
  92. if: failure()
  93. with:
  94. name: logs-emqx-app-tests-${{ matrix.type }}
  95. path: apps/emqx/_build/test/logs
  96. retention-days: 7