Skip to content

Commit 1d16257

Browse files
authored
Merge branch 'main' into hivanalejandro-delete-region-401222835
2 parents aba58b9 + e169459 commit 1d16257

File tree

14 files changed

+67
-32
lines changed

14 files changed

+67
-32
lines changed

.github/config/nodejs-dev.jsonc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,11 @@
146146
"functions/http/httpContent",
147147
"functions/http/httpMethods",
148148
"functions/http/parseXML",
149+
"functions/imagemagick",
149150
"functions/log/helloWorld",
150151
"functions/log/processEntry",
151152
"functions/memorystore/redis",
153+
"functions/ocr/app",
152154
"functions/pubsub/publish",
153155
"functions/pubsub/subscribe",
154156
"functions/scheduleinstance",
@@ -172,6 +174,7 @@
172174
"functions/v2/helloGCS",
173175
"functions/v2/helloPubSub",
174176
"functions/v2/httpLogging",
177+
"functions/v2/imagemagick",
175178
"functions/v2/log/processEntry",
176179
"functions/v2/ocr/app",
177180
"functions/v2/responseStreaming",

.github/config/nodejs-prod.jsonc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,7 @@
8989
"dlp", // [ERR_REQUIRE_ESM]: require() of ES Module
9090
"document-ai", // [ERR_REQUIRE_ESM]: require() of ES Module
9191
"functions/billing", // (untested) Error: Request failed with status code 500
92-
"functions/imagemagick", // (untested) Error: A bucket name is needed to use Cloud Storage
93-
"functions/ocr/app", // (untested) Error: Bucket not provided. Make sure you have a "bucket" property in your request
9492
"functions/slack", // TypeError [ERR_INVALID_ARG_TYPE]: The "key" argument must be of type ... Received undefined
95-
"functions/v2/imagemagick", // (untested) Error: A bucket name is needed to use Cloud Storage.
9693
"healthcare/fhir", // Error: Cannot find module 'whatwg-url'
9794
"iam/deny", // PERMISSION_DENIED: Permission iam.googleapis.com/denypolicies.create denied on resource cloudresourcemanager.googleapis.com/projects/long-door-651
9895
"run/idp-sql", // (untested) Error: Invalid contents in the credentials file

appengine/building-an-app/update/app.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
# See the License for the specific language governing permissions and
1212
# limitations under the License.
1313

14+
# [START gae_app_yaml]
1415
# [START app_yaml]
1516
runtime: nodejs20
1617
# [END app_yaml]
18+
# [END gae_app_yaml]

appengine/building-an-app/update/server.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
'use strict';
1616

1717
// [START gae_update_web_server_app]
18-
// [START app]
19-
// [START gae_update_app]
2018
const express = require('express');
2119
const path = require('path');
2220

@@ -31,15 +29,12 @@ app.get('/', (req, res) => {
3129
res.send('Hello from App Engine!');
3230
});
3331

34-
// [START add_display_form]
3532
// [START gae_add_display_form]
3633
app.get('/submit', (req, res) => {
3734
res.sendFile(path.join(__dirname, '/views/form.html'));
3835
});
3936
// [END gae_add_display_form]
40-
// [END add_display_form]
4137

