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

Move CountertopWorker to TypeScript #188

Merged
merged 6 commits into from
Jul 25, 2023
Merged

Conversation

slifty
Copy link
Member

@slifty slifty commented Jul 22, 2023

This PR moves the CountertopWorker class to TypeScript.

It also brings the AbstractAppliance from our @tvkitchen/base over to this project (and converts it to TypeScript as well)

Related to #153
Related to #154

@slifty
Copy link
Member Author

slifty commented Jul 22, 2023

cc @louh this PR actually represents the migration of a js class to typescript (check out the final commit for the meat and potatoes)

Instead of defining log levels we actually just want to define the shape
of the expected logger class.  I want that shape to adhere to the
defaults provided by winston [1] and pino [2], which both support
"debug, info, warn, error" (they support others, but those are the
overlap.

Issue #153

[1] https://github.com/winstonjs/winston#using-logging-levels
[2] https://getpino.io/#/docs/api?id=logger
@slifty slifty force-pushed the 153-typescript-countertop-worker branch from 862ec6b to c93f0f2 Compare July 22, 2023 19:52
@codecov
Copy link

codecov bot commented Jul 22, 2023

Codecov Report

Merging #188 (c76b220) into main (e4f9431) will decrease coverage by 6.06%.
The diff coverage is 47.40%.

❗ Current head c76b220 differs from pull request most recent head 5f155c6. Consider uploading reports for the commit 5f155c6 to get more accurate results

@@            Coverage Diff             @@
##             main     #188      +/-   ##
==========================================
- Coverage   88.96%   82.90%   -6.06%     
==========================================
  Files          22       27       +5     
  Lines         435      509      +74     
  Branches       73       93      +20     
==========================================
+ Hits          387      422      +35     
- Misses         46       83      +37     
- Partials        2        4       +2     
Flag Coverage Δ
javascript 97.53% <100.00%> (+12.91%) ⬆️
typescript 69.54% <46.71%> (-30.46%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
src/classes/CountertopStation.js 93.61% <ø> (ø)
src/classes/CountertopWorker.ts 0.00% <0.00%> (ø)
src/classes/Payload.ts 100.00% <ø> (ø)
src/types/PayloadParameters.ts 100.00% <ø> (ø)
src/test/BaseMockAppliance.ts 46.66% <46.66%> (ø)
src/test/generateMockAppliance.ts 90.90% <90.90%> (ø)
src/classes/AbstractAppliance.ts 100.00% <100.00%> (ø)
src/classes/PayloadArray.ts 100.00% <100.00%> (ø)
src/errors/AbstractImplementationError.ts 100.00% <100.00%> (ø)
src/errors/ProcessingError.ts 100.00% <100.00%> (ø)
... and 4 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@slifty slifty force-pushed the 153-typescript-countertop-worker branch from c93f0f2 to e98b831 Compare July 22, 2023 20:03
The test regex for javascript was a little extra -- it would run tests
on any file whose *path* contained test or spec after __test__.  This
could result in situations where, say, a fixture directory had the same
name as a test file and also contained javascript, causing those files
to be considered tests.

This fixes that and also adds some parallel regex for typescript based
tests
@slifty slifty force-pushed the 153-typescript-countertop-worker branch 12 times, most recently from e9236a0 to 355e0a5 Compare July 24, 2023 05:52
We don't want to know the test coverage of test code (e.g. fixtures).
@slifty slifty force-pushed the 153-typescript-countertop-worker branch 4 times, most recently from 7957344 to 0ec7447 Compare July 25, 2023 02:46
@slifty
Copy link
Member Author

slifty commented Jul 25, 2023

So here's my thinking:

  1. CountertopWorker did not have meaningful test coverage in the first place
  2. A lot of CountertopWorker is based in kafka interaction, and I do not think we want to keep kafka as part of TVK in the long run.

Which is to say... I don't think I'm going to use this PR as an opportunity to address the poor test coverage even though codecov is upset about it.

Once the TS conversion is complete I think the project will be in a good place to take a hard look at the kafka dependency, at which point it will be much easier to write more comprehensive tests for the worker.

The concept of an abstract appliance / an appliance interface had
existed in the TVKitchen base class package [1].  We had already wanted
to bring it into the countertop repository, but with TypeScript we also
get to clean up a lot of "faked" abstract behavior which should make it
much easier for developers to build their own appliances.

Issue #153 Move to Typescript
Issue #154 Base should be baked into countertop
Jest was still using ts-jest to process typescript tests, which can
cause problems in cases where the tests interacted with javascript
modules.

This removes that in favor of using our babel config.  Once we're fully
typescript we can remove babel and re-add ts-jest.
This is the first real class to be converted to Typescript.  It required
some new type definitions for kafka, and unfortunately also had to
include some temporary lint-disabling since the worker relies on stream
and stream doesn't yet have types.

Issue #153 Move to Typescript
@slifty slifty force-pushed the 153-typescript-countertop-worker branch from 0ec7447 to 5f155c6 Compare July 25, 2023 03:00
@slifty slifty merged commit 932b989 into main Jul 25, 2023
2 of 4 checks passed
@slifty slifty deleted the 153-typescript-countertop-worker branch July 25, 2023 03:02
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.

None yet

1 participant