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

Migrate Sample: Cloud Run as Pub/Sub Push Handler #1419

Merged
merged 18 commits into from
Jul 31, 2019
Merged

Migrate Sample: Cloud Run as Pub/Sub Push Handler #1419

merged 18 commits into from
Jul 31, 2019

Conversation

grayside
Copy link
Collaborator

This sample has been previously reviewed in previous source control. Changes include updating dependencies and switching from ava to mocha.

This sample is currently in use in http://cloud.google.com/run/docs/tutorials/pubsub

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jul 17, 2019
@grayside grayside requested review from ace-n and fhinkel July 17, 2019 20:37
@grayside
Copy link
Collaborator Author

The test output from this sample is currently impacted by GoogleCloudPlatform/nodejs-repo-tools#214

Copy link
Contributor

@ace-n ace-n left a comment

Choose a reason for hiding this comment

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

LGTM other than a nit or two. 🙂

// license that can be found in the LICENSE file.

// [START run_pubsub_server_setup]

Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: extra space in region tag area?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah, go standards transference. Fixing.

app.post('/', (req, res) => {
if (!req.body) {
const msg = 'no Pub/Sub message received';
console.error(`error: ${msg}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: in an ideal world, lines 19-20 wouldn't be repeated in the clause below (lines 26-27) - but I don't think there's a good way to avoid this repetition here. 🙁

const uuid = require('uuid');

const cwd = path.join(__dirname, '../');
const requestObj = tools.getRequest({cwd});
Copy link
Contributor

Choose a reason for hiding this comment

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

@fhinkel this uses nodejs-repo-tools - I assume that's OK for this sample, since it's not a simple hello-world?

Copy link
Contributor

Choose a reason for hiding this comment

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

We're trying to remove the usage of repo-tools. Can you use request or fetch instead of tools.getRequest?

Copy link
Contributor

Choose a reason for hiding this comment

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

You can have a look at the appengine Hello World example, we use supertest for this kind of testing. Since we're not running e2e tests there's no need to install repo-tools. But not blocking, I'll work on removing repo-tools from the samples anyways.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Switched to sinon and supertest.

Copy link
Contributor

@fhinkel fhinkel left a comment

Choose a reason for hiding this comment

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

Please don't commit package-lock.json. Otherwise LGTM

@grayside
Copy link
Collaborator Author

@fhinkel why not commit package-lock.json? Without that the builds are not deterministic and I need to switch the Dockerfile back to npm install instead of following the guidance on https://nodejs.org/de/docs/guides/nodejs-docker-webapp/ to steer a production-centric build to use npm ci.

@grayside
Copy link
Collaborator Author

Not sure why the test is failing. The build log indicates it should be passing

@fhinkel
Copy link
Contributor

fhinkel commented Jul 26, 2019

In production you need package-lock.json. But for samples, I prefer no lock file. If there are breaking changes in the dependencies, our tests should catch that and we can fix it. If we rely on specific versions, we end up with very old dependencies.

Lock files other cause merge conflicts and I see to benefit checking them in for samples.

If we decide to change this, we should do it consistently for all samples and not just this one.

@grayside grayside removed the request for review from SurferJeffAtGoogle July 29, 2019 17:45
@fhinkel
Copy link
Contributor

fhinkel commented Jul 29, 2019

Failing tests see #1435

@grayside
Copy link
Collaborator Author

Tests passed

@grayside
Copy link
Collaborator Author

@fhinkel looks like I've addressed all current concerns, could you approve or clarify remaining issues?

@fhinkel fhinkel added the kokoro:run Add this label to force Kokoro to re-run the tests. label Jul 31, 2019
@kokoro-team kokoro-team removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Jul 31, 2019
@fhinkel
Copy link
Contributor

fhinkel commented Jul 31, 2019

@grayside internal CI (run/logging-manual) is still failing. It passed on a docs change I landed a minute ago. Did this PR break that test again?

@fhinkel
Copy link
Contributor

fhinkel commented Jul 31, 2019

Landing and making run/pubsub a mandatory test 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants