Merge "[ci] Register job reports as zuul atrifacts"

This commit is contained in:
Zuul 2020-02-25 14:25:00 +00:00 committed by Gerrit Code Review
commit 12404b8402
3 changed files with 28 additions and 29 deletions

View File

@ -1,15 +1,16 @@
- hosts: all
vars:
results_dir: "{{ zuul.project.src_dir }}/.test_results/"
html_report: "{{ tox_env }}_report.html"
json_report: "{{ tox_env }}_report.html"
tasks:
- name: Check the existence of results dir
stat:
path: '{{ results_dir }}'
- shell: "ls {{ results_dir }}"
register: results_dir_stat
ignore_errors: True
- name: Save results
become: yes
when: results_dir_stat.stat.exists == True
when: results_dir_stat.rc == 0
synchronize:
src: "{{ results_dir }}"
dest: '{{ zuul.executor.log_root }}/'
@ -21,3 +22,21 @@
- --include=*/
- --exclude=*
- --prune-empty-dirs
- name: Return artifact to Zuul
when: html_report in results_dir_stat.stdout
zuul_return:
data:
zuul:
artifacts:
- name: "HTML report"
url: "{{ html_report }}"
- name: Return artifact to Zuul
when: json_report in results_dir_stat.stdout
zuul_return:
data:
zuul:
artifacts:
- name: "JSON report"
url: "{{ json_report }}"

View File

@ -17,9 +17,8 @@ import subprocess
import sys
PYTEST_REPORT = os.environ.get("PYTEST_REPORT",
".test_results/pytest_results.html")
TESTR_REPORT = "testr_results.html"
DEFAULT_REPORT = ".test_results/%s_report.html" % os.environ["TOX_ENV_NAME"]
PYTEST_REPORT = os.environ.get("PYTEST_REPORT", DEFAULT_REPORT)
PYTEST_ARGUMENTS = ("py.test" # base command
" -vv" # show test names in logs
" --html=%(html_report)s" # html report
@ -86,17 +85,7 @@ def main(args):
print("Test(s) to launch (pytest format): %s" % path)
# NOTE(andreykurilin): we cannot publish pytest reports at gates, but we
# can mask them as testr reports. It looks like a dirty hack and I
# prefer to avoid it, but I see no other solutions at this point.
# apply dirty hack only in gates.
if os.environ.get("ZUUL_PROJECT"):
pytest_report = TESTR_REPORT
else:
pytest_report = PYTEST_REPORT
args = PYTEST_ARGUMENTS % {"html_report": pytest_report,
args = PYTEST_ARGUMENTS % {"html_report": PYTEST_REPORT,
"path": path,
"concurrency": args.concurrency or "auto"}
try:
@ -104,15 +93,6 @@ def main(args):
stderr=subprocess.STDOUT)
except subprocess.CalledProcessError:
# NOTE(andreykurilin): it is ok, since tests can fail.
exit_code = 1
else:
exit_code = 0
if os.path.exists(pytest_report) and os.environ.get("ZUUL_PROJECT"):
subprocess.check_call(["gzip", "-9", "-f", pytest_report],
stderr=subprocess.STDOUT)
if exit_code == 1:
error("")

View File

@ -16,8 +16,8 @@ TASK_FILE=$1
PLUGIN_PATHS=rally-jobs/plugins
mkdir -p .test_results
HTML_REPORT=.test_results/rally_self_report.html
JSON_REPORT=.test_results/rally_self_results.json
HTML_REPORT=.test_results/self_report.html
JSON_REPORT=.test_results/self_report.json
RND=$(head /dev/urandom | tr -dc a-z0-9 | head -c 5)
TMP_RALLY_CONF="/tmp/self-rally-$RND.conf"