René's URL Explorer Experiment


Title: Respond to incoming HTTPS requests when all work is done by phillipj · Pull Request #258 · nodejs/github-bot · GitHub

Open Graph Title: Respond to incoming HTTPS requests when all work is done by phillipj · Pull Request #258 · nodejs/github-bot

X Title: Respond to incoming HTTPS requests when all work is done by phillipj · Pull Request #258 · nodejs/github-bot

Description: TLDR; upgrading the package we use to talk to github.com causes integrations tests to break, and those tests are currently unreliable. The package we're using to talk to github.com uses a deprecated authentication mechanism that I regularly get emails about: https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/. While naively trying to upgrade that package, I stumbled opened up a can of worms that I want to fix properly first... What has changed? Make integration tests execute all external API request expectations Previously only a few of the external API request expectations setup with nock.js has been run (details explained in the long story below). How we run those expectations was introduced in the beginning of this project, a blooper I'm most likely to blame for, and copy-pasted later on. Make server respond to incoming HTTPS requests after all event listeners has finished executing Primarily to make our tests more reliable. For that to happen we need to be confident the code we're running tests on, has finished executing. Replace internal pub/sub mechanism from raw EventEmitter to something where we know when all listeners has finished executing Lots of the internals of the github-bot is setup as event listeners subscribing for events like pull_request.opened. Those events are in practise GitHub webhook events. For us to be able to know when all event listeners are done with their work, using pure EventEmitter does not cut it because our listeners perform asynchronous work. To mitigate that, events-async has been installed. It allows us to know when all (webhook) event listeners has executed as long as listeners returns a Promise. Refactoring our listeners from a callback/fire-n-forget type of code, to return a Promise, obviously involves quite a lot of changes. Those changes has been written to not change any behaviour, but rather only promisify them. The long story Up until now, a handful of integration tests has been flawed because we didn't actually verify all nock.js expectations (read: nock.js scope) had been fulfilled. That was due to a desire to run several methods as a one-liner instead of one per line; filesScope.done() && existingRepoLabelsScope.done() That could make sense at first glance, but there's a very important catch we didn't think about when writing it; it requires .done() to return a truthy value or else what comes after .done() will not be executed. The .done() method on nock.js' scope either throws an exception if the expectation it represents has not been met, or returns undefined when all is good. That undefined value stops the subsequent methods on the same line to be executed. In other words, we have always just checked the first expectation, and none of the subsequent ones on the same line. The changes introduced in this commit executes these .done()s on their own line which sadly causes all of the related tests to explode at the moment. Why most of these expectations haven't been met is probably due to timing issues, since we don't wait for all the related code to have finished executing before the tests are run. As of now, the code has been written in a fashion that allows incoming HTTPS requests to be get their response ASAP, whilst the code pushing PR statuses to github.com or trigger Jenkins builds are still running. That raises some challenges for our integration tests since they don't really know when the code is finished, meaning tests can run. Upcoming changes will fix that by ensuring incoming requests will get their response after all relevant code has succeeded or failed. That will introduce quite a big refactor job, but the end result will be a lot more robust tests that can be trusted. Sooo with that braindump out of the way, any immediate thoughts? I assume there's very few comfortable reviewing and approving these changes. Still would appreciate any kinds of feedback, good and bad, high level or detailed, I'm all ears! Most importantly is getting ack from someone active near the core collaborator community that can point my way if any awkwardness happens that I don't catch myself. I'm ready to jump and investigate when needed.

Open Graph Description: TLDR; upgrading the package we use to talk to github.com causes integrations tests to break, and those tests are currently unreliable. The package we're using to talk to github.com uses a depre...

X Description: TLDR; upgrading the package we use to talk to github.com causes integrations tests to break, and those tests are currently unreliable. The package we're using to talk to github.com uses a d...

