Options
All
  • Public
  • Public/Protected
  • All
Menu

The VersionBot is built on top of the ProcBot class, which does all the heavy lifting and scheduling. It is designed to check for valid versionist commit semantics and alter (or merge) a PR accordingly.

Hierarchy

Index

Constructors

constructor

  • new VersionBot(integration: number, name: string, email: string, pemString: string, webhook: string): VersionBot
  • Constructs a new VersionBot instance.

    Parameters

    • integration: number
    • name: string

      Name of the VersionBot.

    • email: string

      Email ID to use for commits.

    • pemString: string

      PEM for Github events and App login.

    • webhook: string

      Secret webhook for validating events.

    Returns VersionBot

Properties

Protected _botname

_botname: string

Private emailAddress

emailAddress: string

Email address used for commiting as VersionBot.

Private githubApi

githubApi: GithubApi

Instance of Github SDK API in use for App.

Private githubEmitter

githubEmitter: ServiceEmitter

Github App ServiceEmitter.

Private githubEmitterName

githubEmitterName: string

Github ServiceEmitter name.

Private githubListenerName

githubListenerName: string

Github ServiceListener name.

Protected logger

logger: Logger = new Logger()

Methods

Protected addReviewers

  • addReviewers(_registration: GithubRegistration, event: ServiceEvent): Promise<void>
  • Checks a freshly opened PR to see if there are any configured reviewers and maintainers. Should any valid reviewers and maintainers not already be assigned as reviewers on the PR, then a comment is posted on the PR directly asking those user logins to add themselves.

    Parameters

    • _registration: GithubRegistration

      GithubRegistration object used to register the method

    • event: ServiceEvent

      ServiceEvent containing the event information ('pull_request' event)

    Returns Promise<void>

    A void Promise once execution has finished.

Protected addServiceEmitter

  • addServiceEmitter(name: string, data?: any): ServiceEmitter | void
  • Add a new type of ServiceEmitter to the client. Should the ServiceEmitter already exist on the client with the handle/name, this will do nothing.

    Parameters

    • name: string

      The name of the ServiceEmitter to add.

    • Optional data: any

    Returns ServiceEmitter | void

    The constructed or pre-existing ServiceEmitter or void on failure.

Protected addServiceListener

  • addServiceListener(name: string, data?: any): ServiceListener | void
  • Add a new type of ServiceListener to the client. Should the ServiceListener already exist on the client with the handle/name, this will do nothing.

    Parameters

    • name: string

      The name of the ServiceListener to add.

    • Optional data: any

    Returns ServiceListener | void

    The constructed or pre-existing ServiceListener or void on failure.

Private applyVersionist

  • Clones a repository and runs versionist upon it, creating new change files.

    Parameters

    • versionData: VersionistData

      Information on the repository and version.

    Returns Promise<VersionistData>

    Promise with added information on the repo.

Private checkCommitFooterTags

  • Loops through all of the commits for a PR, ensuring that any required tags are present the specified number of times for a PR.

    Parameters

    • allCommits: Commit[]

      All of the commits for the PR.

    • config: VersionBotConfiguration

      The config (if any) for the repository the PR belongs to.

    Returns MissingTag[]

    An array of MissingTag objects, denoting required tags not on the PR.

Protected checkFooterTags

  • checkFooterTags(_registration: GithubRegistration, event: ServiceEvent): Promise<void>
  • Checks the newly opened PR and its commits.

    1. Triggered by an 'opened', 'synchronize' or 'labeled' event.
    2. If the number of required tags and occurrences are present, we create a successful status, otherwise we create a failed one.
    3. If a version bump has occurred and everything is valid, merge the commit to master.

    Parameters

    • _registration: GithubRegistration

      GithubRegistration object used to register the method

    • event: ServiceEvent

      ServiceEvent containing the event information ('pull_request' event)

    Returns Promise<void>

    A void Promise once execution has finished.

