Skip to content

pr-status doesn't work when we don't pass the optional --pr parameter #2507

@felipelima-circle

Description

@felipelima-circle

Describe the bug

the pr-status command has an optional parameter --pr. This command was design to only use the PR number when we don't pass a --sha parameter. Even if we don't pass the --sha and --pr parameters, the command was designed to obtain the sha from the HEAD of the current branch.

The code has a try-catch to prevent auto from throwing an error when the PR number is not available. But this try-catch is not working because the getPrNumber() function calls process.exit(1). The try-catch is not able to stop that.

process.exit(1);

try {
prNumber = this.getPrNumber("pr", pr);
} catch (error) {
// default to sha if no PR found
}

To Reproduce

Try to create a commit status during the merge_group event (merge queue) (or even the push event). This might be needed when Auto PR Check is a required status check that is set by auto pr-check in the pull_request event. Since it's a required status check, for repos using the merge queue, it also needs to be set during merge_group event (merge queue). In this case, there's no PR number. It should be enough using --sha ${{ github.sha }}.

auto pr-status --url ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} --context "Auto PR Check" --sha ${{ github.sha }} --state success --description "PR labels validated in original PR"

Expected behavior

pr-status should work even if we don't pass the --pr parameter.

Screenshots

Environment information:

ℹ  info      ENV: {
  isCi: true,
  name: 'GitHub Actions',
  service: 'github',
  commit: 'dfd<redacted>f9d',
  build: '1<redacted>2',
  isPr: false,
  branch: 'gh-readonly-queue/main/pr-123-efb<redacted>de6',
  prBranch: undefined,
  slug: '<redacted>/<redacted>',
  root: '/home/<redacted>'
}

Additional context

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions