Skip to content

Commit

Permalink
Merge branch 'main' into ssc-management-api-sha-samples
Browse files Browse the repository at this point in the history
  • Loading branch information
glasnt authored Mar 10, 2025
2 parents 3f0dbe9 + be25b32 commit a26c42c
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .github/config/nodejs-dev.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,11 @@
"functions/http/httpContent",
"functions/http/httpMethods",
"functions/http/parseXML",
"functions/imagemagick",
"functions/log/helloWorld",
"functions/log/processEntry",
"functions/memorystore/redis",
"functions/ocr/app",
"functions/pubsub/publish",
"functions/pubsub/subscribe",
"functions/scheduleinstance",
Expand All @@ -172,6 +174,7 @@
"functions/v2/helloGCS",
"functions/v2/helloPubSub",
"functions/v2/httpLogging",
"functions/v2/imagemagick",
"functions/v2/log/processEntry",
"functions/v2/ocr/app",
"functions/v2/responseStreaming",
Expand Down
3 changes: 0 additions & 3 deletions .github/config/nodejs-prod.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,7 @@
"dlp", // [ERR_REQUIRE_ESM]: require() of ES Module
"document-ai", // [ERR_REQUIRE_ESM]: require() of ES Module
"functions/billing", // (untested) Error: Request failed with status code 500
"functions/imagemagick", // (untested) Error: A bucket name is needed to use Cloud Storage
"functions/ocr/app", // (untested) Error: Bucket not provided. Make sure you have a "bucket" property in your request
"functions/slack", // TypeError [ERR_INVALID_ARG_TYPE]: The "key" argument must be of type ... Received undefined
"functions/v2/imagemagick", // (untested) Error: A bucket name is needed to use Cloud Storage.
"healthcare/fhir", // Error: Cannot find module 'whatwg-url'
"iam/deny", // PERMISSION_DENIED: Permission iam.googleapis.com/denypolicies.create denied on resource cloudresourcemanager.googleapis.com/projects/long-door-651
"run/idp-sql", // (untested) Error: Invalid contents in the credentials file
Expand Down
4 changes: 2 additions & 2 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ service-directory @GoogleCloudPlatform/dee-infra @GoogleCloudPlatform/nodejs-sam
tpu @GoogleCloudPlatform/dee-infra @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers
webrisk @GoogleCloudPlatform/dee-infra @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers

# SoDa teams
# SDK teams
cloud-sql @GoogleCloudPlatform/cloud-sql-connectors @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers
datastore @GoogleCloudPlatform/cloud-native-db-dpes @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers
storagetransfer @GoogleCloudPlatform/cloud-storage-dpes @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers
storagetransfer @GoogleCloudPlatform/gcs-sdk-team @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers

# One-offs
composer @GoogleCloudPlatform/cloud-dpes-composer @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers
Expand Down
15 changes: 15 additions & 0 deletions endpoints/getting-started/openapi-appengine.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2017 Google LLC
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# [START endpoints_swagger_appengine_yaml_nodejs]
# [START swagger]
swagger: "2.0"
info:
Expand All @@ -6,6 +20,7 @@ info:
version: "1.0.0"
host: "YOUR-PROJECT-ID.appspot.com"
# [END swagger]
# [END endpoints_swagger_appengine_yaml_nodejs]
consumes:
- "application/json"
produces:
Expand Down
6 changes: 6 additions & 0 deletions functions/imagemagick/ci-setup.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"env": {
"FUNCTIONS_BUCKET": "nodejs-docs-samples-tests",
"BLURRED_BUCKET_NAME": "nodejs-docs-samples-tests-imagick"
}
}
2 changes: 1 addition & 1 deletion functions/imagemagick/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"node": ">=12.0.0"
},
"scripts": {
"test": "c8 mocha -p -j 2 test/*.test.js --timeout=20000 --exit"
"test": "c8 mocha -p -j 2 test/*.test.js --timeout=30000 --exit"
},
"dependencies": {
"@google-cloud/storage": "^7.0.0",
Expand Down
19 changes: 16 additions & 3 deletions functions/imagemagick/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
'use strict';

const assert = require('assert');
const {spawn} = require('child_process');
const {execSync, spawn} = require('child_process');
const {Storage} = require('@google-cloud/storage');
const sinon = require('sinon');
const {request} = require('gaxios');
Expand Down Expand Up @@ -47,13 +47,26 @@ async function startFF(port) {
let stderr = '';
ffProc.stdout.on('data', data => (stdout += data));
ffProc.stderr.on('data', data => (stderr += data));
ffProc.on('error', reject);
ffProc.on('exit', c => (c === 0 ? resolve(stdout) : reject(stderr)));
ffProc.on('exit', code => {
if (code === 0 || code === null) {
// code === null corresponds to a signal-kill
// (which doesn't necessarily indicate a test failure)
resolve(stdout);
} else {
stderr = `Error code: ${code}\n${stderr}`;
reject(new Error(stderr));
}
});
});
await waitPort({host: 'localhost', port});
return {ffProc, ffProcHandler};
}

// ImageMagick is available by default in Cloud Run Functions environments
// https://cloud.google.com/functions/1stgendocs/tutorials/imagemagick-1st-gen.md#importing_dependencies
// Manually install it for testing only.
execSync('sudo apt-get install imagemagick -y');

describe('functions/imagemagick tests', () => {
before(async () => {
let exists;
Expand Down
9 changes: 9 additions & 0 deletions functions/ocr/app/ci-setup.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"env": {
"FUNCTIONS_BUCKET": "nodejs-docs-samples-tests",
"RESULT_BUCKET": "nodejs-docs-samples-tests",
"TRANSLATE_TOPIC": "integration-tests-instance",
"RESULT_TOPIC": "integration-tests-instance",
"TO_LANG": "en,es"
}
}
3 changes: 1 addition & 2 deletions functions/ocr/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ const translate = new Translate();
const publishResult = async (topicName, data) => {
const dataBuffer = Buffer.from(JSON.stringify(data));

const [topic] = await pubsub.topic(topicName).get({autoCreate: true});
topic.publishMessage({data: dataBuffer});
pubsub.topic(topicName).publishMessage(dataBuffer);
};

// [START functions_ocr_detect]
Expand Down
6 changes: 6 additions & 0 deletions functions/v2/imagemagick/ci-setup.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"env": {
"FUNCTIONS_BUCKET": "nodejs-docs-samples-tests",
"BLURRED_BUCKET_NAME": "nodejs-docs-samples-tests-imagick"
}
}
6 changes: 6 additions & 0 deletions functions/v2/imagemagick/test/integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
'use strict';

const assert = require('assert');
const {execSync} = require('child_process');
const {Storage} = require('@google-cloud/storage');
const sinon = require('sinon');
const supertest = require('supertest');
Expand All @@ -33,6 +34,11 @@ const testFiles = {

require('../index');

// ImageMagick is available by default in Cloud Run Functions environments
// https://cloud.google.com/functions/1stgendocs/tutorials/imagemagick-1st-gen.md#importing_dependencies
// Manually install it for testing only.
execSync('sudo apt-get install imagemagick -y');

describe('functions/imagemagick tests', () => {
before(async () => {
let exists;
Expand Down

0 comments on commit a26c42c

Please sign in to comment.