42-
// [START add_post_handler]
4338
// [START gae_add_post_handler]
4439
app.post('/submit', (req, res) => {
4540
console.log({
@@ -49,15 +44,12 @@ app.post('/submit', (req, res) => {
4944
res.send('Thanks for your message!');
5045
});
5146
// [END gae_add_post_handler]
52-
// [END add_post_handler]
5347

5448
// Listen to the App Engine-specified port, or 8080 otherwise
5549
const PORT = parseInt(process.env.PORT) || 8080;
5650
app.listen(PORT, () => {
5751
console.log(`Server listening on port ${PORT}...`);
5852
});
59-
// [END gae_update_app]
60-
// [END app]
6153
// [END gae_update_web_server_app]
6254

6355
module.exports = app;

appengine/building-an-app/update/test/server.test.js

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,6 @@ const restoreConsole = function () {
3636
beforeEach(stubConsole);
3737
afterEach(restoreConsole);
3838

39-
describe('gae_update_app', () => {
40-
it('should send greetings', async () => {
41-
await requestObj
42-
.get('/')
43-
.expect(200)
44-
.expect(response => {
45-
assert.strictEqual(response.text, 'Hello from App Engine!');
46-
});
47-
});
48-
});
49-
5039
describe('gae_update_web_server_app', () => {
5140
it('should send greetings', async () => {
5241
await requestObj
@@ -58,7 +47,7 @@ describe('gae_update_web_server_app', () => {
5847
});
5948
});
6049

61-
describe('gae_add_display_form add_display_form', () => {
50+
describe('gae_add_display_form', () => {
6251
it('should display form', async () => {
6352
await requestObj
6453
.get('/submit')
@@ -74,7 +63,7 @@ describe('gae_add_display_form add_display_form', () => {
7463
});
7564
});
7665

77-
describe('gae_add_post_handler add_post_handler gae_enable_parser', () => {
66+
describe('gae_add_post_handler gae_enable_parser', () => {
7867
it('should record message', async () => {
7968
await requestObj
8069
.post('/submit', {

endpoints/getting-started/openapi.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# Copyright 2016 Google LLC
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
14+
# [START endpoints_swagger_yaml_nodejs]
115
# [START swagger]
216
swagger: "2.0"
317
info:
@@ -6,6 +20,7 @@ info:
620
version: "1.0.0"
721
host: "echo-api.endpoints.YOUR-PROJECT-ID.cloud.goog"
822
# [END swagger]
23+
# [END endpoints_swagger_yaml_nodejs]
924
consumes:
1025
- "application/json"
1126
produces:
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"env": {
3+
"FUNCTIONS_BUCKET": "nodejs-docs-samples-tests",
4+
"BLURRED_BUCKET_NAME": "nodejs-docs-samples-tests-imagick"
5+
}
6+
}

functions/imagemagick/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"node": ">=12.0.0"
1313
},
1414
"scripts": {
15-
"test": "c8 mocha -p -j 2 test/*.test.js --timeout=20000 --exit"
15+
"test": "c8 mocha -p -j 2 test/*.test.js --timeout=30000 --exit"
1616
},
1717
"dependencies": {
1818
"@google-cloud/storage": "^7.0.0",

functions/imagemagick/test/index.test.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
'use strict';
1616

1717
const assert = require('assert');
18-
const {spawn} = require('child_process');
18+
const {execSync, spawn} = require('child_process');
1919
const {Storage} = require('@google-cloud/storage');
2020
const sinon = require('sinon');
2121
const {request} = require('gaxios');
@@ -47,13 +47,26 @@ async function startFF(port) {
4747
let stderr = '';
4848
ffProc.stdout.on('data', data => (stdout += data));
4949
ffProc.stderr.on('data', data => (stderr += data));
50-
ffProc.on('error', reject);
51-
ffProc.on('exit', c => (c === 0 ? resolve(stdout) : reject(stderr)));
50+
ffProc.on('exit', code => {
51+
if (code === 0 || code === null) {
52+
// code === null corresponds to a signal-kill
53+
// (which doesn't necessarily indicate a test failure)
54+
resolve(stdout);
55+
} else {
56+
stderr = `Error code: ${code}\n${stderr}`;
57+
reject(new Error(stderr));
58+
}
59+
});
5260
});
5361
await waitPort({host: 'localhost', port});
5462
return {ffProc, ffProcHandler};
5563
}
5664

65+
// ImageMagick is available by default in Cloud Run Functions environments
66+
// https://cloud.google.com/functions/1stgendocs/tutorials/imagemagick-1st-gen.md#importing_dependencies
67+
// Manually install it for testing only.
68+
execSync('sudo apt-get install imagemagick -y');
69+
5770
describe('functions/imagemagick tests', () => {
5871
before(async () => {
5972
let exists;

functions/ocr/app/ci-setup.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"env": {
3+
"FUNCTIONS_BUCKET": "nodejs-docs-samples-tests",
4+
"RESULT_BUCKET": "nodejs-docs-samples-tests",
5+
"TRANSLATE_TOPIC": "integration-tests-instance",
6+
"RESULT_TOPIC": "integration-tests-instance",
7+
"TO_LANG": "en,es"
8+
}
9+
}

0 commit comments

Comments
 (0)