import sys
import uuid

if __name__ == '__main__':
    sys.path.insert(
        0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

from phabtalk.phabtalk import PhabTalk
from buildkite.utils import format_url

if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('--log-level', type=str, default='WARNING')
    parser.add_argument('--success', action='store_true')
    args = parser.parse_args()
    logging.basicConfig(level=args.log_level,
                        format='%(levelname)-7s %(message)s')
    phabtalk = PhabTalk(os.getenv('CONDUIT_TOKEN'),
                        'https://reviews.llvm.org/api/', False)
    build_url = f'https://reviews.llvm.org/harbormaster/build/{os.getenv("ph_build_id")}'
    print(f'Reporting results to Phabricator build {format_url(build_url)}',
          flush=True)
    ph_buildable_diff = os.getenv('ph_buildable_diff')
    ph_target_phid = os.getenv('ph_target_phid')
    phabtalk.update_build_status(ph_buildable_diff, ph_target_phid, False,
                                 args.success)
    bug_url = f'https://github.com/google/llvm-premerge-checks/issues/new?assignees=&labels=bug' \
              f'&template=bug_report.md&title=buildkite build {os.getenv("BUILDKITE_PIPELINE_SLUG")} ' \
              f'{os.getenv("BUILDKITE_BUILD_NUMBER")}'
    print(f'{format_url(bug_url, "report issue")}', flush=True)
Пример #2
0
if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('--log-level', type=str, default='INFO')
    args = parser.parse_args()
    logging.basicConfig(level=args.log_level,
                        format='%(levelname)-7s %(message)s')
    ph_buildable_diff = os.getenv('ph_buildable_diff')
    ph_target_phid = os.getenv('ph_target_phid')
    if ph_target_phid is None:
        logging.warning(
            'ph_target_phid is not specified. Will not update the build status in Phabricator'
        )
        exit(0)
    phabtalk = PhabTalk(os.getenv('CONDUIT_TOKEN'),
                        dry_run_updates=(os.getenv('ph_dry_run_report')
                                         is not None))
    report_success = False  # for try block
    failed_tests = []
    try:
        bk = BuildkiteApi(os.getenv("BUILDKITE_API_TOKEN"),
                          os.getenv("BUILDKITE_ORGANIZATION_SLUG"))
        build = bk.get_build(os.getenv("BUILDKITE_PIPELINE_SLUG"),
                             os.getenv("BUILDKITE_BUILD_NUMBER"))
        success = True
        failed_tests = process_unit_test_reports(bk, build, '')
        for i, job in enumerate(build.get('jobs', [])):
            job = benedict(job)
            job_web_url = job.get('web_url',
                                  os.getenv('BUILDKITE_BUILD_URL', ''))
            logging.info(f'{job.get("id")} state {job.get("state")}')
Пример #3
0
              f'builds/{os.getenv("BUILDKITE_TRIGGERED_FROM_BUILD_NUMBER")}'
        print(f'Triggered from build {format_url(url)}', flush=True)
    ph_target_phid = os.getenv('ph_target_phid')
    if ph_target_phid is None:
        logging.warning(
            'ph_target_phid is not specified. Will not update the build status in Phabricator'
        )
        exit(0)

    bk = BuildkiteApi(os.getenv("BUILDKITE_API_TOKEN"),
                      os.getenv("BUILDKITE_ORGANIZATION_SLUG"))
    build = bk.get_build(os.getenv("BUILDKITE_PIPELINE_SLUG"),
                         os.getenv("BUILDKITE_BUILD_NUMBER"))
    success = True
    build.setdefault('jobs', [])
    for j in build['jobs']:
        j.setdefault('state', '')
        j.setdefault('id', '')
        logging.info(f'{j["id"]} state {j["state"]}')
        success = success and (j['state'] != 'failed')

    phabtalk = PhabTalk(os.getenv('CONDUIT_TOKEN'))
    build_url = f'https://reviews.llvm.org/harbormaster/build/{os.getenv("ph_build_id")}'
    print(f'Reporting results to Phabricator build {format_url(build_url)}',
          flush=True)
    phabtalk.update_build_status(ph_target_phid, False, success, {}, [])
    bug_url = f'https://github.com/google/llvm-premerge-checks/issues/new?assignees=&labels=bug' \
              f'&template=bug_report.md&title=buildkite build {os.getenv("BUILDKITE_PIPELINE_SLUG")} ' \
              f'{os.getenv("BUILDKITE_BUILD_NUMBER")}'
    print(f'{format_url(bug_url, "report issue")}', flush=True)
# Licensed under the the Apache License v2.0 with LLVM Exceptions (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://llvm.org/LICENSE.txt
#
# 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.

import argparse
import logging
import os

from phabtalk.phabtalk import PhabTalk

if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='Runs premerge checks8')
    parser.add_argument('--url', type=str)
    parser.add_argument('--name', type=str)
    parser.add_argument('--phid', type=str)
    parser.add_argument('--log-level', type=str, default='WARNING')
    args = parser.parse_args()

    logging.basicConfig(level=args.log_level,
                        format='%(levelname)-7s %(message)s')
    PhabTalk(os.getenv('CONDUIT_TOKEN')).maybe_add_url_artifact(
        args.phid, args.url, args.name)
Пример #5
0
]

if __name__ == '__main__':
    scripts_refspec = os.getenv("ph_scripts_refspec", "master")
    diff_id = os.getenv("ph_buildable_diff", "")
    no_cache = os.getenv('ph_no_cache') is not None
    filter_output = '--filter-output' if os.getenv(
        'ph_no_filter_output') is None else ''
    projects = os.getenv('ph_projects', 'detect')
    log_level = os.getenv('ph_log_level', 'INFO')
    logging.basicConfig(level=log_level, format='%(levelname)-7s %(message)s')

    phid = os.getenv('ph_target_phid')
    # Add link in review to the build.
    if phid is not None:
        PhabTalk(os.getenv('CONDUIT_TOKEN')).maybe_add_url_artifact(
            phid, os.getenv('BUILDKITE_BUILD_URL'), 'buildkite')

    # List all affected projects.
    repo = git.Repo('.')
    patch = repo.git.diff("HEAD~1")
    cp = ChooseProjects('.')
    modified_files = cp.get_changed_files(patch)
    modified_projects, unmapped_changes = cp.get_changed_projects(
        modified_files)
    if unmapped_changes:
        logging.warning(
            'There were changes that could not be mapped to a project. Checking everything'
        )
        modified_projects = cp.all_projects
    logging.info(f'modified projects: {modified_projects}')
    # Add projects that depend on modified.
Пример #6
0
# You may obtain a copy of the License at
#
#     https://llvm.org/LICENSE.txt
#
# 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.

import argparse
import logging
import os

from phabtalk.phabtalk import PhabTalk

if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='Runs premerge checks8')
    parser.add_argument('--url', type=str)
    parser.add_argument('--name', type=str)
    parser.add_argument('--phid', type=str)
    parser.add_argument('--log-level', type=str, default='WARNING')
    args = parser.parse_args()

    logging.basicConfig(level=args.log_level,
                        format='%(levelname)-7s %(message)s')
    dry = os.getenv('ph_dry_run_report') is not None
    PhabTalk(os.getenv('CONDUIT_TOKEN'),
             dry_run_updates=dry).maybe_add_url_artifact(
                 args.phid, args.url, args.name)