run_emqx_app_tests.yaml 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. otp:
  12. - 24.2.1-1
  13. # no need to use more than 1 version of Elixir, since tests
  14. # run using only Erlang code. This is needed just to specify
  15. # the base image.
  16. elixir:
  17. - 1.13.4
  18. os:
  19. - ubuntu20.04
  20. arch:
  21. - amd64
  22. runs-on: aws-amd64
  23. container: "ghcr.io/emqx/emqx-builder/5.0-16:${{ matrix.elixir}}-${{ matrix.otp }}-${{ matrix.os }}"
  24. defaults:
  25. run:
  26. shell: bash
  27. steps:
  28. - uses: actions/checkout@v2
  29. with:
  30. fetch-depth: 0
  31. - name: Get deps git refs for cache
  32. id: deps-refs
  33. run: |
  34. PATH=$PATH:./ scripts/get-dep-refs.sh
  35. make clean-all
  36. - name: load quicer cache
  37. uses: actions/cache@v2
  38. with:
  39. path: _build/default/lib/quicer/
  40. key: ${{ matrix.os }}-${{ matrix.otp }}-${{ matrix.arch }}-${{ steps.deps-refs.outputs.DEP_QUICER_REF }}
  41. - name: run
  42. run: |
  43. git config --global --add safe.directory "$GITHUB_WORKSPACE"
  44. echo "git diff base: $GITHUB_BASE_REF"
  45. if [[ "$GITHUB_BASE_REF" =~ [0-9a-f]{8,40} ]]; then
  46. # base is a commit sha1
  47. compare_base="$GITHUB_BASE_REF"
  48. else
  49. repo="${GITHUB_REPOSITORY}"
  50. git remote -v
  51. remote="$(git remote -v | grep -E "github\.com(:|/)$repo((\.git)|(\s))" | grep fetch | awk '{print $1}')"
  52. git fetch "$remote" "$GITHUB_BASE_REF"
  53. compare_base="$remote/$GITHUB_BASE_REF"
  54. fi
  55. changed_files="$(git diff --name-only ${compare_base} HEAD apps/emqx)"
  56. if [ "$changed_files" = '' ]; then
  57. echo "nothing changed in apps/emqx, ignored."
  58. exit 0
  59. fi
  60. make ensure-rebar3
  61. cp rebar3 apps/emqx/
  62. cd apps/emqx
  63. ./rebar3 xref
  64. ./rebar3 dialyzer
  65. ./rebar3 eunit -v
  66. ./rebar3 ct -v
  67. ./rebar3 proper -d test/props
  68. - uses: actions/upload-artifact@v1
  69. if: failure()
  70. with:
  71. name: logs
  72. path: apps/emqx/_build/test/logs
  73. allgood_emqx_app_tests:
  74. runs-on: ubuntu-latest
  75. needs:
  76. - run_emqx_app_tests
  77. steps:
  78. - name: Check if all emqx app tests succeeded
  79. uses: re-actors/alls-green@release/v1
  80. with:
  81. #allowed-failures:
  82. #allowed-skips:
  83. jobs: ${{ toJSON(needs) }}