Protected checkReviewers

  • checkReviewers(_registration: GithubRegistration, event: ServiceEvent): Promise<void>
  • Checks to ensure that the minimum number of approvals for a PR occurs. Should the conditions be satisfied then a successful status is set, otherwise a failed state is set.

    Parameters

    • _registration: GithubRegistration

      GithubRegistration object used to register the method

    • event: ServiceEvent

      ServiceEvent containing the event information ('pull_request' event)

    Returns Promise<void>

    A void Promise once execution has finished.

Private checkStatuses

  • Retrieve all protected branch status requirements, and determine the state for each. Status checks can be filtered to include or exclude the results of given contexts, if required.

    Parameters

    • prInfo: PullRequest

      The PR on which to check the current statuses.

    • Optional filter: StatusFilter

      An optional StatusFilter interface, allowing status contexts to be included/excluded from results.

    Returns Promise<StatusChecks>

    Promise containing a StatusChecks object determining the state of each status.

Private checkValidMaintainer

  • Ensures that the merge label was added by a valid maintainer, should a list exist in the repo configuration.

    throws

    Exception should the maintainer not be valid.

    Parameters

    • config: VersionBotConfiguration

      The VersionBot configuration object.

    • event: PullRequestEvent

      The PR event that triggered this check.

    Returns void

Protected checkWaffleFlow

  • checkWaffleFlow(_registration: GithubRegistration, event: ServiceEvent): Promise<void>
  • Checks for tags which require extra functionality to allow Waffleboard to operate upon the PR. Adds autogenerated text to the PR description for relevant tags.

    Parameters

    • _registration: GithubRegistration

      GithubRegistration object used to register the method

    • event: ServiceEvent

      ServiceEvent containing the event information ('pull_request' event)

    Returns Promise<void>

    A void Promise once execution has finished.

Private createCommitBlobs

  • Updates all relevant repo files with altered version data.

    Parameters

    • repoData: RepoFileData

      Repository and updated file information.

    Returns Promise<void>

    Promise that resolves when git data has been updated.

Protected dispatchToAllEmitters

  • dispatchToAllEmitters(data: ServiceEmitRequest): Promise<any[]>
  • Dispatch to the specified emitter. This method exists as a shortcut to avoid having to retrieve a specific emitter before sending to it.

    Parameters

    • data: ServiceEmitRequest

      The ServiceEmitRequest to use. This will be dispatched to all ServiceEmitters.

    Returns Promise<any[]>

    An array of ServiceEmitResponses from all the ServiceEmitters.

Protected dispatchToEmitter

  • dispatchToEmitter(handle: string, data: any): Promise<any>
  • Dispatch to a specific ServiceEmitter. This method exists as a shortcut to avoid having to retrieve a specific emitter before sending to it.

    throws

    Any error returned from the service represented by the ServiceEmitter.

    Parameters

    • handle: string

      The handle of the ServiceEmitter to dispatch to.

    • data: any

      Emitter appropriate data to send.

    Returns Promise<any>

    Data returned from the service represented by the ServiceEmitter.

Private finaliseMerge

  • finaliseMerge(data: PullRequestEvent, prInfo: PullRequest): Promise<void>
  • Finalises a merge should all checks have passed.

    Parameters

    • data: PullRequestEvent
    • prInfo: PullRequest

    Returns Promise<void>

    Promise fulfilled when merging has finished.

Protected getEmitter

  • getEmitter(handle: string): ServiceEmitter | void
  • Find a particular attached ServiceEmitter based upon its name.

    Parameters

    • handle: string

      Handle of the ServiceEmitter instance to find (name if no handle was set).

    Returns ServiceEmitter | void

    Instance of the ServiceEmitter found, or void if not found.

Protected getListener

  • getListener(handle: string): ServiceListener | void
  • Find a particular attached ServiceListener based upon its handle.

    Parameters

    • handle: string

      Handle of the ServiceListener instance to find (name if no handle was set).

    Returns ServiceListener | void

    Instance of the ServiceListener found, or void if not found.

getNodeBinPath

  • getNodeBinPath(): Promise<string>

