Skip to content
This repository has been archived by the owner on Jun 11, 2020. It is now read-only.

Support multiple minor versions in parallel #723

Merged
merged 22 commits into from
Feb 14, 2020

Conversation

alloy
Copy link
Member

@alloy alloy commented Jan 1, 2020

Regarding DefinitelyTyped/DefinitelyTyped#40923
Supersedes #717

Summary

Some packages, such as react-native, have been and will be < v1 for a while. Especially in the < v1 case, according to semver any v0.x version can break API compatibility. As such, it would be great if we could maintain minor versions in parallel, just like we already can with major versions.

After getting my bearings in the repo, I ended up adjusting the version directory validation to allow for minor versions and record that directory name in the definitions.json file so it can be used when generating packages.

Example run

$ npm run build
$ npm run clean
$ npm run parse
$ npm run check
$ npm run calculate-versions
$ npm run generate -- --single react-native
$ ack '"version":' ./output

output/react-native/package.json
3:    "version": "0.62.0",

output/react-native v0.61/package.json
3:    "version": "0.61.0",

output/react-native v0.60/package.json
3:    "version": "0.60.28",

Test plan

I’ve tried to add tests around code I’ve changed as much as possible and I’ve performed local runs of the steps that can be ran locally (as shown above). However, I do think this requires a handheld run by somebody that knows this project more intimately to ensure all the steps after generating packages work as expected.

@alloy alloy force-pushed the support-multiple-minor-versions branch from 4e29cdd to 60edd1a Compare January 1, 2020 16:05
@alloy
Copy link
Member Author

alloy commented Jan 1, 2020

cc @orta @acoates-ms

README.md Show resolved Hide resolved
src/lib/definition-parser.ts Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
@@ -39,7 +39,7 @@ export default async function generatePackages(dt: FS, allPackages: AllPackages,
if (tgz) {
await writeTgz(pkg.outputDirectory, `${pkg.outputDirectory}.tgz`);
}
log(` * ${pkg.libraryName}`);
log(` * ${pkg.desc}`);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adds the version of the package that’s being generated, rather than simply repeating the package name multiple times.

@@ -282,22 +282,22 @@ async function runCommand(log: LoggerWithErrors, cwd: string | undefined, cmd: s

/** Returns all immediate subdirectories of the root directory that have changed. */
export function gitChanges(diffs: GitDiff[]): PackageId[] {
const changedPackages = new Map<string, Set<DependencyVersion>>();
const changedPackages = new Map<string, Map<string, DependencyVersion>>();
Copy link
Member Author

@alloy alloy Jan 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that DependencyVersion is no longer a single primitive, but rather an object, I had to replace the usage of Set


for (const diff of diffs) {
const dep = getDependencyFromFile(diff.file);
if (dep) {
const versions = changedPackages.get(dep.name);
if (!versions) {
changedPackages.set(dep.name, new Set([dep.majorVersion]));
changedPackages.set(dep.name, new Map([[formatDependencyVersion(dep.version), dep.version]]));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

…so now it’s keyed by a string representation of the version.

@alloy alloy changed the title [WIP] Support multiple minor versions in parallel Support multiple minor versions in parallel Jan 3, 2020
@alloy
Copy link
Member Author

alloy commented Jan 3, 2020

@sandersn @orta Alright, this should now be good to review.

Copy link
Contributor

@orta orta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

When I've tried to run master on my laptop I'm getting issues, can you check the diff for the results of npm run parse on this PR vs master to validate that the additional finer grain server checking hasn't accidentally changed the parsed representation overall?

That said, looks good to me

README.md Show resolved Hide resolved
"make-server-run": "node -r source-map-support/register bin/make-server-run.js",
"make-production-server-run": "node -r source-map-support/register bin/make-server-run.js --remote",
"test-tsNext": "node -r source-map-support/register bin/tester/test.js --all --tsNext",
"code-owners": "node -r source-map-support/register bin/code-owners.js",
"push-production": "npm run build && git checkout production && git merge master && npm run build && git add bin && git commit -m \"Update bin\" && git push -u origin production"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice work

@alloy alloy force-pushed the support-multiple-minor-versions branch from c040652 to 284824c Compare January 7, 2020 20:21
@alloy
Copy link
Member Author

alloy commented Jan 7, 2020

@orta Rebased against master and still all seems to work fine for me 👍

@alloy
Copy link
Member Author

alloy commented Jan 7, 2020

@acoates-ms Unsure in how far you were planning on using your DT branch, but I had to make one small extra change DefinitelyTyped/DefinitelyTyped@5f1995c

@acoates-ms
Copy link

@alloy, The only other thing to check was that any changes to master since I made the change get copied into all the directories. -- Other than that, I was hoping to revive the PR once this one lands. (You are more than welcome to do that yourself though)

@alloy
Copy link
Member Author

alloy commented Jan 8, 2020

@acoates-ms Cool, I’ll pick that up once this lands 👍

@sandersn sandersn self-assigned this Jan 17, 2020
Copy link
Member

@sandersn sandersn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall the code looks good. There's a lot there but it's well-tested.

I'm on vacation early next week so I'll test the change manually then. In the meantime, I had some minor wording suggestions and one small question.

src/lib/versions.ts Outdated Show resolved Hide resolved
src/lib/packages.ts Outdated Show resolved Hide resolved

expect(() => {
getTypingInfo("jquery", dt.pkgFS("jquery"));
}).toThrow("The latest version is 3.3, but a directory v3 exists.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would read better as

"The latest version of ${packageName} is 3.3, so the subdirectory 'v3' is not allowed since it applies to 3.*, which is not older than 3.3."

(Not sure about how to get across the idea of 3.* -- there might be a clearer way.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went with:

The latest version is 3.3, so the subdirectory 'v3' is not allowed; since it applies to any 3.* version, up to and including 3.3.

What do you think?

src/lib/versions.ts Outdated Show resolved Hide resolved
src/lib/packages.ts Outdated Show resolved Hide resolved
src/lib/packages.ts Outdated Show resolved Hide resolved
oldMajorVersion: number | undefined,
): TypingsDataRaw {
directoryVersion: TypingVersion | undefined,
): Omit<TypingsDataRaw, "libraryVersionDirectoryName"> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need to omit libraryVersionDirectoryName here?

Copy link
Member Author

@alloy alloy Jan 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

libraryVersionDirectoryName is not determined in this function. I could have passed the value in, only to include it in the object and return it, but that felt like bolting it on. I can go either way, if you have a strong preference.

alloy and others added 4 commits January 28, 2020 16:53
Co-Authored-By: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
@alloy
Copy link
Member Author

alloy commented Jan 28, 2020

Alright, addressed feedback 👍

@alloy
Copy link
Member Author

alloy commented Feb 12, 2020

@sandersn Could I get another review?

@sandersn
Copy link
Member

@alloy I'm about to quit for the day so I'm going to publish in the morning, around 9 AM PST (-8 GMT).

@sandersn sandersn merged commit 24c6039 into microsoft:master Feb 14, 2020
@sandersn
Copy link
Member

This is published and running on CI. I'll keep an eye out to see how it goes.

@alloy
Copy link
Member Author

alloy commented Feb 14, 2020

Ace 🙌 Thanks!

@alloy
Copy link
Member Author

alloy commented Feb 14, 2020

Looks like the fallout of this change thus far is:

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants