Skip to content

Comments

ci: test samples and examples with a packaged bolt build#2372

Merged
zimeg merged 11 commits intomainfrom
zimeg-fix-express-types-dependency
Feb 11, 2025
Merged

ci: test samples and examples with a packaged bolt build#2372
zimeg merged 11 commits intomainfrom
zimeg-fix-express-types-dependency

Conversation

@zimeg
Copy link
Member

@zimeg zimeg commented Dec 17, 2024

Summary

This PR explores broken builds due to missing @types/express from the most recent release 👀

> tsc --noemit --module commonjs --project ./tsconfig.json
node_modules/@slack/bolt/dist/receivers/ExpressReceiver.d.ts(9,98): error TS7016: Could not find a declaration file for module 'express'. '/home/runner/work/slack-sandbox/slack-sandbox/js.bolt.tails/node_modules/express/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/express` if it exists or add a new declaration (.d.ts) file containing `declare module 'express';`
node_modules/@slack/bolt/dist/receivers/ParamsIncomingMessage.d.ts(3,39): error TS2307: Cannot find module 'express-serve-static-core' or its corresponding type declarations.

Preview

  • This test passes when using npm pack without removing node_modules
  • This test fails when using npm pack and removing node_modules

Notes

  • Moving @types/express back into dependencies seems like a fix to the above errors, but this was difficult to confirm with local setups. Hoping to improve our CI testing and return @types/express in perhaps another PR to prevent this regression in future changes 😓
  • The PR isn't in a state to be merged right now, but I'm super interested in feedback on this testing approach!

Requirements

@zimeg zimeg added bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented semver:patch TypeScript-specific dependencies Pull requests that update a dependency file labels Dec 17, 2024
@zimeg zimeg added this to the 4.2.1 milestone Dec 17, 2024
@zimeg zimeg self-assigned this Dec 17, 2024
@codecov
Copy link

codecov bot commented Dec 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.59%. Comparing base (dcfbab3) to head (d72132f).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2372   +/-   ##
=======================================
  Coverage   92.59%   92.59%           
=======================================
  Files          36       36           
  Lines        7472     7472           
  Branches      653      653           
=======================================
  Hits         6919     6919           
  Misses        545      545           
  Partials        8        8           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member Author

@zimeg zimeg left a comment

Choose a reason for hiding this comment

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

📝 Leaving a few notes from findings during the most recent adventures. I'm so open to thoughts and changing the goal of this PR.

IMO testing samples with npm pack might be nice to split into a separate change, but I'm rambling now...

Comment on lines +25 to +29
- name: Package the latest changes to bolt-js
run: npm i && npm pack . && rm -rf node_modules
- name: Install example dependencies for testing
working-directory: ${{ matrix.example }}
run: npm i && npm link @slack/bolt
run: npm i && npm i ../../slack-bolt-*.tgz
Copy link
Member Author

Choose a reason for hiding this comment

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

Some TILs are included here, though I believe this can still be improved:

  • npm pack will package @slack/bolt as if it's going to be released
  • node_modules of the bolt-js repo must be removed or nested directories can make use of these pacakges

The *.tgz file seems ideal for testing in a production environment like this since it lets us build bolt-js then remove its node_modules before testing a sample!

I'm not thrilled with the relative paths here, but am interested in if this is an approach we're alright taking?

Copy link
Contributor

Choose a reason for hiding this comment

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

Using relative path here should be fine, if something changes and this path is broken, the test should fail and inform us that the path is broken

@zimeg zimeg changed the title build: revert installing @types/express under the dev dependencies ci: test samples and examples with a packaged bolt build Dec 17, 2024
@zimeg zimeg added discussion M-T: An issue where more input is needed to reach a decision tests M-T: Testing work only and removed bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented dependencies Pull requests that update a dependency file labels Dec 17, 2024
@zimeg zimeg requested review from a team, WilliamBergamin and seratch December 17, 2024 06:25
@zimeg zimeg marked this pull request as ready for review December 17, 2024 06:25
@zimeg zimeg marked this pull request as draft January 9, 2025 01:00
@zimeg zimeg modified the milestones: 4.2.1, 4.x Feb 10, 2025
Copy link
Member Author

@zimeg zimeg left a comment

Choose a reason for hiding this comment

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

📝 A few notes for the kind reviewer!

With the changes in #2421 landing, tests across these samples are passing. I plan to follow up with similar skipLibCheck updates across sample apps used in testing, but for now I think this contains a nice improvement to tests 🔬 ✨

"resolveJsonModule": true,
"rootDir": "src",
"skipLibCheck": true,
"skipLibCheck": false,
Copy link
Member Author

Choose a reason for hiding this comment

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

When this is set to true, build errors relating to other packages do not appear. Reference 📚

That includes what was surfaced in #2409 👾

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice thanks 💯 it makes sense to set this as false, allows the CI to validate against the packages used by the project

"resolveJsonModule": true,
"allowSyntheticDefaultImports": true,
"allowJs": true,
"skipLibCheck": false,
Copy link
Member Author

Choose a reason for hiding this comment

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

@zimeg zimeg marked this pull request as ready for review February 10, 2025 22:37
Copy link
Contributor

