-
Notifications
You must be signed in to change notification settings - Fork 378
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
feat(manifest): add support for releasing root module #833
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
4a1a1ea
feat(manifest): add support for releasing root module
bcoe 4744798
fix: address bug with CHANGELOG generation
bcoe 9d2e93a
test: add test case from code review
bcoe 3273eaf
test: added test for creating a release
bcoe 1d1f232
docs: add blurb about root level releases
bcoe 262865a
Update test/manifest.ts
bcoe 9effd3a
Update test/manifest.ts
bcoe 938959d
Update test/manifest.ts
bcoe 6ed9114
Update test/manifest.ts
bcoe f866610
Merge branch 'master' into allow-root-path
bcoe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name": "googleapis", | ||
"version": "3.3.3" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -145,6 +145,9 @@ describe('Manifest', () => { | |
'node/pkg2/CHANGELOG.md', | ||
'python/CHANGELOG.md', | ||
'python/HISTORY.md', | ||
'package-lock.json', | ||
'samples/package.json', | ||
'CHANGELOG.md', | ||
]; | ||
for (const notFound of expectedNotFound) { | ||
mock | ||
|
@@ -283,6 +286,78 @@ describe('Manifest', () => { | |
]); | ||
}); | ||
|
||
it('allows root module to be published, via special "." path', async function () { | ||
const manifest = JSON.stringify({ | ||
'node/pkg1': '3.2.1', | ||
'node/pkg2': '1.2.3', | ||
'.': '2.0.0', | ||
}); | ||
const config = JSON.stringify({ | ||
packages: { | ||
'node/pkg1': {}, | ||
'node/pkg2': {}, | ||
'.': {}, | ||
}, | ||
}); | ||
const commits = [ | ||
buildMockCommit('feat(@node/pkg1)!: major new feature', [ | ||
'node/pkg1/src/foo.ts', | ||
]), | ||
buildMockCommit('feat(@node/pkg2)!: major new feature', [ | ||
'node/pkg2/src/bar.ts', | ||
]), | ||
buildMockCommit('fix(root): root only change', ['src/foo.ts']), | ||
]; | ||
|
||
const github = new GitHub({ | ||
owner: 'fake', | ||
repo: 'repo', | ||
defaultBranch, | ||
}); | ||
const mock = mockGithub(github); | ||
expectManifest(mock, {manifest, lastReleaseSha}); | ||
expectPR(mock, {lastReleaseSha}); | ||
expectCommitsSinceSha(mock, {commits, lastReleaseSha}); | ||
expectGetFiles(mock, { | ||
fixtureFiles: [ | ||
'node/pkg1/package.json', | ||
'node/pkg2/package.json', | ||
'package.json', | ||
], | ||
inlineFiles: [ | ||
['release-please-config.json', config], | ||
['.release-please-manifest.json', manifest], | ||
], | ||
}); | ||
expectLabelAndComment(mock, {addLabel}); | ||
stubSuggesterWithSnapshot(sandbox, this.test!.fullTitle()); | ||
const logs: [string, CheckpointType][] = []; | ||
const checkpoint = (msg: string, type: CheckpointType) => | ||
logs.push([msg, type]); | ||
|
||
const pr = await new Manifest({github, checkpoint}).pullRequest(); | ||
|
||
mock.verify(); | ||
expect(pr).to.equal(22); | ||
expect(logs).to.eql([ | ||
[ | ||
'Found version 3.2.1 for node/pkg1 in .release-please-manifest.json at abc123 of main', | ||
CheckpointType.Success, | ||
], | ||
[ | ||
'Found version 1.2.3 for node/pkg2 in .release-please-manifest.json at abc123 of main', | ||
CheckpointType.Success, | ||
], | ||
[ | ||
'Found version 2.0.0 for . in .release-please-manifest.json at abc123 of main', | ||
CheckpointType.Success, | ||
], | ||
['Processing package: Node(@node/pkg1)', CheckpointType.Success], | ||
['Processing package: Node(@node/pkg2)', CheckpointType.Success], | ||
['Processing package: Node(googleapis)', CheckpointType.Success], | ||
]); | ||
}); | ||
|
||
it('respects python releaser specific config over defaults', async function () { | ||
// https://github.com/googleapis/release-please/pull/790#issuecomment-783792069 | ||
if (process.versions.node.split('.')[0] === '10') { | ||
|
@@ -1750,6 +1825,86 @@ describe('Manifest', () => { | |
], | ||
]); | ||
}); | ||
|
||
it('releases library in root (".")', async () => { | ||
const manifest = JSON.stringify({ | ||
'.': '3.2.1', | ||
}); | ||
const config = JSON.stringify({ | ||
packages: { | ||
'.': {}, | ||
}, | ||
}); | ||
|
||
const github = new GitHub({ | ||
owner: 'fake', | ||
repo: 'repo', | ||
defaultBranch, | ||
}); | ||
const mock = mockGithub(github); | ||
expectManifest(mock, {manifest, lastReleaseSha}); | ||
expectPR(mock, { | ||
lastReleaseSha, | ||
mergedPRFiles: [ | ||
// lack of any "node/pkg2/ files indicates that package did not | ||
// change in the last merged PR. | ||
'package.json', | ||
'CHANGELOG.md', | ||
], | ||
}); | ||
expectGetFiles(mock, { | ||
fixtureFiles: ['package.json'], | ||
inlineFiles: [ | ||
['release-please-config.json', config], | ||
['.release-please-manifest.json', manifest], | ||
['CHANGELOG.md', '#Changelog\n\n## v3.2.1\n\n* entry'], | ||
], | ||
}); | ||
expectLabelAndComment(mock, { | ||
addLabel: 'autorelease: tagged', | ||
removeLabel: 'autorelease: pending', | ||
prComments: [ | ||
':robot: Release for googleapis is at https://[email protected]:html :sunflower:', | ||
], | ||
}); | ||
mock | ||
.expects('createRelease') | ||
.withArgs( | ||
'googleapis', | ||
'googleapis-v3.2.1', | ||
lastReleaseSha, | ||
sinon.match.string, | ||
false | ||
) | ||
.once() | ||
.resolves({ | ||
name: 'googleapis googleapis-v3.2.1', | ||
tag_name: 'googleapis-v3.2.1', | ||
draft: false, | ||
body: '', | ||
html_url: 'https://[email protected]:html', | ||
upload_url: 'https://[email protected]:upload', | ||
}); | ||
|
||
const releases = await new Manifest({github}).githubRelease(); | ||
mock.verify(); | ||
expect(releases).to.eql({ | ||
'.': { | ||
version: '3.2.1', | ||
major: 3, | ||
minor: 2, | ||
patch: 1, | ||
pr: 22, | ||
draft: false, | ||
body: '', | ||
sha: 'abc123', | ||
html_url: 'https://[email protected]:html', | ||
tag_name: 'googleapis-v3.2.1', | ||
name: 'googleapis googleapis-v3.2.1', | ||
upload_url: 'https://[email protected]:upload', | ||
}, | ||
}); | ||
}); | ||
}); | ||
|
||
describe('validate', () => { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, I think we should add a test under the
describe('githubRelease'
section. I'd be curious to see what the tag creation looks like for the root package.also maybe a note somewhere in
docs/manifest-releaser.md
about this root pkg ability?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 👍