Skip to content

Commit a26c42c

Browse files
authored
Merge branch 'main' into ssc-management-api-sha-samples
2 parents 3f0dbe9 + be25b32 commit a26c42c

File tree

11 files changed

+65
-11
lines changed

11 files changed

+65
-11
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

CODEOWNERS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ service-directory @GoogleCloudPlatform/dee-infra @GoogleCloudPlatform/nodejs-sam
2828
tpu @GoogleCloudPlatform/dee-infra @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers
2929
webrisk @GoogleCloudPlatform/dee-infra @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers
3030

31-
# SoDa teams
31+
# SDK teams
3232
cloud-sql @GoogleCloudPlatform/cloud-sql-connectors @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers
3333
datastore @GoogleCloudPlatform/cloud-native-db-dpes @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers
34-
storagetransfer @GoogleCloudPlatform/cloud-storage-dpes @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers
34+
storagetransfer @GoogleCloudPlatform/gcs-sdk-team @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers
3535

3636
# One-offs
3737
composer @GoogleCloudPlatform/cloud-dpes-composer @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers

endpoints/getting-started/openapi-appengine.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# Copyright 2017 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_appengine_yaml_nodejs]
115
# [START swagger]
216
swagger: "2.0"
317
info:
@@ -6,6 +20,7 @@ info:
620
version: "1.0.0"
721
host: "YOUR-PROJECT-ID.appspot.com"
822
# [END swagger]
23+
# [END endpoints_swagger_appengine_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+
}

functions/ocr/app/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ const translate = new Translate();
4141
const publishResult = async (topicName, data) => {
4242
const dataBuffer = Buffer.from(JSON.stringify(data));
4343

44-
const [topic] = await pubsub.topic(topicName).get({autoCreate: true});
45-
topic.publishMessage({data: dataBuffer});
44+
pubsub.topic(topicName).publishMessage(dataBuffer);
4645
};
4746

4847
// [START functions_ocr_detect]
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+
}

0 commit comments

Comments
 (0)