Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: @octokit/rest doesn't appear to support some valid values for createRepoRuleset like merge-queues. #468

Open
1 task done
jasononeil opened this issue Oct 21, 2024 · 3 comments
Labels
Type: Bug Something isn't working as documented

Comments

@jasononeil
Copy link

jasononeil commented Oct 21, 2024

What happened?

I'm working on a script to configure merge queues across many repos (code snippet below).

I noticed that 3 of the fields I tried to configure had TS errors. If I use @ts-expect-error it works correctly (compare to values here in REST API docs here: https://docs.github.com/en/rest/repos/rules?apiVersion=2022-11-28#create-a-repository-ruleset).

I'm unsure if this is just an oversight or if the merge-queue and ruleset features have different valid values for Github Enterprise plans etc.

Code snippet:

    client.repos.createRepoRuleset({
      enforcement: 'active',
      owner,
      repo,
      name: this.rulesetName,
      target: 'branch',
      conditions: {
        ref_name: {
          include: ['refs/heads/renovate/rollup'],
          exclude: [],
        },
      },
      rules: [
        {
          type: 'merge_queue', // TS error
          parameters: {
            merge_method: 'SQUASH',  // TS error
            max_entries_to_build: 5,
            min_entries_to_merge: 1,
            max_entries_to_merge: 5,
            min_entries_to_merge_wait_minutes: 5,
            grouping_strategy: 'ALLGREEN',
            check_response_timeout_minutes: 60,
          },
        },
        {
          type: 'required_status_checks',
          parameters: {
            strict_required_status_checks_policy: false,
            do_not_enforce_on_create: false,  // TS error
            required_status_checks: await this.getRequiredStatusChecks({
              repo,
            }),
          },
        },
      ],
    });

Versions

  • @octokit/rest 21.0.2
  • node 18.20.3
  • typescript 5.6.2

Relevant log output

First error

ts: Type '"merge_queue"' is not assignable to type '"creation" | "update" | "deletion" | "required_linear_history" | "required_deployments" | "required_signatures" | "pull_request" | "required_status_checks" | "non_fast_forward" | ... 9 more ... | "workflows"'.

Second error

ts: Object literal may only specify known properties, and 'merge_method' does not exist in type '{ workflows: { path: string; ref?: string | undefined; repository_id: number; sha?: string | undefined; }[]; }'.

Third error

ts: Object literal may only specify known properties, and 'do_not_enforce_on_create' does not exist in type '{ required_status_checks: { context: string; integration_id?: number | undefined; }[]; strict_required_status_checks_policy: boolean; }'.

Code of Conduct

  • I agree to follow this project's Code of Conduct
@jasononeil jasononeil added Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented labels Oct 21, 2024
Copy link
Contributor

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

@wolfy1339
Copy link
Member

There are some differences with GHES vs GitHub.com APIs. I'm not sure if it is applicable to this endpoint though.

We do have a backlog of type updates that could be the cause of this issue.

Until those get resolved, you'll unfortunately need to keep using //@ts-expect-error.

@jasononeil
Copy link
Author

Okay good to know. I should have mentioned, I am using an Enterprise account but hosted with Github (I assume GHES is the self-hosted option? I've never looked into it before)

@kfcampbell kfcampbell removed the Status: Triage This is being looked at and prioritized label Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working as documented
Projects
Status: 🔥 Backlog
Development

No branches or pull requests

3 participants