run_emqx_app_tests.yaml 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. name: Check emqx app standalone
  2. ## apps/emqx can be used as a rebar/mix dependency
  3. ## in other project, so we need to make sure apps/emqx
  4. ## as an Erlang/Elixir app works standalone
  5. on:
  6. pull_request:
  7. jobs:
  8. run_emqx_app_tests:
  9. strategy:
  10. matrix:
  11. builder:
  12. - 5.1-0
  13. otp:
  14. - 25.3.2-1
  15. # no need to use more than 1 version of Elixir, since tests
  16. # run using only Erlang code. This is needed just to specify
  17. # the base image.
  18. elixir:
  19. - 1.14.5
  20. os:
  21. - ubuntu22.04
  22. arch:
  23. - amd64
  24. runs-on:
  25. - aws-amd64
  26. - ubuntu-22.04
  27. use-self-hosted:
  28. - ${{ github.repository_owner == 'emqx' }}
  29. exclude:
  30. - runs-on: ubuntu-22.04
  31. use-self-hosted: true
  32. - runs-on: aws-amd64
  33. use-self-hosted: false
  34. runs-on: ${{ matrix.runs-on }}
  35. container: "ghcr.io/emqx/emqx-builder/${{ matrix.builder }}:${{ matrix.elixir}}-${{ matrix.otp }}-${{ matrix.os }}"
  36. defaults:
  37. run:
  38. shell: bash
  39. steps:
  40. - uses: actions/checkout@v3
  41. with:
  42. fetch-depth: 0
  43. - name: run
  44. run: |
  45. git config --global --add safe.directory "$GITHUB_WORKSPACE"
  46. echo "git diff base: $GITHUB_BASE_REF"
  47. if [[ "$GITHUB_BASE_REF" =~ [0-9a-f]{8,40} ]]; then
  48. # base is a commit sha1
  49. compare_base="$GITHUB_BASE_REF"
  50. else
  51. repo="${GITHUB_REPOSITORY}"
  52. git remote -v
  53. remote="$(git remote -v | grep -E "github\.com(:|/)$repo((\.git)|(\s))" | grep fetch | awk '{print $1}')"
  54. git fetch "$remote" "$GITHUB_BASE_REF"
  55. compare_base="$remote/$GITHUB_BASE_REF"
  56. fi
  57. changed_files="$(git diff --name-only ${compare_base} HEAD apps/emqx)"
  58. if [ "$changed_files" = '' ]; then
  59. echo "nothing changed in apps/emqx, ignored."
  60. exit 0
  61. fi
  62. make ensure-rebar3
  63. cp rebar3 apps/emqx/
  64. cd apps/emqx
  65. ./rebar3 xref
  66. ./rebar3 dialyzer
  67. ./rebar3 eunit -v
  68. ./rebar3 ct --name 'test@127.0.0.1' -v --readable=true
  69. ./rebar3 proper -d test/props
  70. - uses: actions/upload-artifact@v3
  71. if: failure()
  72. with:
  73. name: logs-${{ matrix.runs-on }}
  74. path: apps/emqx/_build/test/logs