Skip to content

Action size: Add a PR check that comments on significant repo size changes#3910

Open
henrymercer wants to merge 8 commits into
mainfrom
henrymercer/repo-size-diff-check
Open

Action size: Add a PR check that comments on significant repo size changes#3910
henrymercer wants to merge 8 commits into
mainfrom
henrymercer/repo-size-diff-check

Conversation

@henrymercer
Copy link
Copy Markdown
Contributor

The compressed checkout of the repo is downloaded at the start of every CodeQL job. Significant jumps or drops are worth surfacing since they directly affect job startup time.

To that end, this PR adds a "Check repo size" PR check that streams git archive --format=tar.gz for both the PR base and HEAD, compares the compressed sizes, and posts a sticky comment when the difference is at least 10% in either direction.

Copilot AI review requested due to automatic review settings May 18, 2026 15:37
@henrymercer henrymercer requested a review from a team as a code owner May 18, 2026 15:37
@github-actions github-actions Bot added the size/XL May be very hard to review label May 18, 2026
Comment thread pr-checks/check-repo-size.ts Fixed
Comment thread pr-checks/check-repo-size.ts Fixed
Comment thread pr-checks/check-repo-size.ts Fixed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a PR workflow and TypeScript helper to measure compressed repository archive size changes between a PR and its base, then post/update a sticky PR comment when the delta is significant.

Changes:

  • Added a Check repo size workflow.
  • Added pr-checks/check-repo-size.ts with archive measurement, formatting, and PR comment upsert logic.
  • Added unit tests and pr-check dependency updates for Sinon-based Octokit mocking.
Show a summary per file
File Description
.github/workflows/check-repo-size.yml Runs the repo size check on PR events.
pr-checks/check-repo-size.ts Implements archive size measurement and sticky PR comment behavior.
pr-checks/check-repo-size.test.ts Tests formatting, archive measurement, and comment upsert behavior.
pr-checks/package.json Adds Sinon test dependencies for pr-checks.
package-lock.json Updates lockfile metadata for pr-checks dependencies.

Copilot's findings

  • Files reviewed: 4/5 changed files
  • Comments generated: 5

Comment thread pr-checks/check-repo-size.ts Outdated
Comment thread .github/workflows/check-repo-size.yml Outdated
Comment thread .github/workflows/check-repo-size.yml Outdated
Comment thread pr-checks/check-repo-size.ts Outdated
Comment thread .github/workflows/check-repo-size.yml Outdated
Copy link
Copy Markdown
Member

@mbg mbg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking at this! Two high-level design questions:

  1. Could we add this on to an existing workflow (pr-checks?) rather than adding a totally new one?
  2. Rather than comparing to the PR base ref, would it make sense to compare to the latest CodeQL Action release instead?

Comment thread .github/workflows/check-repo-size.yml Outdated
Comment on lines +3 to +5
on:
pull_request:
types: [opened, synchronize, reopened]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add this on to an existing workflow (pr-checks?) rather than adding a totally new one?

Comment thread pr-checks/check-repo-size.ts Outdated
*/
export const SIGNIFICANT_DELTA_FRACTION = 0.1;

export type Octokit = ReturnType<typeof getOctokit>;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

api-client.ts exports ApiClient (the return type of getOctokit). Why this roundabout way of getting hold of that type?

@henrymercer henrymercer marked this pull request as draft May 18, 2026 16:03
@henrymercer
Copy link
Copy Markdown
Contributor Author

henrymercer commented May 18, 2026

Rather than comparing to the PR base ref, would it make sense to compare to the latest CodeQL Action release instead?

With that approach, if we merge a PR that significantly increases / decreases the repo size, this would create noise on all subsequent PRs until the next release. Since we compare against the base, we'll get the comparison against the latest release when we run the release process, so we have another opportunity to see significant changes at that point.

@henrymercer henrymercer force-pushed the henrymercer/repo-size-diff-check branch from 7e6ce16 to b34c6b4 Compare May 18, 2026 17:20
@henrymercer henrymercer force-pushed the henrymercer/repo-size-diff-check branch from b34c6b4 to 9b6438e Compare May 18, 2026 17:25
@henrymercer henrymercer requested a review from Copilot May 18, 2026 18:09
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 5/6 changed files
  • Comments generated: 6

Comment thread .github/workflows/pr-checks.yml Outdated
Comment thread .github/workflows/pr-checks.yml Outdated
Comment thread .github/workflows/pr-checks.yml Outdated
Comment thread .github/workflows/pr-checks.yml Outdated
Comment thread pr-checks/check-repo-size.ts Outdated
Comment thread pr-checks/check-repo-size.test.ts
@henrymercer henrymercer changed the title Add a PR check that comments on significant repo size changes Action size: Add a PR check that comments on significant repo size changes May 18, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

Comments suppressed due to low confidence (1)

.github/workflows/pr-checks.yml:225

  • Because body comes from an artifact produced by PR-controlled code, passing it with gh api --field is unsafe: --field body=@path makes the CLI read a local file, so a malicious body could cause this privileged job to post files such as its environment. Use a raw field or file input only after constructing/validating the body in trusted code.
            gh api --method PATCH "repos/$GITHUB_REPOSITORY/issues/comments/$comment_id" --field body="$body"
          elif [[ "$significant" == "true" ]]; then
            echo "Creating new repo size comment."
            gh api --method POST "repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER/comments" --field body="$body"
  • Files reviewed: 5/5 changed files
  • Comments generated: 1

Comment thread .github/workflows/pr-checks.yml Outdated
@henrymercer henrymercer marked this pull request as ready for review May 18, 2026 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XL May be very hard to review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants