Github user JoshRosen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/7401#discussion_r34611604
  
    --- Diff: dev/run-tests-jenkins.py ---
    @@ -0,0 +1,253 @@
    +#!/usr/bin/env python2
    +
    +#
    +# Licensed to the Apache Software Foundation (ASF) under one or more
    +# contributor license agreements.  See the NOTICE file distributed with
    +# this work for additional information regarding copyright ownership.
    +# The ASF licenses this file to You under the Apache License, Version 2.0
    +# (the "License"); you may not use this file except in compliance with
    +# the License.  You may obtain a copy of the License at
    +#
    +#    http://www.apache.org/licenses/LICENSE-2.0
    +#
    +# Unless required by applicable law or agreed to in writing, software
    +# distributed under the License is distributed on an "AS IS" BASIS,
    +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +# See the License for the specific language governing permissions and
    +# limitations under the License.
    +#
    +
    +from __future__ import print_function
    +import os
    +import sys
    +import json
    +import subprocess
    +
    +from sparktestsupport import SPARK_HOME, ERROR_CODES
    +from sparktestsupport.shellutils import exit_from_command_with_retcode, 
run_cmd, rm_r
    +
    +
    +def print_err(*args):
    +    """
    +    Given a set of arguments, will print them to the STDERR stream
    +    """
    +    print(*args, file=sys.stderr)
    +
    +
    +def post_message(mssg, comments_url):
    +    http_code_header = "HTTP Response Code: "
    +    posted_message = json.dumps({"body": mssg})
    +
    +    print("Attempting to post to Github...")
    +
    +    # we don't want to call `run_cmd` here as, in the event of an error, 
we DO NOT
    +    # want to print the GITHUB_OAUTH_KEY into the public Jenkins logs
    +    curl_proc = subprocess.Popen(['curl',
    +                                  '--silent',
    +                                  '--user', 'x-oauth-basic:' + 
os.environ['GITHUB_OATH_KEY'],
    +                                  '--request', 'POST',
    +                                  '--data', posted_message,
    +                                  '--write-out', http_code_header + 
'%{http_code}',
    +                                  '--header', 'Content-Type: 
application/json',
    +                                  comments_url],
    +                                 stdout=subprocess.PIPE,
    +                                 stderr=subprocess.PIPE)
    +    curl_stdout, curl_stderr = curl_proc.communicate()
    +    curl_returncode = curl_proc.returncode
    +    # find all lines relevant to the Github API response
    +    api_response = "\n".join([l for l in curl_stdout.split('\n')
    +                              if l and not l.startswith(http_code_header)])
    +    # find the line where `http_code_header` exists, split on ':' to get 
the
    +    # HTTP response code, and cast to an int
    +    http_code = 
int(curl_stdout[curl_stdout.find(http_code_header):].split(':')[1])
    +
    +    if not curl_returncode == 0:
    +        print_err("Failed to post message to GitHub.")
    +        print_err(" > curl_status:", curl_returncode)
    +        print_err(" > curl_output:", curl_stdout)
    +        print_err(" > data:", posted_message)
    +
    +    if http_code and not http_code == 201:
    +        print_err(" > http_code:", http_code)
    +        print_err(" > api_response:", api_response)
    +        print_err(" > data:", posted_message)
    +
    +    if curl_returncode == 0 and http_code == 201:
    +        print(" > Post successful.")
    +
    +
    +def send_archived_logs():
    +    print("Archiving unit tests logs...")
    +
    +    log_files = run_cmd(['find', '.',
    +                         '-name', 'unit-tests.log',
    +                         '-o', '-path', 
'./sql/hive/target/HiveCompatibilitySuite.failed',
    +                         '-o', '-path', 
'./sql/hive/target/HiveCompatibilitySuite.hiveFailed',
    +                         '-o', '-path', 
'./sql/hive/target/HiveCompatibilitySuite.wrong'],
    +                        return_output=True)
    +
    +    if log_files:
    +        log_archive = "unit-tests-logs.tar.gz"
    +
    +        run_cmd(['tar', 'czf', log-archive] + 
log_files.strip().split('\n'))
    +
    +        jenkins_build_dir = os.environ["JENKINS_HOME"] + "/jobs/" + 
os.environ["JOB_NAME"] +
    +        "/builds/" + os.environ["BUILD_NUMBER"]
    +
    +        scp_proc = subprocess.Popen(['scp', log_archive,
    --- End diff --
    
    @andrewor14, do you think that we even need this manual archiving of 
`unit-tests.log` now that we have the Jenkins build artifact attachment plugin 
for this?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to