From b38e7066a5b0503dc1054068e980c45e97157e60 Mon Sep 17 00:00:00 2001 From: Thales Macedo Garitezi Date: Tue, 18 Jun 2024 17:31:37 -0300 Subject: [PATCH] ci: ct testing with mix --- .github/workflows/.zipignore2 | 1 + .github/workflows/_pr_entrypoint.yaml | 5 ++++- .github/workflows/run_test_cases.yaml | 24 ++++++++++++++++++------ Makefile | 27 +++++++++++++++++---------- scripts/ct/run.sh | 7 +++++-- 5 files changed, 45 insertions(+), 19 deletions(-) create mode 100644 .github/workflows/.zipignore2 diff --git a/.github/workflows/.zipignore2 b/.github/workflows/.zipignore2 new file mode 100644 index 000000000..f0d0058a7 --- /dev/null +++ b/.github/workflows/.zipignore2 @@ -0,0 +1 @@ +*/.github/* diff --git a/.github/workflows/_pr_entrypoint.yaml b/.github/workflows/_pr_entrypoint.yaml index 778236751..c8b5aa733 100644 --- a/.github/workflows/_pr_entrypoint.yaml +++ b/.github/workflows/_pr_entrypoint.yaml @@ -146,9 +146,12 @@ jobs: env: PROFILE: ${{ matrix.profile }} ENABLE_COVER_COMPILE: 1 + TEST: 1 + MIX_ENV: ${{ matrix.profile }}-test run: | make ensure-rebar3 - make ${PROFILE}-compile test-compile + # make ${PROFILE}-compile test-compile + env PROFILE=${PROFILE}-test mix do deps.get, deps.compile echo "PROFILE=${PROFILE}" | tee -a .env echo "PKG_VSN=$(./pkg-vsn.sh ${PROFILE})" | tee -a .env zip -ryq -x@.github/workflows/.zipignore $PROFILE.zip . diff --git a/.github/workflows/run_test_cases.yaml b/.github/workflows/run_test_cases.yaml index ef78df7f5..f6113cc96 100644 --- a/.github/workflows/run_test_cases.yaml +++ b/.github/workflows/run_test_cases.yaml @@ -54,11 +54,19 @@ jobs: run: | unzip -o -q ${{ matrix.profile }}.zip git config --global --add safe.directory "$GITHUB_WORKSPACE" - # produces eunit.coverdata + # TODO: produces eunit.coverdata - run: make eunit + env: + PROFILE: ${{ matrix.profile }}-test + MIX_ENV: ${{ matrix.profile }}-test + TEST: 1 - # produces proper.coverdata + # TODO produces proper.coverdata - run: make proper + env: + PROFILE: ${{ matrix.profile }}-test + MIX_ENV: ${{ matrix.profile }}-test + TEST: 1 - run: make cover @@ -113,6 +121,7 @@ jobs: ENABLE_COVER_COMPILE: 1 CT_COVER_EXPORT_PREFIX: ${{ matrix.profile }}-sg${{ matrix.suitegroup }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PROFILE: ${{ matrix.profile }}-test run: ./scripts/ct/run.sh --ci --app ${{ matrix.app }} --keep-up - name: make cover @@ -131,7 +140,7 @@ jobs: - name: compress logs if: failure() - run: tar -czf logs.tar.gz _build/test/logs + run: tar -czf logs.tar.gz _build/{test,${{ matrix.profile }}-test}/logs - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 if: failure() @@ -174,7 +183,11 @@ jobs: # produces $PROFILE---sg.coverdata - name: run common tests - run: make "${{ matrix.app }}-ct" + env: + TEST: 1 + MIX_ENV: ${{ matrix.profile }}-test + PROFILE: ${{ matrix.profile }}-test + run: make ensure-hex ensure-mix-rebar3 ensure-mix-rebar "${{ matrix.app }}-ct" - run: make cover @@ -191,7 +204,7 @@ jobs: - name: compress logs if: failure() - run: tar -czf logs.tar.gz _build/test/logs + run: tar -czf logs.tar.gz _build/{test,${{ matrix.profile }}-test}/logs - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 if: failure() @@ -223,4 +236,3 @@ jobs: git-commit: ${{ github.sha }} - run: echo "All tests passed" - diff --git a/Makefile b/Makefile index 69e821f5d..befe93804 100644 --- a/Makefile +++ b/Makefile @@ -28,6 +28,8 @@ CT_COVER_EXPORT_PREFIX ?= $(PROFILE) export REBAR_GIT_CLONE_OPTIONS += --depth=1 +ELIXIR_COMMON_DEPS := ensure-hex ensure-mix-rebar3 ensure-mix-rebar + .PHONY: default default: $(REBAR) $(PROFILE) @@ -59,18 +61,22 @@ ensure-mix-rebar: $(REBAR) @mix local.rebar --if-missing --force .PHONY: mix-deps-get -mix-deps-get: $(ELIXIR_COMMON_DEPS) +mix-deps-get: elixir-common-deps @mix deps.get +.PHONY: elixir-common-deps +elixir-common-deps: $(ELIXIR_COMMON_DEPS) + .PHONY: eunit -eunit: $(REBAR) ${ELIXIR_COMMON_DEPS} merge-config +eunit: $(REBAR) $(ELIXIR_COMMON_DEPS) merge-config # @$(REBAR) eunit --name eunit@127.0.0.1 -c -v --cover_export_name $(CT_COVER_EXPORT_PREFIX)-eunit # TODO: cover compile mix eunit .PHONY: proper proper: $(REBAR) - @$(REBAR) proper -d test/props -c + # @$(REBAR) proper -d test/props -c + mix proper .PHONY: test-compile test-compile: $(REBAR) merge-config @@ -114,13 +120,14 @@ define gen-app-ct-target $1-ct: $(REBAR) merge-config clean-test-cluster-config $(eval SUITES := $(shell $(SCRIPTS)/find-suites.sh $1)) ifneq ($(SUITES),) - $(REBAR) ct -v \ - --readable=$(CT_READABLE) \ - --name $(CT_NODE_NAME) \ - $(call cover_args,$1) \ - --suite $(SUITES) \ - $(GROUPS_ARG) \ - $(CASES_ARG) + mix ct --suites $(SUITES) + # $(REBAR) ct -v \ + # --readable=$(CT_READABLE) \ + # --name $(CT_NODE_NAME) \ + # $(call cover_args,$1) \ + # --suite $(SUITES) \ + # $(GROUPS_ARG) \ + # $(CASES_ARG) else @echo 'No suites found for $1' endif diff --git a/scripts/ct/run.sh b/scripts/ct/run.sh index 35ab0c209..9183e459a 100755 --- a/scripts/ct/run.sh +++ b/scripts/ct/run.sh @@ -104,7 +104,7 @@ ERLANG_CONTAINER='erlang' DOCKER_CT_ENVS_FILE="${WHICH_APP}/docker-ct" if [ -f "${WHICH_APP}/BSL.txt" ]; then - if [ -n "${PROFILE:-}" ] && [ "${PROFILE}" != 'emqx-enterprise' ]; then + if [ -n "${PROFILE:-}" ] && ! [[ "${PROFILE}" =~ emqx-enterprise* ]]; then echo "bad_profile: PROFILE=${PROFILE} will not work for app ${WHICH_APP}" exit 1 fi @@ -327,8 +327,11 @@ else -e SUITEGROUP="${SUITEGROUP:-}" \ -e ENABLE_COVER_COMPILE="${ENABLE_COVER_COMPILE:-}" \ -e CT_COVER_EXPORT_PREFIX="${CT_COVER_EXPORT_PREFIX:-}" \ + -e TEST=1 \ + -e MIX_ENV="${PROFILE}" \ + -e BUILD_WITHOUT_QUIC=1 \ -i $TTY "$ERLANG_CONTAINER" \ - bash -c "BUILD_WITHOUT_QUIC=1 make ${WHICH_APP}-ct" + bash -c "make ensure-hex ensure-mix-rebar3 ensure-mix-rebar; mix do deps.get, deps.compile; make ${WHICH_APP}-ct" else # this is an ad-hoc run docker exec -e IS_CI="$IS_CI" \