diff --git a/.github/config/nodejs-dev.jsonc b/.github/config/nodejs-dev.jsonc index c8ca78b18b..6275022fd2 100644 --- a/.github/config/nodejs-dev.jsonc +++ b/.github/config/nodejs-dev.jsonc @@ -77,6 +77,7 @@ "recaptcha_enterprise/demosite/app", // no tests exist // These tests are already passing in prod, so skip them in dev. + "ai-platform/snippets", "appengine/building-an-app/build", "appengine/building-an-app/update", "appengine/datastore", diff --git a/.github/config/nodejs.jsonc b/.github/config/nodejs.jsonc index b8bc67ffcb..be4a9cde3b 100644 --- a/.github/config/nodejs.jsonc +++ b/.github/config/nodejs.jsonc @@ -75,7 +75,6 @@ "recaptcha_enterprise/demosite/app", // no tests exist // TODO: fix these - "ai-platform/snippets", // PERMISSION_DENIED: Permission denied: Consumer 'projects/undefined' has been suspended. "automl", // (untested) FAILED_PRECONDITION: Google Cloud AutoML Natural Language was retired on March 15, 2024. Please migrate to Vertex AI instead "cloud-sql/sqlserver/tedious", // (untested) TypeError: The "config.server" property is required and must be of type string. "compute", // GoogleError: The resource 'projects/long-door-651/zones/us-central1-a/disks/disk-from-pool-name' was not found diff --git a/.github/workflows/custard-ci.yaml b/.github/workflows/custard-ci.yaml index a63e570c33..4ff2a20886 100644 --- a/.github/workflows/custard-ci.yaml +++ b/.github/workflows/custard-ci.yaml @@ -145,7 +145,7 @@ jobs: ref: ${{ github.event.pull_request.head.sha }} - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 with: - node-version: ${{ fromJson(env.CI_SETUP).node-version }} + node-version: 16 - uses: google-github-actions/auth@6fc4af4b145ae7821d527454aa9bd537d1f2dc5f # v2 id: auth with: diff --git a/.github/workflows/custard-run.yaml b/.github/workflows/custard-run.yaml index c5fc5c94d2..90230e0198 100644 --- a/.github/workflows/custard-run.yaml +++ b/.github/workflows/custard-run.yaml @@ -82,7 +82,7 @@ jobs: - name: Setup Node uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 with: - node-version: 20 + node-version: 16 - run: npm install - name: npx gtx lint (${{ needs.affected.outputs.num-paths }} packages) uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/map-run@9ee708234e240605d96e78f652c333ed6aa95a23 # v0.3.2 diff --git a/ai-platform/snippets/ci-setup.json b/ai-platform/snippets/ci-setup.json new file mode 100644 index 0000000000..b1a85518cc --- /dev/null +++ b/ai-platform/snippets/ci-setup.json @@ -0,0 +1,6 @@ +{ + "timeout-minutes": 20, + "secrets": { + "CAIP_PROJECT_ID": "nodejs-docs-samples-tests/nodejs-docs-samples-ai-platform-caip-project-id" + } +} diff --git a/ai-platform/snippets/package.json b/ai-platform/snippets/package.json index 4d7ad0964f..3c8d2d47c0 100644 --- a/ai-platform/snippets/package.json +++ b/ai-platform/snippets/package.json @@ -10,19 +10,19 @@ "*.js" ], "scripts": { - "test": "c8 mocha -p -j 2 --timeout 2400000 test/*.js" + "test": "c8 mocha -p -j 2 --timeout 2400000 test/*.js --reporter list" }, "dependencies": { - "@google-cloud/aiplatform": "^3.0.0", - "@google-cloud/bigquery": "^7.0.0", + "@google-cloud/aiplatform": "^4.0.0", + "@google-cloud/bigquery": "^8.0.0", "@google-cloud/storage": "^7.0.0" }, "devDependencies": { "c8": "^10.0.0", - "chai": "^4.5.0", - "mocha": "^10.0.0", - "uuid": "^10.0.0", - "sinon": "^18.0.0" + "chai": "^5.0.0", + "mocha": "^11.0.0", + "uuid": "^11.0.0", + "sinon": "^20.0.0" } } diff --git a/ai-platform/snippets/test/batch-prediction-gemini.test.js b/ai-platform/snippets/test/batch-prediction-gemini.test.js index 87d58dd618..721c085da9 100644 --- a/ai-platform/snippets/test/batch-prediction-gemini.test.js +++ b/ai-platform/snippets/test/batch-prediction-gemini.test.js @@ -16,12 +16,12 @@ 'use strict'; -const {assert} = require('chai'); -const {after, describe, it} = require('mocha'); -const cp = require('child_process'); -const {JobServiceClient} = require('@google-cloud/aiplatform'); +import { assert } from 'chai'; +import { after, describe, it } from 'mocha'; +import { execSync as _execSync } from 'child_process'; +import { JobServiceClient } from '@google-cloud/aiplatform'; -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); +const execSync = cmd => _execSync(cmd, {encoding: 'utf-8'}); describe('Batch predict with Gemini', async () => { const projectId = process.env.CAIP_PROJECT_ID; diff --git a/ai-platform/snippets/test/create-batch-prediction-job-text-classification.test.js b/ai-platform/snippets/test/create-batch-prediction-job-text-classification.test.js index ac285ad4c4..91c9d1a3f6 100644 --- a/ai-platform/snippets/test/create-batch-prediction-job-text-classification.test.js +++ b/ai-platform/snippets/test/create-batch-prediction-job-text-classification.test.js @@ -16,18 +16,18 @@ 'use strict'; -const {assert} = require('chai'); -const {after, describe, it} = require('mocha'); -const uuid = require('uuid').v4; -const cp = require('child_process'); -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); +import { assert } from 'chai'; +import { after, describe, it } from 'mocha'; +import { v4 as uuid } from 'uuid'; +import { execSync as _execSync } from 'child_process'; +const execSync = cmd => _execSync(cmd, {encoding: 'utf-8'}); -const aiplatform = require('@google-cloud/aiplatform'); +import { v1 } from '@google-cloud/aiplatform'; const clientOptions = { apiEndpoint: 'us-central1-aiplatform.googleapis.com', }; -const jobServiceClient = new aiplatform.v1.JobServiceClient(clientOptions); +const jobServiceClient = new v1.JobServiceClient(clientOptions); const batchPredictionDisplayName = `temp_create_batch_prediction_text_classification_test${uuid()}`; const modelId = '7827432074230366208';