@WilliamBergamin WilliamBergamin left a comment

Choose a reason for hiding this comment

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

This is great 💯 using npm pack rather then npm link brings this test closer to the end user experience and should allow us to catch unexpected behaviors

thanks for working on this 🚀

Any thoughts on updating the maintainers_guide to recommend npm pack for local testing?

"resolveJsonModule": true,
"rootDir": "src",
"skipLibCheck": true,
"skipLibCheck": false,
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice thanks 💯 it makes sense to set this as false, allows the CI to validate against the packages used by the project

Comment on lines +25 to +29
- name: Package the latest changes to bolt-js
run: npm i && npm pack . && rm -rf node_modules
- name: Install example dependencies for testing
working-directory: ${{ matrix.example }}
run: npm i && npm link @slack/bolt
run: npm i && npm i ../../slack-bolt-*.tgz
Copy link
Contributor

Choose a reason for hiding this comment

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

Using relative path here should be fine, if something changes and this path is broken, the test should fail and inform us that the path is broken

@zimeg
Copy link
Member Author

zimeg commented Feb 11, 2025

@WilliamBergamin thanks a ton for the review and feedback! I'm hoping to merge this soon, but am sharing a few more thoughts:

using npm pack rather then npm link brings this test closer to the end user experience and should allow us to catch unexpected behaviors

I'm most excited for this. Finding this gap in our testing was difficult with a combination of the above tsconfig example settings and running tests with devDependences installed. I'm hoping we don't find surprises in these packages 🎁 ✨

Any thoughts on updating the maintainers_guide to recommend npm pack for local testing?

Super great call and added in d72132f! I was worried this would add some overhead to fast iteration but I remembered the npm run build script is required to use the latest changes anyways, so replacing this with npm pack isn't too bad!

The tests are all passing now, but before merging I want to make a few changes to the typescript samples found on @slack-samples to match the included examples, then re-run the tests. Hoping nothing changes with this, but I can't be certain 🚢

@zimeg
Copy link
Member Author

zimeg commented Feb 11, 2025

☝️ Changes to samples have been made, but are failing tests with the current @slack/bolt release (IMO this is "good"!) so I'll hold off on merging those for now.

With the other updates made here I think it's a good time to merge this. All for the sake of testing 🔬 ✨

@zimeg zimeg merged commit 5b5bd89 into main Feb 11, 2025
18 checks passed
@zimeg zimeg deleted the zimeg-fix-express-types-dependency branch February 11, 2025 18:13
Copy link
Contributor

@WilliamBergamin WilliamBergamin left a comment

Choose a reason for hiding this comment

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

Nice thanks for making this happen 💯

I left 2 comments one is a NIT that can be ignored if you feel the style is off


#### Local Development

Using in progress changes made to this package in another app is sometimes useful in experiments. A packaged build of Bolt for JavaScript can be created with `npm pack` and installed in a project with `npm install ../slack-bolt-*.tgz`. The packaged build includes dependencies published with Bolt for JavaScript, including required peer dependencies but not devDependencies, to imitate actual installations.
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: what do you think about making this in point/step format

Suggested change
Using in progress changes made to this package in another app is sometimes useful in experiments. A packaged build of Bolt for JavaScript can be created with `npm pack` and installed in a project with `npm install ../slack-bolt-*.tgz`. The packaged build includes dependencies published with Bolt for JavaScript, including required peer dependencies but not devDependencies, to imitate actual installations.
Using in progress changes made to this package in an app can be useful for development.
Use the pack command to package the project
```zsh
npm pack
```
Install the `slack-bolt-*.tgz` to use your changes
```zsh
npm install path/to/bolt-js/slack-bolt-*.tgz
```
The packaged build includes dependencies published with Bolt for JavaScript, including required peer dependencies but not devDependencies, to imitate actual installations.


Using in progress changes made to this package in another app is sometimes useful in experiments. A packaged build of Bolt for JavaScript can be created with `npm pack` and installed in a project with `npm install ../slack-bolt-*.tgz`. The packaged build includes dependencies published with Bolt for JavaScript, including required peer dependencies but not devDependencies, to imitate actual installations.

Remove cached project dependencies with `rm -rf node_modules` between those steps to keep the cache clean.
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should mention removing the package-lock.json as well 🤔

And I don't think we need the force flag for this, but correct me if I'm wrong

Suggested change
Remove cached project dependencies with `rm -rf node_modules` between those steps to keep the cache clean.
Remove cached project dependencies with `rm -r node_modules package-lock.json ` between those steps to keep the cache clean.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've been relying on the npm command to keep the package-lock.json most relevant, but for development it seems alright to regenerate this afresh! Good call 👏

I also tend to prefer rm -rf because it's "really fast" but sometimes permissions catch me 😉

@zimeg
Copy link
Member Author

zimeg commented Feb 11, 2025

@WilliamBergamin Ooh I'm way more a fan of spaced sections. I was hoping to match the surrounding sections with this change, but IMO revisiting this guide to use command sections would be most ideal 👁️‍🗨️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

discussion M-T: An issue where more input is needed to reach a decision semver:patch tests M-T: Testing work only TypeScript-specific

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants