feat_: integration tests coverage
This commit is contained in:
parent
b2a4f100f9
commit
edffaae9f3
|
@ -108,3 +108,5 @@ __pycache__/
|
|||
.pytest_cache/
|
||||
.envrc
|
||||
report/results.xml
|
||||
integration-tests/coverage
|
||||
integration-tests/reports
|
||||
|
|
11
Makefile
11
Makefile
|
@ -488,14 +488,11 @@ test-verif-proxy-wrapper:
|
|||
CGO_CFLAGS="$(CGO_CFLAGS)" go test -v github.com/status-im/status-go/rpc -tags gowaku_skip_migrations,nimbus_light_client -run ^TestProxySuite$$ -testify.m TestRun -ldflags $(LDFLAGS)
|
||||
|
||||
|
||||
run-integration-tests: SHELL := /bin/sh
|
||||
run-integration-tests: export INTEGRATION_TESTS_DOCKER_UID ?= $(shell id -u $$USER)
|
||||
#run-integration-tests: SHELL := /bin/sh # Run not in nix-shell, we need codecov
|
||||
run-integration-tests: export INTEGRATION_TESTS_DOCKER_UID ?= $(call sh, id -u $$USER)
|
||||
run-integration-tests: export INTEGRATION_TESTS_REPORT_CODECOV = false
|
||||
run-integration-tests:
|
||||
docker-compose -f integration-tests/docker-compose.anvil.yml -f integration-tests/docker-compose.test.status-go.yml up -d --build --remove-orphans; \
|
||||
docker-compose -f integration-tests/docker-compose.anvil.yml -f integration-tests/docker-compose.test.status-go.yml logs -f tests-rpc; \
|
||||
exit_code=$$(docker inspect integration-tests_tests-rpc_1 -f '{{.State.ExitCode}}'); \
|
||||
docker-compose -f integration-tests/docker-compose.anvil.yml -f integration-tests/docker-compose.test.status-go.yml down; \
|
||||
exit $$exit_code
|
||||
@./_assets/scripts/run_integration_tests.sh
|
||||
|
||||
run-anvil: SHELL := /bin/sh
|
||||
run-anvil:
|
||||
|
|
|
@ -42,11 +42,11 @@ pipeline {
|
|||
always {
|
||||
script {
|
||||
archiveArtifacts(
|
||||
artifacts: '**/results.xml',
|
||||
artifacts: 'reports/*.xml',
|
||||
allowEmptyArchive: true,
|
||||
)
|
||||
junit(
|
||||
testResults: '**/results.xml',
|
||||
testResults: 'reports/*.xml',
|
||||
skipOldReports: true,
|
||||
skipPublishingChecks: true,
|
||||
skipMarkingBuildUnstable: true,
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
source "${GIT_ROOT}/_assets/scripts/colors.sh"
|
||||
|
||||
report_to_codecov() {
|
||||
# https://docs.codeclimate.com/docs/jenkins#jenkins-ci-builds
|
||||
echo -e "${GRN}Uploading coverage report to Codecov${RST}"
|
||||
|
||||
local tests_report_wildcard="${1}"
|
||||
local coverage_report="${2}"
|
||||
local test_type="${3}"
|
||||
|
||||
# Gather report files with given wildcard
|
||||
local report_files_args=""
|
||||
for file in ${tests_report_wildcard}; do
|
||||
report_files_args+="--file ${file} "
|
||||
done
|
||||
|
||||
codecov do-upload --token "${CODECOV_TOKEN}" --report-type test_results ${report_files_args}
|
||||
codecov upload-process --token "${CODECOV_TOKEN}" -f ${coverage_report} -F "${test_type}"
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel)
|
||||
source "${GIT_ROOT}/_assets/scripts/colors.sh"
|
||||
source "${GIT_ROOT}/_assets/scripts/codecov.sh"
|
||||
|
||||
echo -e "${GRN}Running integration tests${RST}, HEAD: $(git rev-parse HEAD)"
|
||||
|
||||
root_path=./integration-tests
|
||||
coverage_reports_path="${root_path}/coverage"
|
||||
|
||||
# Cleanup any previous coverage reports
|
||||
rm -rf ${coverage_reports_path}
|
||||
|
||||
# Run integration tests
|
||||
docker-compose \
|
||||
-f ${root_path}/docker-compose.anvil.yml \
|
||||
-f ${root_path}/docker-compose.test.status-go.yml \
|
||||
up -d --build --remove-orphans;
|
||||
|
||||
# Save logs
|
||||
docker-compose \
|
||||
-f ${root_path}/docker-compose.anvil.yml \
|
||||
-f ${root_path}/docker-compose.test.status-go.yml \
|
||||
logs -f tests-rpc;
|
||||
|
||||
# Retrieve exit code
|
||||
exit_code=$(docker inspect integration-tests_tests-rpc_1 -f '{{.State.ExitCode}}');
|
||||
|
||||
# Stop and remove containers
|
||||
docker-compose \
|
||||
-f ${root_path}/docker-compose.anvil.yml \
|
||||
-f ${root_path}/docker-compose.test.status-go.yml \
|
||||
down;
|
||||
|
||||
# Early exit if tests failed
|
||||
if [[ "$exit_code" -ne 0 ]]; then
|
||||
exit $exit_code
|
||||
fi
|
||||
|
||||
# Report to Codecov
|
||||
if [[ ${INTEGRATION_TESTS_REPORT_CODECOV} == 'true' ]]; then
|
||||
# Docs: https://go.dev/blog/integration-test-coverage
|
||||
binary_coverage_reports_path="${coverage_reports_path}/binary"
|
||||
merged_coverage_reports_path="${coverage_reports_path}/merged"
|
||||
full_coverage_profile="${coverage_reports_path}/coverage.out"
|
||||
test_results_path="${root_path}/reports"
|
||||
|
||||
# Clean merged reports directory
|
||||
mkdir -p ${merged_coverage_reports_path}
|
||||
|
||||
# Merge coverage reports
|
||||
go tool covdata merge -i=${binary_coverage_reports_path} -o=${merged_coverage_reports_path}
|
||||
|
||||
# Convert coverage reports to profile
|
||||
go tool covdata textfmt -i=${merged_coverage_reports_path} -o=${full_coverage_profile}
|
||||
|
||||
# Upload reports to Codecov
|
||||
report_to_codecov "${test_results_path}/*.xml" "${full_coverage_profile}" "integration"
|
||||
fi
|
|
@ -2,8 +2,8 @@
|
|||
set -o pipefail
|
||||
|
||||
GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel)
|
||||
|
||||
source "${GIT_ROOT}/_assets/scripts/colors.sh"
|
||||
source "${GIT_ROOT}/_assets/scripts/codecov.sh"
|
||||
|
||||
if [[ $UNIT_TEST_RERUN_FAILS == 'true' ]]; then
|
||||
GOTESTSUM_EXTRAFLAGS="${GOTESTSUM_EXTRAFLAGS} --rerun-fails"
|
||||
|
@ -162,14 +162,7 @@ if [[ $UNIT_TEST_REPORT_CODECLIMATE == 'true' ]]; then
|
|||
fi
|
||||
|
||||
if [[ $UNIT_TEST_REPORT_CODECOV == 'true' ]]; then
|
||||
echo -e "${GRN}Uploading coverage report to Codecov${RST}"
|
||||
# https://docs.codeclimate.com/docs/jenkins#jenkins-ci-builds
|
||||
codecov_report_files_args=""
|
||||
for file in report_*.xml; do
|
||||
codecov_report_files_args+="--file ${file} "
|
||||
done
|
||||
codecov do-upload --token "${CODECOV_TOKEN}" --report-type test_results ${codecov_report_files_args}
|
||||
codecov --token "${CODECOV_TOKEN}" -f ${final_coverage_report} -F "unit"
|
||||
report_to_codecov "report_*.xml" ${final_coverage_report} "unit"
|
||||
fi
|
||||
|
||||
# Generate report with test stats
|
||||
|
|
|
@ -16,10 +16,11 @@ services:
|
|||
timeout: 2s
|
||||
retries: 120
|
||||
environment:
|
||||
GOCOVERDIR: "./coverage/integration"
|
||||
GOCOVERDIR: "./coverage/binary"
|
||||
volumes:
|
||||
- ./coverage:./coverage/integration
|
||||
- ./coverage:/coverage
|
||||
|
||||
# TODO: Remove this duplication when implemented: https://github.com/status-im/status-go/issues/5803
|
||||
status-go-no-funds:
|
||||
build:
|
||||
context: ../
|
||||
|
@ -37,9 +38,9 @@ services:
|
|||
timeout: 2s
|
||||
retries: 120
|
||||
environment:
|
||||
GOCOVERDIR: "./coverage/integration"
|
||||
GOCOVERDIR: "/coverage/binary"
|
||||
volumes:
|
||||
- ./coverage:./coverage/integration
|
||||
- ./coverage:/coverage
|
||||
|
||||
tests-rpc:
|
||||
user: ${INTEGRATION_TESTS_DOCKER_UID}
|
||||
|
@ -53,6 +54,12 @@ services:
|
|||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.tests-rpc
|
||||
entrypoint: ["pytest", "-m", "wallet", "--rpc_url=http://status-go:3333", "--rpc_url_2=http://status-go-no-funds:3333"]
|
||||
entrypoint: [
|
||||
"pytest",
|
||||
"-m", "wallet",
|
||||
"--rpc_url=http://status-go:3333",
|
||||
"--rpc_url_2=http://status-go-no-funds:3333",
|
||||
"--junitxml=/tests-rpc/reports/report.xml",
|
||||
]
|
||||
volumes:
|
||||
- .:/tests-rpc
|
||||
|
|
Loading…
Reference in New Issue