Skip to content

chore(ci): migrate ai-platform/snippets via Node 16 #4103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion .github/workflows/custard-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/custard-run.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
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"
}
}
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