X Tutup
Skip to content

Use repo name from GITHUB_REPOSITORY env variable#1871

Open
mihkeleidast wants to merge 5 commits intochangesets:mainfrom
mihkeleidast:issue/1870
Open

Use repo name from GITHUB_REPOSITORY env variable#1871
mihkeleidast wants to merge 5 commits intochangesets:mainfrom
mihkeleidast:issue/1870

Conversation

@mihkeleidast
Copy link

@mihkeleidast mihkeleidast commented Mar 4, 2026

Fixes #1870.

Makes the changelog generator options object fully optional, as the env variable is defined in GitHub Actions.

Less configuring, simpler to use.

@changeset-bot
Copy link

changeset-bot bot commented Mar 4, 2026

🦋 Changeset detected

Latest commit: d37fdac

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@changesets/test-utils Patch
@changesets/changelog-github Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codecov
Copy link

codecov bot commented Mar 4, 2026

Codecov Report

❌ Patch coverage is 69.56522% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.80%. Comparing base (3ab4d89) to head (d37fdac).

Files with missing lines Patch % Lines
scripts/test-utils/src/index.ts 66.66% 4 Missing ⚠️
packages/changelog-github/src/index.ts 72.72% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1871      +/-   ##
==========================================
- Coverage   81.84%   81.80%   -0.04%     
==========================================
  Files          55       55              
  Lines        2396     2413      +17     
  Branches      725      729       +4     
==========================================
+ Hits         1961     1974      +13     
- Misses        429      433       +4     
  Partials        6        6              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment on lines +244 to +253
process.env.GITHUB_REPOSITORY = data.repo;
const [changeset, bump] = getChangeset("fixes #1234 and #5678", data.commit);
expect(await getReleaseLine(changeset, bump, null)).toMatchInlineSnapshot(`
"

- [#1613](https://github.com/emotion-js/emotion/pull/1613) [\`a085003\`](https://github.com/emotion-js/emotion/commit/a085003) Thanks [@Andarist](https://github.com/Andarist)! - something
fixes [#1234](https://github.com/emotion-js/emotion/issues/1234) and [#5678](https://github.com/emotion-js/emotion/issues/5678)"
`);

process.env.GITHUB_REPOSITORY = undefined;
Copy link
Member

Choose a reason for hiding this comment

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

Please wrap this in try/catch so the env variable gets reverted correctly. Ideally, we should do this using a helper like this:

function setEnvironmentVariable(name: string, value: string | undefined) {
  const hadValue = Object.hasOwn(process.env, name);
  const originalValue = process.env[name];

  if (typeof value === "string") {
    process.env[name] = value;
  } else {
    delete process.env[name];
  }

  return () => {
    if (hadValue) {
      process.env[name] = originalValue;
    } else {
      delete process.env[name];
    }
  };
}

Feel free to add it to the test-utils

Copy link
Author

Choose a reason for hiding this comment

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

Should be done if I understood you correctly.

'Please provide a repo to this changelog generator like this:\n"changelog": ["@changesets/changelog-github", { "repo": "org/repo" }]'
);
}
const { GITHUB_REPOSITORY } = readEnv(options);
Copy link
Member

Choose a reason for hiding this comment

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

Let's not couple options.repo with env. Please introduce a new util called smth like resolveRepository

Copy link
Author

Choose a reason for hiding this comment

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

Done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

changelog-github - infer repo name from environment variables

2 participants

X Tutup