-
-
Notifications
You must be signed in to change notification settings - Fork 6
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
Simplify monorepo-workflow-operations #21
Conversation
f975b68
to
a87fb54
Compare
e096a90
to
e8ccf1a
Compare
be53bb8
to
3db4897
Compare
if (versionSpecifier instanceof SemVer) { | ||
const comparison = versionSpecifier.compare(currentVersion); | ||
|
||
if (comparison === 0) { |
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've moved these checks to when the release spec is validated, as it makes more sense there.
@@ -32,6 +36,11 @@ export async function determineInitialParameters( | |||
project.rootPackage.validatedManifest.name.replace('/', '__'), | |||
) | |||
: path.resolve(cwd, inputs.tempDirectory); | |||
const parsedTodayTimestamp = |
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.
This is moved from monorepo-workflow-operations
, where it was done on the fly.
* @param args.today - The current date. | ||
* @returns A promise for information about the new release. | ||
*/ | ||
export async function planRelease({ |
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.
This whole file was moved from monorepo-workflow-operations
.
const newVersion = | ||
versionSpecifier instanceof SemVer | ||
? versionSpecifier | ||
: new SemVer(currentVersion.toString()).inc(versionSpecifier); |
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.
The checks that used to be here around the new version (formerly in monorepo-workflow-operations.ts
) have been moved to validateReleaseSpecification
in release-specification.ts
.
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.
Good idea, that makes much more sense
* @param releaseName - The name of the release, which will be used to name the | ||
* commit and the branch. | ||
*/ | ||
export async function captureChangesInReleaseBranch( |
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.
This got moved from workflow-operations.ts
, as it really pertains to a repo.
* (optional) and the properties that will go into the object (optional). | ||
* @returns The mock Package object. | ||
*/ | ||
export function buildMockMonorepoRootPackage( |
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.
This is now no longer used entirely.
The tests for `monorepo-workflow-operations.ts` are not as readable or maintainable as I'd like them to be. This commit attempts to fix that. * While there isn't a whole lot we can do in terms of the scenarios we're testing because the function makes a lot of calls and the logic inside of it is somewhat complicated, we can at least move code that is responsible for parsing the TODAY environment variable, building a ReleasePlan object from the release spec, and applying the updates to the repos themselves out into separate files. This simplifies the test data and removes a few tests entirely. * We also simplify the structure of the tests so that we aren't using so many nested `describe` blocks. This ends up being very difficult to keep straight, so the flattened layout here makes it a little more palatable. * We also simplify the setup code for each test. Currently we are mocking all of the dependencies for `followMonorepoWorkflow` in one go, but we're doing so in a way that forces the reader to wade through a bunch of type definitions. That isn't really that helpful. The most complicated part of reading the tests for `followMonorepoWorkflow` isn't the dependencies — it's the logic. So we take all of the decision points we have to make in the implementation and represent those as options to our setup function in the tests so it's as clear as possible which exact scenario is being tested just by reading the test. * Finally while we're moving things around, we can also move the check we perform to ensure that the new version of a package is greater than its existing version so that it is earlier in the entire workflow, i.e. from building the release plan to the validating the release specification. This also reduces the number of tests we have to write.
3db4897
to
c30ce5c
Compare
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.
These improvements look good! I see why you removed the nested describe blocks.
I had a few questions about the tests but aside from that I've finished reviewing it all.
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.
LGTM!
The tests for
monorepo-workflow-operations.ts
are not as readable ormaintainable as I'd like them to be. This commit attempts to fix that.
we're testing because the function makes a lot of calls and the logic
inside of it is somewhat complicated, we can at least move
code that is responsible for parsing the TODAY environment variable,
building a ReleasePlan object from the release spec, and applying the
updates to the repos themselves out into separate files. This
simplifies the test data and removes a few tests entirely.
many nested
describe
blocks. This ends up being very difficult tokeep straight, so the flattened layout here makes it a little more
palatable.
mocking all of the dependencies for
followMonorepoWorkflow
in onego, but we're doing so in a way that forces the reader to wade through
a bunch of type definitions. That isn't really that helpful. The most
complicated part of reading the tests for
followMonorepoWorkflow
isn't the dependencies — it's the logic. So we take all of the
decision points we have to make in the implementation and represent
those as options to our setup function in the tests so it's as clear
as possible which exact scenario is being tested just by reading the
test.
we perform to ensure that the new version of a package is greater than
its existing version so that it is earlier in the entire workflow,
i.e. from building the release plan to the validating the release
specification. This also reduces the number of tests we have to write.