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(test-tooling): fix types of streams: use NodeJS.ReadableStream #3047

Conversation

petermetz
Copy link
Contributor

  1. The container management library that we use in the test infrastructure
    (called dockerode) is expecting streams that are defined in the global
    namespace of the @types/node library, e.g. the standard library of NodeJS
    itself.
  2. Previously we were using the "streams" package to provide type information
    to the streams that we were passing around to dockerode and it was working
    fine, but after some changes that seem unrelated this has broken the
    compilation process.
  3. The mentioned changes are not yet on the main branch, but we expect
    them to be there soon and so this change is laying the groundwork for that
    by pre-emptively fixing the broken build's root cause which is that the
    test-tooling package does not declare it's typings related dependencies
    correctly: It implicitly uses the NodeJS standard library's types but
    so far had not declared them on the package level.
  4. This change is therefore to rectify the issue of the @types/node
    dependency missing from the test-tooling package and also the refactoring
    of some of the test ledger classes which were relying on the streams
    builtin package instead of correctly using the NodeJS.ReadableStream global.
  5. Earlier the reasoning for this was that we try to avoid pulling in
    types from the global scope because we try to avoid any sort of dependency
    on the global scope in general. Once we have proof though that this is
    causing issues with the build, then we must give up the principle for
    practical reasons (and only in the minimum viable scope, e.g. this does
    not change the fact that everywhere else in the codebase we should still
    do our best to avoid using the global scoped classes, types, functions,
    etc..).

Thank you to @AndreAugusto11 and @RafaelAPB for pointing out this issue
through the pull request of his that is currently being worked on at the
time of this writing:
RafaelAPB#72

Related to but does not address #2811

Signed-off-by: Peter Somogyvari peter.somogyvari@accenture.com

Pull Request Requirements

  • Rebased onto upstream/main branch and squashed into single commit to help maintainers review it more efficient and to avoid spaghetti git commit graphs that obfuscate which commit did exactly what change, when and, why.
  • Have git sign off at the end of commit message to avoid being marked red. You can add -s flag when using git commit command. You may refer to this link for more information.
  • Follow the Commit Linting specification. You may refer to this link for more information.

Character Limit

  • Pull Request Title and Commit Subject must not exceed 72 characters (including spaces and special characters).
  • Commit Message per line must not exceed 80 characters (including spaces and special characters).

A Must Read for Beginners
For rebasing and squashing, here's a must read guide for beginners.

@RafaelAPB
Copy link
Contributor

One comment: 🥵. In a more serious tone, great work @petermetz and @AndreAugusto11

Copy link
Contributor

@jagpreetsinghsasan jagpreetsinghsasan left a comment

Choose a reason for hiding this comment

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

LGTM

@petermetz petermetz force-pushed the refactor-test-tooling-nodejs-types-stream-usage branch from 3f23bf1 to 8139132 Compare March 4, 2024 07:42
packages/cactus-test-tooling/package.json Outdated Show resolved Hide resolved
@petermetz petermetz force-pushed the refactor-test-tooling-nodejs-types-stream-usage branch from 8139132 to edd28cc Compare March 4, 2024 17:01
@petermetz petermetz requested a review from outSH March 4, 2024 17:02
1. The container management library that we use in the test infrastructure
(called dockerode) is expecting streams that are defined in the global
namespace of the `@types/node` library, e.g. the standard library of NodeJS
itself.
2. Previously we were using the "streams" package to provide type information
to the streams that we were passing around to dockerode and it was working
fine, but after some changes that seem unrelated this has broken the
compilation process.
3. The mentioned changes are not yet on the main branch, but we expect
them to be there soon and so this change is laying the groundwork for that
by pre-emptively fixing the broken build's root cause which is that the
test-tooling package does not declare it's typings related dependencies
correctly: It implicitly uses the NodeJS standard library's types but
so far had not declared them on the package level.
4. This change is therefore to rectify the issue of the `@types/node`
dependency missing from the test-tooling package and also the refactoring
of some of the test ledger classes which were relying on the `streams`
builtin package instead of correctly using the NodeJS.ReadableStream global.
5. Earlier the reasoning for this was that we try to avoid pulling in
types from the global scope because we try to avoid any sort of dependency
on the global scope in general. Once we have proof though that this is
causing issues with the build, then we must give up the principle for
practical reasons (and only in the minimum viable scope, e.g. this does
not change the fact that everywhere else in the codebase we should still
do our best to avoid using the global scoped classes, types, functions,
etc..).

Thank you to @AndreAugusto11 and @RafaelAPB for pointing out this issue
through the pull request of his that is currently being worked on at the
time of this writing:
RafaelAPB#72

Related to but does not address hyperledger-cacti#2811

Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
@petermetz petermetz force-pushed the refactor-test-tooling-nodejs-types-stream-usage branch from edd28cc to 5b602f9 Compare March 4, 2024 17:02
@petermetz petermetz merged commit 59dbd6a into hyperledger-cacti:main Mar 4, 2024
122 of 147 checks passed
@petermetz petermetz deleted the refactor-test-tooling-nodejs-types-stream-usage branch March 4, 2024 17:39
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.

4 participants