Closed jtgrohn closed 1 year ago
This is a great feature, thanks for taking the time to put together these changes. I will review shortly.
I ran UTs locally and code coverage is still needed for a few code paths in version.js
:
------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
------------|---------|----------|---------|---------|-------------------
All files | 93.04 | 96.97 | 85.71 | 92.86 |
config.js | 100 | 100 | 100 | 100 |
pr.js | 100 | 100 | 100 | 100 |
version.js | 80 | 85.71 | 66.67 | 79.49 | 7-20,39,89-90
------------|---------|----------|---------|---------|-------------------
I ran UTs locally and code coverage is still needed for a few code paths in
version.js
:------------|---------|----------|---------|---------|------------------- File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s ------------|---------|----------|---------|---------|------------------- All files | 93.04 | 96.97 | 85.71 | 92.86 | config.js | 100 | 100 | 100 | 100 | pr.js | 100 | 100 | 100 | 100 | version.js | 80 | 85.71 | 66.67 | 79.49 | 7-20,39,89-90 ------------|---------|----------|---------|---------|-------------------
I'm a js noob. Any suggestions for how to test getCommitsOnBranch
? Mocking the config object/github api calls like the other tests gets tricky because of the iterator.
I'll get back to this next week - I'm not going to have time this week.
Thanks for the reviews!
Also, I assume you're looking for 100% coverage?
Test coverage should be at 100% now.
Hmm. Looks like this is only actually working within the context of a PR. process.env.GITHUB_BASE_REF
isn't picking up the branch for a merge, squash, or rebase commit. I'll get that fixed.
Hmm. Looks like this is only actually working within the context of a PR.
process.env.GITHUB_BASE_REF
isn't picking up the branch for a merge, squash, or rebase commit. I'll get that fixed.
Fixed with the latest commit
@jefflinse in case it isn't clear, this PR is ready for review :)
@jtgrohn Sorry for the delay on this, been a busy few weeks and it fell off my radar. Will re-review this week.
SUMMARY
Add a
base-branch
option to only consider version tags on the PR base branch. Default behaviour remains the same -base-branch
defaults tofalse
. When set totrue
, the action filters out tags that are not on the PR base branch to find the latest version tag - as opposed to considering all tags in the repository.There is no open issue for this change, but the desire is to have
pr-semver-bump
support hotfix scenarios on release branches for consumers who can't update to latest. Consider the following scenarioA hotfix needs to be released for v1.1.x, so creating a hotfix branch from the latest
v1.1.2
The semver in the branch is expected to be auto-bumped to
v1.1.3
, butpr-semver-bump
currently offersv1.2.3
. This PR adds abase-branch
option so thatpr-semver-bump
will offerv1.1.3
.The PR hides this functionality behind an option to preserve backwards-compatibility.
It is also behind an option to preserve performance in the default case. There is also a potential performance concern due to all the extra GitHub API querying to find the commits on a branch, as well to find the commit sha a tag is associated with. The older a version a hotfix is requested for, the more quering for tag commit shas will occur. For a sense of scale, it took about ~4.5 minutes for a repo with 31k commits and where it needed to consider < a dozen version tags to find one on the base branch and it took ~40 seconds for a repo with 4.3k commits and < a dozen tags to find one on the base branch.
An alternative approach which I didn't try to code up would be to follow the tree for a branch back to the base branch / tag to find the current version that way. That could theoretically be more performant (assuming in the typical case a branch doesn't have a ton of commits). I don't know if the GitHub API would make that easy though.
RELEASE NOTES
Add
base-branch
option to only consider version tags on the PR base branchWhen
base-branch
is set totrue
, the action filters out tags that are not on the PR base branch to find the latest version tag.