[ci] version_check_command now checks markdown of first CHANGELOG line. (#7266)

This PR:

* Modifies the `version_check_command` test so it checks the leading markdown of the first line of a CHANGELOG file, to ensure it's `'##'`.
* Fixes the CHANGELOG in two packages that were allowed by the tool before this fix:
  * google_maps_flutter_web
  * interactive_media_ads

## Issues

Fixes https://github.com/flutter/flutter/issues/152638
This commit is contained in:
David Iglesias
2024-07-31 18:33:18 -07:00
committed by GitHub
parent 37c4b1cd75
commit f8fbcdbe95
8 changed files with 54 additions and 7 deletions

View File

@ -1,4 +1,8 @@
# 0.5.9
## 0.5.9+1
* Fixes a typo in the formatting of the CHANGELOG.
## 0.5.9
* Updates `package:google_maps` dependency to latest (`^8.0.0`).
* Supports `web: ">=0.5.1 <2.0.0"`.

View File

@ -2,7 +2,7 @@ name: google_maps_flutter_web
description: Web platform implementation of google_maps_flutter
repository: https://github.com/flutter/packages/tree/main/packages/google_maps_flutter/google_maps_flutter_web
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22
version: 0.5.9
version: 0.5.9+1
environment:
sdk: ^3.4.0

View File

@ -1,4 +1,8 @@
# 0.1.1
## 0.1.1+1
* Fixes a typo in the formatting of the CHANGELOG.
## 0.1.1
* Adds iOS implementation.
* Adds support for setting the layout direction of the `AdDisplayContainer`.

View File

@ -21,7 +21,7 @@ class AdsRequestProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) :
*
* This must match the version in pubspec.yaml.
*/
const val pluginVersion = "0.1.1"
const val pluginVersion = "0.1.1+1"
}
override fun setAdTagUrl(pigeon_instance: AdsRequest, adTagUrl: String) {

View File

@ -13,7 +13,7 @@ class AdsRequestProxyAPIDelegate: PigeonApiDelegateIMAAdsRequest {
/// The current version of the `interactive_media_ads` plugin.
///
/// This must match the version in pubspec.yaml.
static let pluginVersion = "0.1.1"
static let pluginVersion = "0.1.1+1"
func pigeonDefaultConstructor(
pigeonApi: PigeonApiIMAAdsRequest, adTagUrl: String, adDisplayContainer: IMAAdDisplayContainer,

View File

@ -2,7 +2,7 @@ name: interactive_media_ads
description: A Flutter plugin for using the Interactive Media Ads SDKs on Android and iOS.
repository: https://github.com/flutter/packages/tree/main/packages/interactive_media_ads
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+interactive_media_ads%22
version: 0.1.1 # This must match the version in
version: 0.1.1+1 # This must match the version in
# `android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApi.kt` and
# `ios/interactive_media_ads/Sources/interactive_media_ads/AdsRequestProxyAPIDelegate.swift`

View File

@ -392,6 +392,7 @@ ${indentation}HTTP response: ${pubVersionFinderResponse.httpResponse.body}
}
// Remove all leading mark down syntax from the version line.
String? versionString = firstLineWithText?.split(' ').last;
String? leadingMarkdown = firstLineWithText?.split(' ').first;
final String badNextErrorMessage = '${indentation}When bumping the version '
'for release, the NEXT section should be incorporated into the new '
@ -413,15 +414,18 @@ ${indentation}HTTP response: ${pubVersionFinderResponse.httpResponse.body}
// CHANGELOG. That means the next version entry in the CHANGELOG should
// pass the normal validation.
versionString = null;
leadingMarkdown = null;
while (iterator.moveNext()) {
if (iterator.current.trim().startsWith('## ')) {
versionString = iterator.current.trim().split(' ').last;
leadingMarkdown = iterator.current.trim().split(' ').first;
break;
}
}
}
if (versionString == null) {
final bool validLeadingMarkdown = leadingMarkdown == '##';
if (versionString == null || !validLeadingMarkdown) {
printError('${indentation}Unable to find a version in CHANGELOG.md');
print('${indentation}The current version should be on a line starting '
'with "## ", either on the first non-empty line or after a "## NEXT" '

View File

@ -641,6 +641,41 @@ void main() {
);
});
test('fails gracefully if the first entry uses the wrong style', () async {
final RepositoryPackage plugin =
createFakePlugin('plugin', packagesDir, version: '1.0.0');
const String changelog = '''
# 1.0.0
* Some changes for a later release.
## 0.9.0
* Some earlier changes.
''';
plugin.changelogFile.writeAsStringSync(changelog);
processRunner.mockProcessesForExecutable['git-show'] = <FakeProcessInfo>[
FakeProcessInfo(MockProcess(stdout: 'version: 1.0.0')),
];
Error? commandError;
final List<String> output = await runCapturingPrint(runner, <String>[
'version-check',
'--base-sha=main',
], errorHandler: (Error e) {
commandError = e;
});
expect(commandError, isA<ToolExit>());
expect(
output,
containsAllInOrder(<Matcher>[
contains('Unable to find a version in CHANGELOG.md'),
contains('The current version should be on a line starting with '
'"## ", either on the first non-empty line or after a "## NEXT" '
'section.'),
]),
);
});
test(
'fails gracefully if the version headers are not found due to using the wrong style',
() async {