Opengraph URL: https://github.com/nodejs/github-bot/pull/258

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:46527ec4-2bb1-c3a1-2073-a8a5257d0fcb
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idEDF6:50FD4:2751AF2:35F96C7:6A4EF27D
html-safe-nonce3eb93966f349fe7d054b9059e95c4be165a3b17e202a3d684448961da45b98b8
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFREY2OjUwRkQ0OjI3NTFBRjI6MzVGOTZDNzo2QTRFRjI3RCIsInZpc2l0b3JfaWQiOiI3OTQ3NDc3MTkzNjIxMTcyODYxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac50325097ce0df4c23b2c631277d85358f6385e9ae62e982b65d682c9da5c2806
hovercard-subject-tagpull_request:401878950
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/nodejs/github-bot/pull/258/files
twitter:imagehttps://avatars.githubusercontent.com/u/1231635?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/1231635?s=400&v=4
og:image:altTLDR; upgrading the package we use to talk to github.com causes integrations tests to break, and those tests are currently unreliable. The package we're using to talk to github.com uses a depre...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Noneb92d11c0aa4a77d54ef4af1078b6a15fb5a70a215b30c4ecf28889d5a8e656d9
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/nodejs/github-bot git https://github.com/nodejs/github-bot.git
octolytics-dimension-user_id9950313
octolytics-dimension-user_loginnodejs
octolytics-dimension-repository_id55435270
octolytics-dimension-repository_nwonodejs/github-bot
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id55435270
octolytics-dimension-repository_network_root_nwonodejs/github-bot
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release00d04d6b867d2f16ab50bebae8ccc56e07c8988b
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/nodejs/github-bot/pull/258/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fgithub-bot%2Fpull%2F258%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fgithub-bot%2Fpull%2F258%2Ffiles
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=nodejs%2Fgithub-bot
Reloadhttps://github.com/nodejs/github-bot/pull/258/files
Reloadhttps://github.com/nodejs/github-bot/pull/258/files
Reloadhttps://github.com/nodejs/github-bot/pull/258/files
Please reload this pagehttps://github.com/nodejs/github-bot/pull/258/files
nodejs https://github.com/nodejs
github-bothttps://github.com/nodejs/github-bot
Please reload this pagehttps://github.com/nodejs/github-bot/pull/258/files
Notifications https://github.com/login?return_to=%2Fnodejs%2Fgithub-bot
Fork 138 https://github.com/login?return_to=%2Fnodejs%2Fgithub-bot
Star 300 https://github.com/login?return_to=%2Fnodejs%2Fgithub-bot
Code https://github.com/nodejs/github-bot
Issues 18 https://github.com/nodejs/github-bot/issues
Pull requests 2 https://github.com/nodejs/github-bot/pulls
Actions https://github.com/nodejs/github-bot/actions
Projects https://github.com/nodejs/github-bot/projects
Security and quality 0 https://github.com/nodejs/github-bot/security
Insights https://github.com/nodejs/github-bot/pulse
Code https://github.com/nodejs/github-bot
Issues https://github.com/nodejs/github-bot/issues
Pull requests https://github.com/nodejs/github-bot/pulls
Actions https://github.com/nodejs/github-bot/actions
Projects https://github.com/nodejs/github-bot/projects
Security and quality https://github.com/nodejs/github-bot/security
Insights https://github.com/nodejs/github-bot/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fnodejs%2Fgithub-bot%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fnodejs%2Fgithub-bot%2Fissues%2Fnew%2Fchoose
phillipjhttps://github.com/phillipj
nodejs:masterhttps://github.com/nodejs/github-bot/tree/master
phillipj:resilient-tests-refactorhttps://github.com/phillipj/github-bot/tree/resilient-tests-refactor
Conversation 6 https://github.com/nodejs/github-bot/pull/258
Commits 6 https://github.com/nodejs/github-bot/pull/258/commits
Checks 0 https://github.com/nodejs/github-bot/pull/258/checks
Files changed https://github.com/nodejs/github-bot/pull/258/files
Please reload this pagehttps://github.com/nodejs/github-bot/pull/258/files
Respond to incoming HTTPS requests when all work is done https://github.com/nodejs/github-bot/pull/258/files#top
Show all changes 6 commits https://github.com/nodejs/github-bot/pull/258/files
249b062 Make flawed integration tests explode by fixing nock expectations phillipj Apr 10, 2020 https://github.com/nodejs/github-bot/pull/258/commits/249b0622d15d67a17fa5ceaee8e36f9f848d226d
e34a7c8 Remove majority of fake timers use while testing phillipj Apr 11, 2020 https://github.com/nodejs/github-bot/pull/258/commits/e34a7c8f65e51457b2d2166766cf7e8952d2c55e
d7adb14 Reinitialise app before each label integration test to avoid label cache phillipj Apr 14, 2020 https://github.com/nodejs/github-bot/pull/258/commits/d7adb14801dc02ba9eb022fdc70fb797dd33cbd5
1639a84 Respond to GitHub events webhook HTTPS requests when all work is done phillipj Apr 11, 2020 https://github.com/nodejs/github-bot/pull/258/commits/1639a84059686735703f44c1864d89b3ac596e94
47c3ecd Move require() of all scripts from ./app.js to ./server.js phillipj May 8, 2020 https://github.com/nodejs/github-bot/pull/258/commits/47c3ecdbc06654637782325bc897d429f882268e
0652131 Add missing timers and v6.x label in integration labels fixture phillipj Apr 11, 2020 https://github.com/nodejs/github-bot/pull/258/commits/06521318225e9e1f0362a0a17e524df83086b5f6
Clear filters https://github.com/nodejs/github-bot/pull/258/files
Please reload this pagehttps://github.com/nodejs/github-bot/pull/258/files
Please reload this pagehttps://github.com/nodejs/github-bot/pull/258/files
app.js https://github.com/nodejs/github-bot/pull/258/files#diff-e07d531ac040ce3f40e0ce632ac2a059d7cd60f20e61f78268ac3be015b3b28f
github-comment.js https://github.com/nodejs/github-bot/pull/258/files#diff-7c972d337be181378d12552fcb9c1aaed5a933bc8d259485fd84d0fe42cb14c5
github-events.js https://github.com/nodejs/github-bot/pull/258/files#diff-6551d4674fc5e162e28fd0e709ac0ccfb7954d22893a85f87f3f7cc375896988
node-repo.js https://github.com/nodejs/github-bot/pull/258/files#diff-34cc967d4efd1db9679ce2af367b4ddd311b20381e80e4c5443d27a446fe5646
package-lock.json https://github.com/nodejs/github-bot/pull/258/files#diff-053150b640a7ce75eff69d1a22cae7f0f94ad64ce9a855db544dda0929316519
package.json https://github.com/nodejs/github-bot/pull/258/files#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519
node-subsystem-label.js https://github.com/nodejs/github-bot/pull/258/files#diff-8c4ca1c70d17ea8cecc3c96d2cb899aea7dd243fb1d4b51bb9edba83033d4fd4
trigger-jenkins-build.js https://github.com/nodejs/github-bot/pull/258/files#diff-de897b05536d670fbd137691b37e01cb99ab2f3027cd54b670c25d84bb7610a8
server.js https://github.com/nodejs/github-bot/pull/258/files#diff-a4c65ede64197e1a112899a68bf994485b889c4b143198bac4af53425b38406f
repo-labels-page-2.json https://github.com/nodejs/github-bot/pull/258/files#diff-5bbc84c39e48454491b3fb73b8f9597bb51eca5d06f99dadf77ce0ea144a5a0c
repo-labels.json https://github.com/nodejs/github-bot/pull/258/files#diff-c5ab1846b0279dc7dadb0c53af67cf10f05e30cb50ff9ea5b37a6055735879ae
node-labels-webhook.test.js https://github.com/nodejs/github-bot/pull/258/files#diff-ae0ef3b15365ff6ca46c4352e9314822d6e38b6312bc506d356f5109d1949dd5
ping.test.js https://github.com/nodejs/github-bot/pull/258/files#diff-460f7b21350e4fd5b02d3f4b235e658a1d9c1fc7b79a7b2c4996e786b07666a1
push-jenkins-update.test.js https://github.com/nodejs/github-bot/pull/258/files#diff-6e27ee546c8dba3234dae1f82ee42bfb61bd363f47eb2de071f387d3644311e5
trigger-jenkins-build.test.js https://github.com/nodejs/github-bot/pull/258/files#diff-3ed94a2c9b80f41b4287845f687930d626c1e8d691177553ed35c8fcac472da9
node-repo.test.js https://github.com/nodejs/github-bot/pull/258/files#diff-4782f2bbbf4592f5f0be0c0348b9251841cdd21c113caa9acd747b1cfbe1796d
app.jshttps://github.com/nodejs/github-bot/pull/258/files#diff-e07d531ac040ce3f40e0ce632ac2a059d7cd60f20e61f78268ac3be015b3b28f
View file https://github.com/phillipj/github-bot/blob/06521318225e9e1f0362a0a17e524df83086b5f6/app.js
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/nodejs/github-bot/pull/258/{{ revealButtonHref }}
https://github.com/nodejs/github-bot/pull/258/files#diff-e07d531ac040ce3f40e0ce632ac2a059d7cd60f20e61f78268ac3be015b3b28f
lib/github-comment.jshttps://github.com/nodejs/github-bot/pull/258/files#diff-7c972d337be181378d12552fcb9c1aaed5a933bc8d259485fd84d0fe42cb14c5
View file https://github.com/phillipj/github-bot/blob/06521318225e9e1f0362a0a17e524df83086b5f6/lib/github-comment.js
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/nodejs/github-bot/pull/258/{{ revealButtonHref }}
https://github.com/nodejs/github-bot/pull/258/files#diff-7c972d337be181378d12552fcb9c1aaed5a933bc8d259485fd84d0fe42cb14c5
lib/github-events.jshttps://github.com/nodejs/github-bot/pull/258/files#diff-6551d4674fc5e162e28fd0e709ac0ccfb7954d22893a85f87f3f7cc375896988
View file https://github.com/phillipj/github-bot/blob/06521318225e9e1f0362a0a17e524df83086b5f6/lib/github-events.js
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/nodejs/github-bot/pull/258/{{ revealButtonHref }}
https://github.com/nodejs/github-bot/pull/258/files#diff-6551d4674fc5e162e28fd0e709ac0ccfb7954d22893a85f87f3f7cc375896988
https://github.com/nodejs/github-bot/pull/258/files#diff-6551d4674fc5e162e28fd0e709ac0ccfb7954d22893a85f87f3f7cc375896988
https://github.com/nodejs/github-bot/pull/258/files#diff-6551d4674fc5e162e28fd0e709ac0ccfb7954d22893a85f87f3f7cc375896988
lib/node-repo.jshttps://github.com/nodejs/github-bot/pull/258/files#diff-34cc967d4efd1db9679ce2af367b4ddd311b20381e80e4c5443d27a446fe5646
View file https://github.com/phillipj/github-bot/blob/06521318225e9e1f0362a0a17e524df83086b5f6/lib/node-repo.js
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/nodejs/github-bot/pull/258/{{ revealButtonHref }}
https://github.com/nodejs/github-bot/pull/258/files#diff-34cc967d4efd1db9679ce2af367b4ddd311b20381e80e4c5443d27a446fe5646
https://github.com/nodejs/github-bot/pull/258/files#diff-34cc967d4efd1db9679ce2af367b4ddd311b20381e80e4c5443d27a446fe5646
https://github.com/nodejs/github-bot/pull/258/files#diff-34cc967d4efd1db9679ce2af367b4ddd311b20381e80e4c5443d27a446fe5646
https://github.com/nodejs/github-bot/pull/258/files#diff-34cc967d4efd1db9679ce2af367b4ddd311b20381e80e4c5443d27a446fe5646
package-lock.jsonhttps://github.com/nodejs/github-bot/pull/258/files#diff-053150b640a7ce75eff69d1a22cae7f0f94ad64ce9a855db544dda0929316519
View file https://github.com/phillipj/github-bot/blob/06521318225e9e1f0362a0a17e524df83086b5f6/package-lock.json
Open in desktop https://desktop.github.com
how customized files appear on GitHubhttps://docs.github.com/github/administering-a-repository/customizing-how-changed-files-appear-on-github
Please reload this pagehttps://github.com/nodejs/github-bot/pull/258/files
package.jsonhttps://github.com/nodejs/github-bot/pull/258/files#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519
View file https://github.com/phillipj/github-bot/blob/06521318225e9e1f0362a0a17e524df83086b5f6/package.json
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/nodejs/github-bot/pull/258/{{ revealButtonHref }}
https://github.com/nodejs/github-bot/pull/258/files#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519
https://github.com/nodejs/github-bot/pull/258/files#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519
scripts/node-subsystem-label.jshttps://github.com/nodejs/github-bot/pull/258/files#diff-8c4ca1c70d17ea8cecc3c96d2cb899aea7dd243fb1d4b51bb9edba83033d4fd4
View file https://github.com/phillipj/github-bot/blob/06521318225e9e1f0362a0a17e524df83086b5f6/scripts/node-subsystem-label.js
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/nodejs/github-bot/pull/258/{{ revealButtonHref }}
https://github.com/nodejs/github-bot/pull/258/files#diff-8c4ca1c70d17ea8cecc3c96d2cb899aea7dd243fb1d4b51bb9edba83033d4fd4
https://github.com/nodejs/github-bot/pull/258/files#diff-8c4ca1c70d17ea8cecc3c96d2cb899aea7dd243fb1d4b51bb9edba83033d4fd4
Please reload this pagehttps://github.com/nodejs/github-bot/pull/258/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.