Skip to content

Cocoon listFiles() logic is faulty: only looks at the first 30 files in the PR! #161462

@matanlurey

Description

@matanlurey

Cocoon uses a wrapper around the GitHub REST API that calls "List pull request files":

/// Returns changed files for a [PullRequest].
///
/// See more:
///   * https://developer.github.com/v3/pulls/#list-pull-requests-files
Future<List<String>> listFiles(PullRequest pullRequest) async {
  final List<PullRequestFile> files =
      await github.pullRequests.listFiles(pullRequest.base!.repo!.slug(), pullRequest.number!).toList();
  log.fine('List of files: $files');
  return files.map((PullRequestFile file) {
    return file.filename!;
  }).toList();
}

As noted on https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28#list-pull-requests-files:

Responses include a maximum of 3000 files. The paginated response returns 30 files per page by default.

That is, in our current implementation, which uses listFiles() for a number of things including the implementation of .ci.yaml's runIf, if you change more than roughly 30 files (potentially less if the patches are large), we will erroneously compute what to run/not run.

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listc: tech-debtTechnical debt, code quality, testing, etc.team-infraOwned by Infrastructure teamtriaged-infraTriaged by Infrastructure team

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions