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

TypeScript support for the existing Node.js example #5325

Merged
merged 4 commits into from
Feb 3, 2021

Conversation

onpaws
Copy link
Contributor

@onpaws onpaws commented Jan 31, 2021

Hi there, I'm Pat. First time contributor. Thanks for your efforts on skaffold!

Fixes: #4261

Description

The example Node.js project is a great starting point for JavaScript developers. Some developers may prefer to use TypeScript, so this PR intends to do the minimum number of steps to port the existing Node.js example to TypeScript, making sure hot reload still works in the expected way.

Steps I took:

  • Duplicated examples/nodejs and renamed to examples/typescript
  • npm install typescript
  • tsc --init and accepted all defaults.
  • Added the minimum necessary type dependencies (@types/express and @types/node) to keep the compiler happy.
  • Ported the two JavaScript files to TypeScript.
  • Swapped nodemon for tsc-watch, which appears to be drop-in compatible.

Follow-up Work
[VS Code] Potentially consider remote debugging

Tests

I didn't write new tests because I'm not sure what exactly it should mean to "test" an example.

That being said make test seems to still pass:

Generated proto files are updated!
PASSED hack/test-generated-proto.sh in 2s
Running linters...
RUN hack/boilerplate.sh
PASSED hack/boilerplate.sh in 1s
RUN hack/gofmt.sh
PASSED hack/gofmt.sh in 1s
RUN hack/golangci-lint.sh
Installing GolangCI-Lint
golangci/golangci-lint info checking GitHub for tag 'v1.30.0'
golangci/golangci-lint info found version: 1.30.0 for v1.30.0/darwin/amd64
golangci/golangci-lint info installed /Users/paws/Developer/skaffold/hack/bin/golangci-lint
PASSED hack/golangci-lint.sh in 62s

Same for make integration -- the new examples/typescript folder did show up in the output and it appears to pass also. (I'm not going to pretend I understand what this test suite is actually doing :) Maybe it copies all the examples into examples/?)

<snip>
=== RUN   TestDiagnose/typescript
time="2021-01-31T13:51:49+01:00" level=info msg="Running [skaffold diagnose] in examples/typescript"
time="2021-01-31T13:51:49+01:00" level=info msg="Ran [skaffold diagnose] in 107.417913ms"
<snip>
--- PASS: TestDiagnose/typescript (0.11s)
<snip>

Versions

OS: macOS 11.1 20C69
Node: v14.15.4
TypeScript: 4.1.3

@onpaws onpaws requested a review from a team as a code owner January 31, 2021 13:02
@google-cla
Copy link

google-cla bot commented Jan 31, 2021

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@codecov
Copy link

codecov bot commented Jan 31, 2021

Codecov Report

Merging #5325 (28692a7) into master (c254d25) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #5325   +/-   ##
=======================================
  Coverage   71.80%   71.80%           
=======================================
  Files         392      392           
  Lines       14228    14228           
=======================================
  Hits        10217    10217           
  Misses       3259     3259           
  Partials      752      752           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c254d25...28692a7. Read the comment docs.

@onpaws onpaws force-pushed the examples/typescript branch from 0f24f10 to 0106c13 Compare January 31, 2021 13:16
@google-cla google-cla bot added cla: yes and removed cla: no labels Jan 31, 2021
@onpaws
Copy link
Contributor Author

onpaws commented Jan 31, 2021

@googlebot I fixed it.

@onpaws
Copy link
Contributor Author

onpaws commented Jan 31, 2021

I see Travis tests mostly pass, except for buildpacks, which I find a bit curious b/c I didn't touch anything to do with buildpacks, at least AFAIK. Happy to look into it - have a feeling rebase-ing this PR off some other commit than master may resolve. Is there a better branch to target? What do you think?

FAIL: TestDebug/buildpacks (390.59s)

@IsaacPD
Copy link
Contributor

IsaacPD commented Feb 1, 2021

Thanks for the contribution @onpaws , I believe there's an issue with the buildpacks test, I've been seeing failures on some of our recent PRs. So I would not worry to much about it but feel free to report any findings related to the issue to #5326 .

In regards to the changes you made, you added the example under integration\examples, could you also duplicate it under examples?

@gsquared94
Copy link
Contributor

gsquared94 commented Feb 1, 2021

In regards to the changes you made, you added the example under integration\examples, could you also duplicate it under examples?

@IsaacPD the examples directory gets populated from integration/examples on every new version release. It doesn't need to be done manually.

@onpaws
Copy link
Contributor Author

onpaws commented Feb 1, 2021

@IsaacPD my first commit actually put it in examples/ like you said, but then I saw the README section 'Note for contributors' and it sounds like a build script does it automatically. Thanks for looking out :)

@IsaacPD
Copy link
Contributor

IsaacPD commented Feb 3, 2021

The test have that are failing have been temporarily disabled on master, could you please rebase to catch these changes and prevent travis from failing. Thanks

@onpaws
Copy link
Contributor Author

onpaws commented Feb 3, 2021

Yep, you got it, coming right up

@onpaws onpaws force-pushed the examples/typescript branch from e67cf4c to 28692a7 Compare February 3, 2021 21:47
@onpaws
Copy link
Contributor Author

onpaws commented Feb 3, 2021

Hopefully this is the desired commit:
097325d65..c254d2512 master -> upstream/master

Let's see if the tests pass this time 🤞

Update: hooray, looks like they did 🥳

@gsquared94 gsquared94 added the kokoro:force-run forces a kokoro re-run on a PR label Feb 3, 2021
@kokoro-team kokoro-team removed the kokoro:force-run forces a kokoro re-run on a PR label Feb 3, 2021
@IsaacPD IsaacPD merged commit e66f04c into GoogleContainerTools:master Feb 3, 2021
@onpaws onpaws deleted the examples/typescript branch February 4, 2021 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Typescript sample project
4 participants