-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Release tooling: Update docs version files when releasing #23235
Merged
shilman
merged 6 commits into
next
from
23000-bug-new-release-flow-doesnt-update-versions-on-docs-site
Jul 4, 2023
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7fa67b4
write to docs version files
JReinhold 27a65be
remove heading
JReinhold 112c87a
first stab at tests
JReinhold 7d21d33
finish write-chnagelog tests
JReinhold 36c5f50
sync docs/versions/next.json to main on new prereleases
JReinhold 327e48e
Merge branch 'next' into 23000-bug-new-release-flow-doesnt-update-ver…
JReinhold 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
/* eslint-disable global-require */ | ||
/* eslint-disable no-underscore-dangle */ | ||
import path from 'path'; | ||
import dedent from 'ts-dedent'; | ||
import { run as writeChangelog } from '../write-changelog'; | ||
import * as changesUtils from '../utils/get-changes'; | ||
|
||
// eslint-disable-next-line jest/no-mocks-import | ||
jest.mock('fs-extra', () => require('../../../code/__mocks__/fs-extra')); | ||
const fsExtra = require('fs-extra'); | ||
|
||
const getChangesMock = jest.spyOn(changesUtils, 'getChanges'); | ||
|
||
jest.spyOn(console, 'log').mockImplementation(() => {}); | ||
jest.spyOn(console, 'warn').mockImplementation(() => {}); | ||
jest.spyOn(console, 'error').mockImplementation(() => {}); | ||
|
||
const STABLE_CHANGELOG_PATH = path.join(__dirname, '..', '..', '..', 'CHANGELOG.md'); | ||
const PRERELEASE_CHANGELOG_PATH = path.join(__dirname, '..', '..', '..', 'CHANGELOG.prerelease.md'); | ||
const LATEST_VERSION_PATH = path.join( | ||
__dirname, | ||
'..', | ||
'..', | ||
'..', | ||
'docs', | ||
'versions', | ||
'latest.json' | ||
); | ||
const NEXT_VERSION_PATH = path.join(__dirname, '..', '..', '..', 'docs', 'versions', 'next.json'); | ||
|
||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
const EXISTING_STABLE_CHANGELOG = dedent`## 7.0.0 | ||
|
||
- Core: Some change`; | ||
|
||
const EXISTING_PRERELEASE_CHANGELOG = dedent`## 7.1.0-alpha.20 | ||
|
||
- CLI: Super fast now`; | ||
|
||
fsExtra.__setMockFiles({ | ||
[STABLE_CHANGELOG_PATH]: EXISTING_STABLE_CHANGELOG, | ||
[PRERELEASE_CHANGELOG_PATH]: EXISTING_PRERELEASE_CHANGELOG, | ||
}); | ||
|
||
describe('Write changelog', () => { | ||
it('should write to stable changelogs and version files in docs', async () => { | ||
getChangesMock.mockResolvedValue({ | ||
changes: [], | ||
changelogText: `## 7.0.1 | ||
|
||
- React: Make it reactive | ||
- CLI: Not UI`, | ||
}); | ||
|
||
await writeChangelog(['7.0.1'], {}); | ||
|
||
expect(fsExtra.writeFile).toHaveBeenCalledTimes(1); | ||
expect(fsExtra.writeFile.mock.calls[0][0]).toBe(STABLE_CHANGELOG_PATH); | ||
expect(fsExtra.writeFile.mock.calls[0][1]).toMatchInlineSnapshot(` | ||
"## 7.0.1 | ||
|
||
- React: Make it reactive | ||
- CLI: Not UI | ||
|
||
## 7.0.0 | ||
|
||
- Core: Some change" | ||
`); | ||
expect(fsExtra.writeJson).toBeCalledTimes(1); | ||
expect(fsExtra.writeJson.mock.calls[0][0]).toBe(LATEST_VERSION_PATH); | ||
expect(fsExtra.writeJson.mock.calls[0][1]).toMatchInlineSnapshot(` | ||
{ | ||
"info": { | ||
"plain": "- React: Make it reactive | ||
- CLI: Not UI", | ||
}, | ||
"version": "7.0.1", | ||
} | ||
`); | ||
}); | ||
|
||
it('should write to prerelase changelogs and version files in docs', async () => { | ||
getChangesMock.mockResolvedValue({ | ||
changes: [], | ||
changelogText: `## 7.1.0-alpha.21 | ||
|
||
- React: Make it reactive | ||
- CLI: Not UI`, | ||
}); | ||
|
||
await writeChangelog(['7.1.0-alpha.21'], {}); | ||
|
||
expect(fsExtra.writeFile).toHaveBeenCalledTimes(1); | ||
expect(fsExtra.writeFile.mock.calls[0][0]).toBe(PRERELEASE_CHANGELOG_PATH); | ||
expect(fsExtra.writeFile.mock.calls[0][1]).toMatchInlineSnapshot(` | ||
"## 7.1.0-alpha.21 | ||
|
||
- React: Make it reactive | ||
- CLI: Not UI | ||
|
||
## 7.1.0-alpha.20 | ||
|
||
- CLI: Super fast now" | ||
`); | ||
expect(fsExtra.writeJson).toBeCalledTimes(1); | ||
expect(fsExtra.writeJson.mock.calls[0][0]).toBe(NEXT_VERSION_PATH); | ||
expect(fsExtra.writeJson.mock.calls[0][1]).toMatchInlineSnapshot(` | ||
{ | ||
"info": { | ||
"plain": "- React: Make it reactive | ||
- CLI: Not UI", | ||
}, | ||
"version": "7.1.0-alpha.21", | ||
} | ||
`); | ||
}); | ||
}); |
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
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.
I assume that you ensure that this never gets called in any other scenarios? Future release? Canary release?
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.
That's a good point. For now we only support the two release types, so it's hard to come up with how the logic would be if there were other types of releases here.