github icon indicating copy to clipboard operation
github copied to clipboard

fix: replace `searchAPI` usage with `GraphQL` in `findSRIssue` util

Open babblebey opened this issue 1 year ago • 0 comments

This Pull request replaces the usage of the troublesome 😉 GitHub SearchAPI as primary logic in the findSRIssue with graphql. It relegates the searchAPI consumption to a fallback logic that will be removed in a future release.

The GraphQL functionality performs its search for Semantic Release Issue by querying for Issues on a repository with specific filter, in our case we use a label in the filter. This means that the PR introduces changes to the way we "create" and "find" Sematic Release issues in the fail and success script.

Changes Made:

  • Introduced an opinionated label for Semantic Release failing release issues in form of a constant RELEASE_FAIL_LABEL

  • Concatenated the RELEASE_FAIL_LABEL to the label param on creation of semantic release failing issue in the fail script; this means the our opinionated label gets added to the failing release issue regardless of the plugin context.label configuration value (which is either semantic-release, CUSTOM_LABEL or false)

    const newIssue = {
      owner,
      repo,
      title: failTitle,
      body: `${body}\n\n${ISSUE_ID}`,
      labels: (labels || []).concat([RELEASE_FAIL_LABEL]), // 👈 👈 👈 👈  HERE
      assignees,
    };
    
  • Introduced the GraphQL Query that the appropriated filter and passed into it is the labels filter with context.label configuration concatenated with our opinionated RELEASE_FAIL_LABEL as value;

    const {
      repository: {
        issues: { nodes: issueNodes },
      },
    } = await octokit.graphql(loadGetSRIssuesQuery, {
      owner,
      repo,
      filter: {
        labels: (labels || []).concat([RELEASE_FAIL_LABEL]), // 👈 👈 👈 👈  HERE
      },
    });
    

Related Issue

Fixes #867

babblebey avatar Aug 28 '24 16:08 babblebey