@@ -1729,15 +1729,17 @@ run_e2e_tests () {
1729
1729
# Expected args:
1730
1730
# 1. the app root dir
1731
1731
# 2. the app name
1732
- # 3. the s3 bucket where to upload artefacts (with a rclone remote, like ovh:e2e-test/blabla)
1733
- # 4. the rclone.conf file to use to upload artefacts
1734
- # 5. the file where the upload report will be written (json)
1732
+ # 3. the return code of the testing process
1733
+ # 4. the s3 bucket where to upload artefacts (with a rclone remote, like ovh:e2e-test/blabla)
1734
+ # 5. the rclone.conf file to use to upload artefacts
1735
+ # 6. the file where the upload report will be written (json)
1735
1736
upload_e2e_tests_artefacts () {
1736
1737
local ROOT_DIR=" $1 "
1737
1738
local APP=" $2 "
1738
- local S3_BUCKET=" $3 "
1739
- local RCLONE_CONF=" $4 "
1740
- local UPLOAD_REPORT_FILE=" $5 "
1739
+ local TESTS_RET_CODE=" $3 "
1740
+ local S3_BUCKET=" $4 "
1741
+ local RCLONE_CONF=" $5 "
1742
+ local UPLOAD_REPORT_FILE=" $6 "
1741
1743
1742
1744
local TIMESTAMP
1743
1745
TIMESTAMP=" $( date +" %d-%m-%Y" ) "
@@ -1791,7 +1793,7 @@ upload_e2e_tests_artefacts() {
1791
1793
local LOGS_LINK
1792
1794
LOGS_LINK=" $( rclone --config " $RCLONE_CONF " link " $REMOTE_DIR /logs.txt" ) "
1793
1795
1794
- printf ' { "app": "%s", "timestamp": "%s", "artefacts": "%s", "logs": "%s", "num_failed": "%d", "failed": [' " $APP " " $TIMESTAMP " " $ARTEFACTS_LINK " " $LOGS_LINK " " ${# FAILED_TESTS[@]} " > " $UPLOAD_REPORT_FILE "
1796
+ printf ' { "app": "%s", "timestamp": "%s", "ret_code": "%d", " artefacts": "%s", "logs": "%s", "num_failed": "%d", "failed": [' " $APP " " $TIMESTAMP " " $TESTS_RET_CODE " " $ARTEFACTS_LINK " " $LOGS_LINK " " ${# FAILED_TESTS[@]} " > " $UPLOAD_REPORT_FILE "
1795
1797
1796
1798
local COMMA=" "
1797
1799
for TEST_NAME in " ${FAILED_TESTS[@]} " ; do
@@ -1913,6 +1915,26 @@ push_e2e_tests_report_to_git_repo() {
1913
1915
rm -fR " $WORK_DIR "
1914
1916
}
1915
1917
1918
+ # Send the e2e tests report to a slack channel.
1919
+ # Expected args:
1920
+ # 1. the same upload report file as upload_e2e_tests_artefacts
1921
+ # 2. the slack channel webhook
1922
+ push_e2e_tests_report_to_slack () {
1923
+ local UPLOAD_REPORT_FILE=" $1 "
1924
+ local SLACK_WEBHOOK=" $2 "
1925
+
1926
+ local APP
1927
+ APP=$( get_json_value " $UPLOAD_REPORT_FILE " " app" )
1928
+ local TESTS_RET_CODE
1929
+ TESTS_RET_CODE=$( get_json_value " $UPLOAD_REPORT_FILE " " ret_code" )
1930
+ local ARTEFACTS_LINK
1931
+ ARTEFACTS_LINK=$( get_json_value " $UPLOAD_REPORT_FILE " " artefacts" )
1932
+ local LOGS_LINK
1933
+ LOGS_LINK=$( get_json_value " $UPLOAD_REPORT_FILE " " logs" )
1934
+
1935
+ slack_e2e_report " $APP " " $TESTS_RET_CODE " " $SLACK_WEBHOOK " " $LOGS_LINK " " $ARTEFACTS_LINK "
1936
+ }
1937
+
1916
1938
# Take all steps to run e2e test and push results to a git repository. Binary artefacts
1917
1939
# are uploaded on an s3 bucket.
1918
1940
# Expected args:
@@ -1931,6 +1953,7 @@ run_and_publish_e2e_tests_to_git_repo() {
1931
1953
local REPORTS_BASE=" $6 "
1932
1954
1933
1955
run_e2e_tests " $ROOT_DIR " " $APP "
1956
+ local TESTS_RET_CODE=" $? "
1934
1957
1935
1958
local MD_FLAVOR
1936
1959
[[ " $REPOSITORY_URL " = * gitlab* ]] && MD_FLAVOR=" gitlab"
@@ -1940,7 +1963,7 @@ run_and_publish_e2e_tests_to_git_repo() {
1940
1963
local MD_REPORT_FILE=" $TMP_DIR /e2e.md"
1941
1964
1942
1965
upload_e2e_tests_artefacts \
1943
- " $ROOT_DIR " " $APP " \
1966
+ " $ROOT_DIR " " $APP " " $TESTS_RET_CODE " \
1944
1967
" $S3_BUCKET " " $RCLONE_CONF " \
1945
1968
" $UPLOAD_REPORT_FILE "
1946
1969
generate_e2e_tests_markdown_report \
@@ -1949,3 +1972,31 @@ run_and_publish_e2e_tests_to_git_repo() {
1949
1972
" $UPLOAD_REPORT_FILE " " $MD_REPORT_FILE " \
1950
1973
" $REPOSITORY_URL " " $REPORTS_BASE "
1951
1974
}
1975
+
1976
+ # Take all steps to run e2e test and push results to a slack channel. Binary artefacts
1977
+ # are uploaded on an s3 bucket.
1978
+ # Expected args:
1979
+ # 1. the app root dir
1980
+ # 2. the app name
1981
+ # 3. the s3 bucket where to upload binary artefacts
1982
+ # 4. the rclone.conf file to use with rclone
1983
+ # 5. the slack channel webhook
1984
+ run_and_publish_e2e_tests_to_slack () {
1985
+ local ROOT_DIR=" $1 "
1986
+ local APP=" $2 "
1987
+ local S3_BUCKET=" $3 "
1988
+ local RCLONE_CONF=" $4 "
1989
+ local SLACK_WEBHOOK=" $5 "
1990
+
1991
+ run_e2e_tests " $ROOT_DIR " " $APP "
1992
+ local TESTS_RET_CODE=" $? "
1993
+
1994
+ local UPLOAD_REPORT_FILE=" $TMP_DIR /e2e-upload-report.json"
1995
+
1996
+ upload_e2e_tests_artefacts \
1997
+ " $ROOT_DIR " " $APP " " $TESTS_RET_CODE " \
1998
+ " $S3_BUCKET " " $RCLONE_CONF " \
1999
+ " $UPLOAD_REPORT_FILE "
2000
+ push_e2e_tests_report_to_slack \
2001
+ " $UPLOAD_REPORT_FILE " " $SLACK_WEBHOOK "
2002
+ }
0 commit comments