Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/config/nodejs-dev.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion .github/config/nodejs.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions ai-platform/snippets/ci-setup.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"timeout-minutes": 20,
"secrets": {
"CAIP_PROJECT_ID": "nodejs-docs-samples-tests/nodejs-docs-samples-ai-platform-caip-project-id"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This new ci-setup.json is a key part of resolving the permission issues for ai-platform/snippets. To ensure this configuration is effective, could you clarify the format and resolution mechanism for the secret path "nodejs-docs-samples-tests/nodejs-docs-samples-ai-platform-caip-project-id"?

Specifically:

  • How does the CI system interpret this string to fetch the secret? For instance, is nodejs-docs-samples-tests the GCP project ID where the secret is stored, and nodejs-docs-samples-ai-platform-caip-project-id the name of the secret itself?
  • Is this a standard convention within your CI, or if it's intended as a direct path, how does it align with typical Google Cloud Secret Manager path formats (e.g., projects/PROJECT_ID/secrets/SECRET_NAME/versions/latest)?

Confirming this will help ensure the CAIP_PROJECT_ID is correctly supplied to the tests. A brief note in the PR description or a comment in the file about this convention could also be beneficial for future maintainers.

}
}
14 changes: 7 additions & 7 deletions ai-platform/snippets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}

10 changes: 5 additions & 5 deletions ai-platform/snippets/test/batch-prediction-gemini.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Check failure on line 19 in ai-platform/snippets/test/batch-prediction-gemini.test.js

View workflow job for this annotation

GitHub Actions / lint

Replace `·assert·` with `assert`
import { after, describe, it } from 'mocha';

Check failure on line 20 in ai-platform/snippets/test/batch-prediction-gemini.test.js

View workflow job for this annotation

GitHub Actions / lint

Replace `·after,·describe,·it·` with `after,·describe,·it`
import { execSync as _execSync } from 'child_process';

Check failure on line 21 in ai-platform/snippets/test/batch-prediction-gemini.test.js

View workflow job for this annotation

GitHub Actions / lint

Replace `·execSync·as·_execSync·` with `execSync·as·_execSync`
import { JobServiceClient } from '@google-cloud/aiplatform';

Check failure on line 22 in ai-platform/snippets/test/batch-prediction-gemini.test.js

View workflow job for this annotation

GitHub Actions / lint

Replace `·JobServiceClient·` with `JobServiceClient`

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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Check failure on line 19 in ai-platform/snippets/test/create-batch-prediction-job-text-classification.test.js

View workflow job for this annotation

GitHub Actions / lint

Replace `·assert·` with `assert`
import { after, describe, it } from 'mocha';

Check failure on line 20 in ai-platform/snippets/test/create-batch-prediction-job-text-classification.test.js

View workflow job for this annotation

GitHub Actions / lint

Replace `·after,·describe,·it·` with `after,·describe,·it`
import { v4 as uuid } from 'uuid';

Check failure on line 21 in ai-platform/snippets/test/create-batch-prediction-job-text-classification.test.js

View workflow job for this annotation

GitHub Actions / lint

Replace `·v4·as·uuid·` with `v4·as·uuid`
import { execSync as _execSync } from 'child_process';

Check failure on line 22 in ai-platform/snippets/test/create-batch-prediction-job-text-classification.test.js

View workflow job for this annotation

GitHub Actions / lint

Replace `·execSync·as·_execSync·` with `execSync·as·_execSync`
const execSync = cmd => _execSync(cmd, {encoding: 'utf-8'});

const aiplatform = require('@google-cloud/aiplatform');
import { v1 } from '@google-cloud/aiplatform';

Check failure on line 25 in ai-platform/snippets/test/create-batch-prediction-job-text-classification.test.js

View workflow job for this annotation

GitHub Actions / lint

Replace `·v1·` with `v1`
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';
Expand Down
Loading