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

refactor(env-options): migrate test to reduce cyclic dependencies #1896

Merged
merged 1 commit into from
Dec 19, 2023

Conversation

erights
Copy link
Contributor

@erights erights commented Dec 12, 2023

closes: #XXXX
refs: #XXXX

Description

This PR is non-urgent, and so should wait for the current endo-release-agoric_sdk-upgrade dance to settle down.

Currently, before this PR, we get the following cyclic dependency warnings from yarn build

lerna WARN ECYCLE Dependency cycles detected, you should fix these!
lerna WARN ECYCLE @endo/compartment-mapper -> ses -> @endo/env-options -> @endo/init -> @endo/compartment-mapper
lerna WARN ECYCLE @endo/eventual-send -> (nested cycle: @endo/compartment-mapper -> ses -> @endo/env-options -> @endo/init -> @endo/compartment-mapper) -> @endo/eventual-send
lerna WARN ECYCLE @endo/lockdown -> (nested cycle: @endo/eventual-send -> (nested cycle: @endo/compartment-mapper -> ses -> @endo/env-options -> @endo/init -> @endo/compartment-mapper) -> @endo/eventual-send) -> @endo/lockdown
lerna WARN ECYCLE @endo/promise-kit -> (nested cycle: @endo/lockdown -> (nested cycle: @endo/eventual-send -> (nested cycle: @endo/compartment-mapper -> ses -> @endo/env-options -> @endo/init -> @endo/compartment-mapper) -> @endo/eventual-send) -> @endo/lockdown) -> @endo/promise-kit
lerna WARN ECYCLE @endo/ses-ava -> (nested cycle: @endo/promise-kit -> (nested cycle: @endo/lockdown -> (nested cycle: @endo/eventual-send -> (nested cycle: @endo/compartment-mapper -> ses -> @endo/env-options -> @endo/init -> @endo/compartment-mapper) -> @endo/eventual-send) -> @endo/lockdown) -> @endo/promise-kit) -> @endo/ses-ava
lerna WARN ECYCLE @endo/static-module-record -> (nested cycle: @endo/ses-ava -> (nested cycle: @endo/promise-kit -> (nested cycle: @endo/lockdown -> (nested cycle: @endo/eventual-send -> (nested cycle: @endo/compartment-mapper -> ses -> @endo/env-options -> @endo/init -> @endo/compartment-mapper) -> @endo/eventual-send) -> @endo/lockdown) -> @endo/promise-kit) -> @endo/ses-ava) -> @endo/static-module-record
lerna WARN ECYCLE (nested cycle: @endo/static-module-record -> (nested cycle: @endo/ses-ava -> (nested cycle: @endo/promise-kit -> (nested cycle: @endo/lockdown -> (nested cycle: @endo/eventual-send -> (nested cycle: @endo/compartment-mapper -> ses -> @endo/env-options -> @endo/init -> @endo/compartment-mapper) -> @endo/eventual-send) -> @endo/lockdown) -> @endo/promise-kit) -> @endo/ses-ava) -> @endo/static-module-record) -> (nested cycle: @endo/static-module-record -> (nested cycle: @endo/ses-ava -> (nested cycle: @endo/promise-kit -> (nested cycle: @endo/lockdown -> (nested cycle: @endo/eventual-send -> (nested cycle: @endo/compartment-mapper -> ses -> @endo/env-options -> @endo/init -> @endo/compartment-mapper) -> @endo/eventual-send) -> @endo/lockdown) -> @endo/promise-kit) -> @endo/ses-ava) -> @endo/static-module-record)

The @endo/env-option package participates in many of these, due only to a devDependency in support of a test. This PR moves that test to @endo/ses-ava to reduce cyclic dependencies.

Even with the PR, we still get the following cyclic dependency warnings:

lerna WARN ECYCLE Dependency cycles detected, you should fix these!
lerna WARN ECYCLE @endo/compartment-mapper -> ses -> @endo/compartment-mapper
lerna WARN ECYCLE @endo/lockdown -> (nested cycle: @endo/compartment-mapper -> ses -> @endo/compartment-mapper) -> @endo/static-module-record -> @endo/ses-ava -> @endo/lockdown
lerna WARN ECYCLE (nested cycle: @endo/lockdown -> (nested cycle: @endo/compartment-mapper -> ses -> @endo/compartment-mapper) -> @endo/static-module-record -> @endo/ses-ava -> @endo/lockdown) -> (nested cycle: @endo/lockdown -> (nested cycle: @endo/compartment-mapper -> ses -> @endo/compartment-mapper) -> @endo/static-module-record -> @endo/ses-ava -> @endo/lockdown)

These seem also to be cycles through devDependencies, and so should be fixable by the same means (and with the same costs). However, at least one supports usage from a scripts/*.js rather than a test/*.js . Could these be migrated too? What else would need to be adjusted?

Security Considerations

None

Scaling Considerations

None

Documentation Considerations

It is weird that the tests of a package are not in that package. As we repair other cyclic dependencies, we're likely to cause more of these surprises.

Testing Considerations

After this PR, no tests remain in @endo/env-options . However, the normal yarn test definition is not tolerant of that, so this PR also changes it to "exit 0". However, this means that if tests are added in the future, they may silently be ignored.

Reviewers, to avoid this problem, should this PR instead leave yarn test alone and add a placeholder test instead?

Upgrade Considerations

None

Comment on lines -15 to -17
"devDependencies": {
"ava": "^5.1.1"
},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just a drive by, but I noticed this was completely unused. Are there any tools to detect dead dependencies? It would seem to be a simple static check.

Copy link
Member

Choose a reason for hiding this comment

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

We use depcheck and if I understand it correctly, it should have caught this in its CI job. https://github.com/depcheck/depcheck

@@ -0,0 +1,7 @@
import '@endo/lockdown/commit-debug.js';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Besides migrating, also changed this from '@endo/init/debug.js' to avoid depending on @endo/eventual-send

yarn.lock Outdated
@@ -743,6 +743,41 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==

"@endo/env-options@^0.1.4":
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't worry yet about these yarn.lock changes. After the current endo-release-agoric_sdk-upgrade dance settles down and I rebase this PR, I see what fresh changes it causes to yarn.lock.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I separated the yarn.lock changes into a separate commit. Since this PR does involve package.json dependency changes, I doubt I could merge without some yarn.lock changes. However, neither should I commit these as long as #1904 needs investigation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Merging #1904 and rebasing this PR caused this PR to drop its yarn.lock changes. Redoing yarn did not create any changes. So this PR is now good to go. Thanks!

@erights erights force-pushed the markm-decyclic-env-options-init-2 branch from bd212a2 to 191c65f Compare December 12, 2023 22:38
@erights erights force-pushed the markm-decyclic-env-options-init-2 branch from 191c65f to 126d094 Compare December 18, 2023 23:49
@erights erights force-pushed the markm-decyclic-env-options-init-2 branch from 126d094 to 75e7dd6 Compare December 19, 2023 00:27
@erights erights merged commit 3622b48 into master Dec 19, 2023
14 checks passed
@erights erights deleted the markm-decyclic-env-options-init-2 branch December 19, 2023 00:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants