From 180d393a58fcd0ba466f3c9cb5c58c1350c0cc4c Mon Sep 17 00:00:00 2001 From: Katie McLaughlin Date: Tue, 4 Mar 2025 13:49:54 +1100 Subject: [PATCH 1/5] ci(ocr): migrate to new CI --- .github/config/nodejs-dev.jsonc | 1 + .github/config/nodejs-prod.jsonc | 1 - functions/ocr/app/ci-setup.json | 6 ++++++ 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 functions/ocr/app/ci-setup.json diff --git a/.github/config/nodejs-dev.jsonc b/.github/config/nodejs-dev.jsonc index 088934266a..a3da913bb4 100644 --- a/.github/config/nodejs-dev.jsonc +++ b/.github/config/nodejs-dev.jsonc @@ -149,6 +149,7 @@ "functions/log/helloWorld", "functions/log/processEntry", "functions/memorystore/redis", + "functions/ocr/app", "functions/pubsub/publish", "functions/pubsub/subscribe", "functions/scheduleinstance", diff --git a/.github/config/nodejs-prod.jsonc b/.github/config/nodejs-prod.jsonc index bee3b1d2ed..4fa780309a 100644 --- a/.github/config/nodejs-prod.jsonc +++ b/.github/config/nodejs-prod.jsonc @@ -90,7 +90,6 @@ "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' diff --git a/functions/ocr/app/ci-setup.json b/functions/ocr/app/ci-setup.json new file mode 100644 index 0000000000..e50394aa44 --- /dev/null +++ b/functions/ocr/app/ci-setup.json @@ -0,0 +1,6 @@ +{ + "env": { + "FUNCTIONS_BUCKET": "$PROJECT_ID", + "RESULTS_BUCKET": "$PROJECT_ID" + } +} From 3f5f76fe89d9c6379a1cebdc8b7db4f10f7afb8f Mon Sep 17 00:00:00 2001 From: Katie McLaughlin Date: Tue, 4 Mar 2025 13:55:51 +1100 Subject: [PATCH 2/5] add additional envvars --- functions/ocr/app/ci-setup.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/functions/ocr/app/ci-setup.json b/functions/ocr/app/ci-setup.json index e50394aa44..355e4b6578 100644 --- a/functions/ocr/app/ci-setup.json +++ b/functions/ocr/app/ci-setup.json @@ -1,6 +1,9 @@ { "env": { "FUNCTIONS_BUCKET": "$PROJECT_ID", - "RESULTS_BUCKET": "$PROJECT_ID" + "RESULTS_BUCKET": "$PROJECT_ID", + "TRANSLATE_TOPIC": "integration-tests-instance", + "RESULT_TOPIC": "integration-tests-instance", + "TO_LANG": "en,es" } } From abff0a37fdbc82bf03a9d1323a8477fcc37e1d71 Mon Sep 17 00:00:00 2001 From: Katie McLaughlin Date: Tue, 4 Mar 2025 14:16:35 +1100 Subject: [PATCH 3/5] spelling --- functions/ocr/app/ci-setup.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/ocr/app/ci-setup.json b/functions/ocr/app/ci-setup.json index 355e4b6578..bfc24c7980 100644 --- a/functions/ocr/app/ci-setup.json +++ b/functions/ocr/app/ci-setup.json @@ -1,7 +1,7 @@ { "env": { "FUNCTIONS_BUCKET": "$PROJECT_ID", - "RESULTS_BUCKET": "$PROJECT_ID", + "RESULT_BUCKET": "$PROJECT_ID", "TRANSLATE_TOPIC": "integration-tests-instance", "RESULT_TOPIC": "integration-tests-instance", "TO_LANG": "en,es" From 1065a97c687b9d894ed84b0d6865d224f1852254 Mon Sep 17 00:00:00 2001 From: Katie McLaughlin Date: Thu, 6 Mar 2025 16:52:57 +1100 Subject: [PATCH 4/5] be explicit about bucket --- functions/ocr/app/ci-setup.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/ocr/app/ci-setup.json b/functions/ocr/app/ci-setup.json index bfc24c7980..5c3b62165e 100644 --- a/functions/ocr/app/ci-setup.json +++ b/functions/ocr/app/ci-setup.json @@ -1,7 +1,7 @@ { "env": { - "FUNCTIONS_BUCKET": "$PROJECT_ID", - "RESULT_BUCKET": "$PROJECT_ID", + "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" From afaa8117d5c600b3ad67f0842b3425efa28e90d0 Mon Sep 17 00:00:00 2001 From: Katie McLaughlin Date: Thu, 6 Mar 2025 16:53:08 +1100 Subject: [PATCH 5/5] debug: don't auto-create topic (MAY NEED REVERT) --- functions/ocr/app/index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/functions/ocr/app/index.js b/functions/ocr/app/index.js index 6c8430f53c..1c87d9b88a 100644 --- a/functions/ocr/app/index.js +++ b/functions/ocr/app/index.js @@ -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]