]> source.dussan.org Git - rspamd.git/commitdiff
Share robot log and report on https://ci.rspamd.com/testlogs/
authorAnton Yuzhaninov <citrin+git@citrin.ru>
Tue, 23 Oct 2018 02:19:29 +0000 (22:19 -0400)
committerAnton Yuzhaninov <citrin+git@citrin.ru>
Tue, 23 Oct 2018 02:56:05 +0000 (22:56 -0400)
Sending functional test log (about 5Mb) in a email attachmend was temporary
solution.
Upload them to https://ci.rspamd.com/testlogs/ instead.
Link to log/report will be printed in build log.

.drone.yml
test/tools/http_put.py [new file with mode: 0755]

index 76962e6e60677abda18b95ca11e96e37683716dc..7db345c6349d8918d9331baa99a338159d6a148c 100644 (file)
@@ -93,9 +93,17 @@ pipeline:
       # some rspamd processes during this test work as root and some as nobody
       # use umask to create world-writable files so nobody can write to *.gcda files created by root
       - umask 0000
+      - set +e
       - RSPAMD_INSTALLROOT=/rspamd/install robot --xunit xunit.xml --exclude isbroken $CI_WORKSPACE/test/functional/cases; EXIT_CODE=$?
+      - set -e
+      # upload test results to nginx frontent using WebDAV PUT
+      - >
+        if [ -n "$HTTP_PUT_AUTH" ]; then
+               $CI_WORKSPACE/test/tools/http_put.py log.html report.html $CI_SYSTEM_LINK/testlogs/$CI_REPO_NAME/$CI_BUILD_NUMBER/;
+        fi
       - find /var/tmp/ -name '*.core'
       - exit $EXIT_CODE
+    secrets: [http_put_auth]
 
   send-coverage:
     image: rspamd/ci-ubuntu-test
@@ -113,10 +121,9 @@ pipeline:
       # don't send coverage report for pull request
       event: [push, tag]
 
-  send-test-log:
+  notify:
     image: drillster/drone-email
     from: noreply@rspamd.com
-    attachment: /rspamd/build/log.html
     secrets: [email_host, email_username, email_password]
     when:
       status: failure
diff --git a/test/tools/http_put.py b/test/tools/http_put.py
new file mode 100755 (executable)
index 0000000..dab9a21
--- /dev/null
@@ -0,0 +1,51 @@
+#!/usr/bin/env python3
+"""
+Small script to upload file using HTTP PUT
+"""
+
+import argparse
+import os
+import sys
+
+import requests
+
+
+def main():
+    parser = argparse.ArgumentParser(
+        description='Upload a file usgin HTTP PUT method',
+        epilog=(
+            "To use HTTP Auth set HTTP_PUT_AUTH environment variable to user:password\n"
+            "Example: %(prog)s file1 file2 https://example.com/dir/"))
+    parser.add_argument(
+        "file", type=argparse.FileType('rb'), nargs='+', help="File to upload")
+    parser.add_argument(
+        "dir_url", help="Remote URL (path to a directory, must ends with /)")
+    args = parser.parse_args()
+
+    if not args.dir_url.endswith('/'):
+        parser.error("URL must ends with /")
+
+    http_auth = os.getenv('HTTP_PUT_AUTH')
+    if http_auth:
+        user, password = http_auth.split(':')
+        auth = (user, password)
+    else:
+        auth = None
+
+    exit_code = 0
+
+    for fh in args.file:
+        try:
+            r = requests.put(args.dir_url + fh.name, data=fh, auth=auth, timeout=(45, 90))
+            r.raise_for_status()
+            print("{} uploaded to {}".format(fh.name, r.url))
+        except (requests.exceptions.ConnectionError,
+                requests.exceptions.HTTPError) as err:
+            print(err, file=sys.stderr)
+            exit_code = 1
+
+    return exit_code
+
+
+if __name__ == '__main__':
+    sys.exit(main())