Skip to content
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

fix(php): do not add version to root version map #2199

Merged
merged 4 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/strategies/php-yoshi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ export class PHPYoshi extends BaseStrategy {
splitCommits[directory]
);
versionsMap.set(composer.name, newVersion);
versionsMap.set('version', newVersion);
const partialReleaseNotes = await this.changelogNotes.buildNotes(
splitCommits[directory],
{
Expand Down Expand Up @@ -173,6 +172,16 @@ export class PHPYoshi extends BaseStrategy {
version,
}),
});
const directoryVersion: VersionsMap = new Map();
directoryVersion.set('version', version);
updates.push({
path: this.addPath(`${directory}/composer.json`),
createIfMissing: false,
updater: new RootComposerUpdatePackages({
version,
versionsMap: directoryVersion,
}),
});
if (componentInfo.composer.extra?.component?.entry) {
updates.push({
path: this.addPath(
Expand Down
30 changes: 29 additions & 1 deletion test/strategies/php-yoshi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
.resolves(buildGitHubFileRaw('0.1.2'));
getFileStub
.withArgs('Client1/composer.json', 'main')
.resolves(buildGitHubFileRaw('{"name": "google/client1"}'));
.resolves(buildGitHubFileRaw('{"name": "google/client1", "version": "1.2.3"}'));

Check failure on line 67 in test/strategies/php-yoshi.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `buildGitHubFileRaw('{"name":·"google/client1",·"version":·"1.2.3"}')` with `⏎········buildGitHubFileRaw('{"name":·"google/client1",·"version":·"1.2.3"}')⏎······`
getFileStub
.withArgs('Client2/composer.json', 'main')
.resolves(buildGitHubFileRaw('{"name": "google/client2"}'));
Expand Down Expand Up @@ -164,8 +164,11 @@
);
const updates = release!.updates;
assertHasUpdate(updates, 'Client1/VERSION', DefaultUpdater);
assertHasUpdate(updates, 'Client1/composer.json', RootComposerUpdatePackages);

Check failure on line 167 in test/strategies/php-yoshi.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `updates,·'Client1/composer.json',·RootComposerUpdatePackages` with `⏎········updates,⏎········'Client1/composer.json',⏎········RootComposerUpdatePackages⏎······`
assertHasUpdate(updates, 'Client2/VERSION', DefaultUpdater);
assertHasUpdate(updates, 'Client2/composer.json');
assertHasUpdate(updates, 'Client3/VERSION', DefaultUpdater);
assertHasUpdate(updates, 'Client3/composer.json');
assertHasUpdate(updates, 'Client3/src/Entry.php', PHPClientVersion);
});
it('ignores non client top level directories', async () => {
Expand Down Expand Up @@ -194,10 +197,35 @@
);
const updates = release!.updates;
assertHasUpdate(updates, 'Client1/VERSION', DefaultUpdater);
assertHasUpdate(updates, 'Client1/composer.json', RootComposerUpdatePackages);

Check failure on line 200 in test/strategies/php-yoshi.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `updates,·'Client1/composer.json',·RootComposerUpdatePackages` with `⏎········updates,⏎········'Client1/composer.json',⏎········RootComposerUpdatePackages⏎······`
assertHasUpdate(updates, 'Client2/VERSION', DefaultUpdater);
assertHasUpdate(updates, 'Client2/composer.json');
assertHasUpdate(updates, 'Client3/VERSION', DefaultUpdater);
assertHasUpdate(updates, 'Client3/composer.json');
assertHasUpdate(updates, 'Client3/src/Entry.php', PHPClientVersion);
});
it('updates component composer version', async () => {
const strategy = new PHPYoshi({
targetBranch: 'main',
github,
});
const latestRelease = undefined;
const release = await strategy.buildReleasePullRequest(
commits,
latestRelease
);
const updates = release!.updates;
assertHasUpdate(updates, 'Client1/composer.json', RootComposerUpdatePackages);

Check failure on line 218 in test/strategies/php-yoshi.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `updates,·'Client1/composer.json',·RootComposerUpdatePackages` with `⏎········updates,⏎········'Client1/composer.json',⏎········RootComposerUpdatePackages⏎······`
const client1Composer = updates.find(update => {
return update.path === 'Client1/composer.json';
});
const newContent = client1Composer!.updater.updateContent(
'{"name":"google/client1","version":"1.2.3"}'
);
expect(newContent).to.eql(

Check failure on line 225 in test/strategies/php-yoshi.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `⏎········'{"name":"google/client1","version":"1.2.4"}'⏎······` with `'{"name":"google/client1","version":"1.2.4"}'`
'{"name":"google/client1","version":"1.2.4"}'
);
});
});
describe('buildRelease', () => {
it('parses the release notes', async () => {
Expand Down
Loading