| // Copyright 2018 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| import '@gerritcodereview/typescript-api/gerrit'; |
| import {initAuth} from './auth'; |
| import {CacheObject} from './cache-object'; |
| import {ResultDbV1Client} from './resultdb-client'; |
| import {BuildbucketV2Client} from './buildbucket-client'; |
| import {ChecksDB} from './checks-db'; |
| import {ChecksFetcher} from './checks-fetcher'; |
| import {FailureAnalysis, FailureAnalysisView} from './failure-analysis'; |
| import {installChecksResult} from './checks-result'; |
| import { |
| compareBuildIds, |
| convertLegacyBucket, |
| identicalBucket, |
| } from './buildbucket-utils'; |
| import {PluginApi} from '@gerritcodereview/typescript-api/plugin'; |
| window.Gerrit.install(async (plugin: PluginApi): Promise<void> => { |
| initAuth(plugin); |
| const checksDB = new ChecksDB('checks-db'); |
| const failureTriage = new FailureAnalysis(checksDB); |
| const buildbucketHost = 'cr-buildbucket.appspot.com'; |
| const fetcher = new ChecksFetcher(plugin, buildbucketHost, 100, checksDB, 10); |
| plugin.checks().register( |
| {fetch: changeData => fetcher.fetch(changeData) as any}, |
| // ChecksFetcher will trigger fetch() when there are updates. |
| // Set fetchPollingIntervalSeconds to a high number so it |
| // does not interfere. |
| {fetchPollingIntervalSeconds: 300} |
| ); |
| plugin.hook('check-result-expanded').onAttached(installChecksResult); |
| |
| plugin |
| .registerCustomComponent('commit-container', 'failure-analysis-view') |
| .onAttached(el => { |
| failureTriage.register(el as FailureAnalysisView); |
| }); |
| }); |
| |
| // Export clients/functions to global space so other plugins can use them. |
| // TODO(https://crbug.com/1087585): remove global variables |
| window.buildbucket = window.buildbucket || {}; |
| Object.assign(window.buildbucket, { |
| BuildbucketV2Client, |
| CacheObject, |
| ResultDbV1Client, |
| compareBuildIds, |
| convertLegacyBucket, |
| identicalBucket, |
| }); |