Private getVersionBotCommits

  • getVersionBotCommits(prInfo: PullRequest): Promise<string | null>
  • Determines if VersionBot has already made commits to the PR branch for a version bump.

    Parameters

    • prInfo: PullRequest

      The PR to check.

    Returns Promise<string | null>

    A Promise containing 'null' should VersionBot have not already committed, else the commit message itself.

Protected mergePR

  • mergePR(_registration: GithubRegistration, event: ServiceEvent): Promise<void>
  • Merges a PR.

    1. Triggered by a 'labeled' event ('procbots/versionbot/ready-to-merge') or a 'pull_request_review_comment'
    2. Checks all review comments to ensure that at least one approves the PR (and that no comment that may come after it includes a 'CHANGES_REQUESTED' state).
    3. Commit new version upped files to the branch, which will cause a 'synchronized' event, which will finalise the merge.

    It should be noted that this will, of course, result in a 'closed' event on a PR, which in turn will feed into the 'generateVersion' method.

    Parameters

    • _registration: GithubRegistration

      GithubRegistration object used to register the method

    • event: ServiceEvent

      ServiceEvent containing the event information ('pull_request' or 'pull_request_review' event)

    Returns Promise<void>

    A void Promise once execution has finished.

Private mergeToMaster

  • mergeToMaster(data: MergeData): Promise<void>
  • Carries out the merge to master, updating relevant references from prior commits. Deletes the old branch after merge has occured.

    Parameters

    • data: MergeData

      Repo and commit data to be referenced.

    Returns Promise<void>

    Promise that resolves when reference updates and merging has finalised.

Protected passWithNoChecks

  • passWithNoChecks(_registration: GithubRegistration, event: ServiceEvent): Promise<void>
  • Always passes Versionist and AutoMerge status if a no-checks label has been applied. This allows manual merging to correctly go ahead.

    Parameters

    • _registration: GithubRegistration

      GithubRegistration object used to register the method

    • event: ServiceEvent

      ServiceEvent containing the event information ('pull_request' event)

    Returns Promise<void>

    A void Promise once execution has finished.

Protected processConfiguration

  • processConfiguration(configFile: string): ProcBotConfiguration | void
  • Process a configuration file from YAML into a nested object.

    Parameters

    • configFile: string

      The configuration file as a string.

    Returns ProcBotConfiguration | void

    The configuration object or void.

Private reportError

Protected retrieveConfiguration

  • retrieveConfiguration(details: ConfigurationLocation): Promise<ProcBotConfiguration | void>
  • Retrieve a ProcBotConfiguration file from a ServiceEmitter or inbuilt route.

    Parameters

    • details: ConfigurationLocation

      An object detailing the service to retrieve the configuration file from, and its location.

    Returns Promise<ProcBotConfiguration | void>

    A Promise containing configuration object should one have been found, or void.

Protected statusChange

  • statusChange(registration: GithubRegistration, event: ServiceEvent): Promise<void | void[]>
  • Looks for status change events and creates relevant PR events for any PR whose codebase changes

    Parameters

    • registration: GithubRegistration
    • event: ServiceEvent

      ServiceEvent containing the event information ('status' event)

    Returns Promise<void | void[]>

    A void Promise once execution has finished.

Private stripPRAuthor

  • stripPRAuthor(list: string[] | null, pullRequest: PullRequest): string[] | null
  • Strip the PR author from a list of user login string.

    Parameters

    • list: string[] | null

      The array of user logins.

    • pullRequest: PullRequest

      The pull request to use as a base.

    Returns string[] | null

    An array containing stripped user logins, or null should there be no valid users.

Static Private hasLabel

  • hasLabel(labels: Label[], labelName: string): boolean
  • Determines whether an array of Labels includes the specified label name.

    Parameters

    • labels: Label[]

      Array of Github Labels.

    • labelName: string

      The name of the label to search for.

    Returns boolean

    true if the label was found, false otherwise.

Generated using TypeDoc