ci: ct testing with mix

This commit is contained in:
Thales Macedo Garitezi 2024-06-18 17:31:37 -03:00
parent 8843fcbbf4
commit b38e7066a5
5 changed files with 45 additions and 19 deletions

1
.github/workflows/.zipignore2 vendored Normal file
View File

@ -0,0 +1 @@
*/.github/*

View File

@ -146,9 +146,12 @@ jobs:
env: env:
PROFILE: ${{ matrix.profile }} PROFILE: ${{ matrix.profile }}
ENABLE_COVER_COMPILE: 1 ENABLE_COVER_COMPILE: 1
TEST: 1
MIX_ENV: ${{ matrix.profile }}-test
run: | run: |
make ensure-rebar3 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 "PROFILE=${PROFILE}" | tee -a .env
echo "PKG_VSN=$(./pkg-vsn.sh ${PROFILE})" | tee -a .env echo "PKG_VSN=$(./pkg-vsn.sh ${PROFILE})" | tee -a .env
zip -ryq -x@.github/workflows/.zipignore $PROFILE.zip . zip -ryq -x@.github/workflows/.zipignore $PROFILE.zip .

View File

@ -54,11 +54,19 @@ jobs:
run: | run: |
unzip -o -q ${{ matrix.profile }}.zip unzip -o -q ${{ matrix.profile }}.zip
git config --global --add safe.directory "$GITHUB_WORKSPACE" git config --global --add safe.directory "$GITHUB_WORKSPACE"
# produces eunit.coverdata # TODO: produces eunit.coverdata
- run: make eunit - 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 - run: make proper
env:
PROFILE: ${{ matrix.profile }}-test
MIX_ENV: ${{ matrix.profile }}-test
TEST: 1
- run: make cover - run: make cover
@ -113,6 +121,7 @@ jobs:
ENABLE_COVER_COMPILE: 1 ENABLE_COVER_COMPILE: 1
CT_COVER_EXPORT_PREFIX: ${{ matrix.profile }}-sg${{ matrix.suitegroup }} CT_COVER_EXPORT_PREFIX: ${{ matrix.profile }}-sg${{ matrix.suitegroup }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PROFILE: ${{ matrix.profile }}-test
run: ./scripts/ct/run.sh --ci --app ${{ matrix.app }} --keep-up run: ./scripts/ct/run.sh --ci --app ${{ matrix.app }} --keep-up
- name: make cover - name: make cover
@ -131,7 +140,7 @@ jobs:
- name: compress logs - name: compress logs
if: failure() 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 - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
if: failure() if: failure()
@ -174,7 +183,11 @@ jobs:
# produces $PROFILE-<app-name>-<otp-vsn>-sg<suitegroup>.coverdata # produces $PROFILE-<app-name>-<otp-vsn>-sg<suitegroup>.coverdata
- name: run common tests - 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 - run: make cover
@ -191,7 +204,7 @@ jobs:
- name: compress logs - name: compress logs
if: failure() 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 - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
if: failure() if: failure()
@ -223,4 +236,3 @@ jobs:
git-commit: ${{ github.sha }} git-commit: ${{ github.sha }}
- run: echo "All tests passed" - run: echo "All tests passed"

View File

@ -28,6 +28,8 @@ CT_COVER_EXPORT_PREFIX ?= $(PROFILE)
export REBAR_GIT_CLONE_OPTIONS += --depth=1 export REBAR_GIT_CLONE_OPTIONS += --depth=1
ELIXIR_COMMON_DEPS := ensure-hex ensure-mix-rebar3 ensure-mix-rebar
.PHONY: default .PHONY: default
default: $(REBAR) $(PROFILE) default: $(REBAR) $(PROFILE)
@ -59,18 +61,22 @@ ensure-mix-rebar: $(REBAR)
@mix local.rebar --if-missing --force @mix local.rebar --if-missing --force
.PHONY: mix-deps-get .PHONY: mix-deps-get
mix-deps-get: $(ELIXIR_COMMON_DEPS) mix-deps-get: elixir-common-deps
@mix deps.get @mix deps.get
.PHONY: elixir-common-deps
elixir-common-deps: $(ELIXIR_COMMON_DEPS)
.PHONY: eunit .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 # @$(REBAR) eunit --name eunit@127.0.0.1 -c -v --cover_export_name $(CT_COVER_EXPORT_PREFIX)-eunit
# TODO: cover compile # TODO: cover compile
mix eunit mix eunit
.PHONY: proper .PHONY: proper
proper: $(REBAR) proper: $(REBAR)
@$(REBAR) proper -d test/props -c # @$(REBAR) proper -d test/props -c
mix proper
.PHONY: test-compile .PHONY: test-compile
test-compile: $(REBAR) merge-config test-compile: $(REBAR) merge-config
@ -114,13 +120,14 @@ define gen-app-ct-target
$1-ct: $(REBAR) merge-config clean-test-cluster-config $1-ct: $(REBAR) merge-config clean-test-cluster-config
$(eval SUITES := $(shell $(SCRIPTS)/find-suites.sh $1)) $(eval SUITES := $(shell $(SCRIPTS)/find-suites.sh $1))
ifneq ($(SUITES),) ifneq ($(SUITES),)
$(REBAR) ct -v \ mix ct --suites $(SUITES)
--readable=$(CT_READABLE) \ # $(REBAR) ct -v \
--name $(CT_NODE_NAME) \ # --readable=$(CT_READABLE) \
$(call cover_args,$1) \ # --name $(CT_NODE_NAME) \
--suite $(SUITES) \ # $(call cover_args,$1) \
$(GROUPS_ARG) \ # --suite $(SUITES) \
$(CASES_ARG) # $(GROUPS_ARG) \
# $(CASES_ARG)
else else
@echo 'No suites found for $1' @echo 'No suites found for $1'
endif endif

View File

@ -104,7 +104,7 @@ ERLANG_CONTAINER='erlang'
DOCKER_CT_ENVS_FILE="${WHICH_APP}/docker-ct" DOCKER_CT_ENVS_FILE="${WHICH_APP}/docker-ct"
if [ -f "${WHICH_APP}/BSL.txt" ]; then 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}" echo "bad_profile: PROFILE=${PROFILE} will not work for app ${WHICH_APP}"
exit 1 exit 1
fi fi
@ -327,8 +327,11 @@ else
-e SUITEGROUP="${SUITEGROUP:-}" \ -e SUITEGROUP="${SUITEGROUP:-}" \
-e ENABLE_COVER_COMPILE="${ENABLE_COVER_COMPILE:-}" \ -e ENABLE_COVER_COMPILE="${ENABLE_COVER_COMPILE:-}" \
-e CT_COVER_EXPORT_PREFIX="${CT_COVER_EXPORT_PREFIX:-}" \ -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" \ -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 else
# this is an ad-hoc run # this is an ad-hoc run
docker exec -e IS_CI="$IS_CI" \ docker exec -e IS_CI="$IS_CI" \