-
Notifications
You must be signed in to change notification settings - Fork 250
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat_: functional tests coverage (#5805)
* feat_: functional tests coverage * fix_: codecov yaml
- Loading branch information
1 parent
77ef8f1
commit d794e43
Showing
9 changed files
with
211 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,46 @@ | ||
# When modifying this file, please validate using: | ||
# make codecov-validate | ||
|
||
codecov: | ||
require_ci_to_pass: false | ||
notify: | ||
wait_for_ci: true | ||
|
||
coverage: | ||
require_ci_to_pass: no | ||
wait_for_ci: no | ||
status: | ||
project: | ||
default: | ||
informational: true | ||
unit-tests: | ||
target: auto | ||
flags: | ||
- unit | ||
functional-tests: | ||
target: auto | ||
flags: | ||
- functional | ||
patch: | ||
default: | ||
informational: true | ||
unit-tests: | ||
target: auto | ||
flags: | ||
- unit | ||
functional-tests: | ||
target: auto | ||
flags: | ||
- functional | ||
|
||
# When modifying this file, please validate using: | ||
# make codecov-validate | ||
flags: | ||
unit-tests: | ||
paths: | ||
- ".*" | ||
carryforward: false | ||
functional-tests: | ||
paths: | ||
- ".*" | ||
carryforward: true | ||
|
||
comment: | ||
behavior: default | ||
layout: diff,flags,tree |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/env bash | ||
|
||
source "${GIT_ROOT}/_assets/scripts/colors.sh" | ||
|
||
report_to_codecov() { | ||
# https://go.dev/blog/integration-test-coverage | ||
echo -e "${GRN}Uploading coverage report to Codecov${RST}" | ||
|
||
local tests_report_wildcard="${1}" | ||
local coverage_report="${2}" | ||
local flag="${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 "${flag}" | ||
} | ||
|
||
convert_coverage_to_html() { | ||
echo -e "${GRN}Generating HTML coverage report${RST}" | ||
|
||
local input_coverage_report="${1}" | ||
local output_coverage_report="${2}" | ||
|
||
go tool cover -html "${input_coverage_report}" -o "${output_coverage_report}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -o nounset | ||
|
||
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}" | ||
|
||
root_path="${GIT_ROOT}/integration-tests" | ||
coverage_reports_path="${root_path}/coverage" | ||
binary_coverage_reports_path="${coverage_reports_path}/binary" | ||
merged_coverage_reports_path="${coverage_reports_path}/merged" | ||
test_results_path="${root_path}/reports" | ||
|
||
# Cleanup any previous coverage reports | ||
rm -rf "${coverage_reports_path}" | ||
rm -rf "${test_results_path}" | ||
|
||
# Create directories | ||
mkdir -p "${binary_coverage_reports_path}" | ||
mkdir -p "${merged_coverage_reports_path}" | ||
mkdir -p "${test_results_path}" | ||
|
||
all_compose_files="-f ${root_path}/docker-compose.anvil.yml -f ${root_path}/docker-compose.test.status-go.yml" | ||
|
||
# Run integration tests | ||
echo -e "${GRN}Running tests${RST}, HEAD: $(git rev-parse HEAD)" | ||
docker-compose ${all_compose_files} up -d --build --remove-orphans | ||
|
||
echo -e "${GRN}Running tests-rpc${RST}" # Follow the logs, wait for them to finish | ||
docker-compose ${all_compose_files} logs -f tests-rpc > "${root_path}/tests-rpc.log" | ||
|
||
# Stop containers | ||
echo -e "${GRN}Stopping docker containers${RST}" | ||
docker-compose ${all_compose_files} stop | ||
|
||
# Save logs | ||
echo -e "${GRN}Saving logs${RST}" | ||
docker-compose ${all_compose_files} logs status-go > "${root_path}/statusd.log" | ||
docker-compose ${all_compose_files} logs status-go-no-funds > "${root_path}/statusd-no-funds.log" | ||
|
||
# Retrieve exit code | ||
exit_code=$(docker inspect integration-tests_tests-rpc_1 -f '{{.State.ExitCode}}'); | ||
|
||
# Cleanup containers | ||
echo -e "${GRN}Removing docker containers${RST}" | ||
docker-compose ${all_compose_files} down | ||
|
||
# Collect coverage reports | ||
echo -e "${GRN}Collecting code coverage reports${RST}" | ||
full_coverage_profile="${coverage_reports_path}/coverage.out" | ||
go tool covdata merge -i="${binary_coverage_reports_path}" -o="${merged_coverage_reports_path}" | ||
go tool covdata textfmt -i="${merged_coverage_reports_path}" -o="${full_coverage_profile}" | ||
convert_coverage_to_html "${full_coverage_profile}" "${coverage_reports_path}/coverage.html" | ||
|
||
# Upload reports to Codecov | ||
if [[ ${INTEGRATION_TESTS_REPORT_CODECOV} == 'true' ]]; then | ||
report_to_codecov "${test_results_path}/*.xml" "${full_coverage_profile}" "functional" | ||
fi | ||
|
||
echo -e "${GRN}Testing finished${RST}" | ||
exit $exit_code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters