Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
52 changes: 52 additions & 0 deletions .github/workflows/aml-ai.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Copyright 2024 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.

name: aml-ai
on:
push:
branches:
- main
paths:
- 'aml-ai/**'
- '.github/workflows/aml-ai.yaml'
pull_request:
types:
- opened
- reopened
- synchronize
- labeled
paths:
- 'aml-ai/**'
- '.github/workflows/aml-ai.yaml'
schedule:
- cron: '0 0 * * 0'
jobs:
test:
# Ref: https://github.com/google-github-actions/auth#usage
permissions:
contents: 'read'
id-token: 'write'
if: github.event.action != 'labeled' || github.event.label.name == 'actions:force-run'
Copy link
Contributor

Choose a reason for hiding this comment

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

low

Consider adding a comment explaining the purpose of the actions:force-run label and when it should be used.

Suggested change
if: github.event.action != 'labeled' || github.event.label.name == 'actions:force-run'
if: github.event.action != 'labeled' || github.event.label.name == 'actions:force-run' # Allows manual rerun via label

uses: ./.github/workflows/test.yaml
with:
name: 'aml-ai'
path: 'aml-ai'
flakybot:
# Ref: https://github.com/google-github-actions/auth#usage
permissions:
contents: 'read'
id-token: 'write'
if: github.event_name == 'schedule' && always() # always() submits logs even if tests fail
Copy link
Contributor

Choose a reason for hiding this comment

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

low

Consider adding a comment explaining what the always() function does in this context.

Suggested change
if: github.event_name == 'schedule' && always() # always() submits logs even if tests fail
if: github.event_name == 'schedule' && always() # Submits logs even if tests fail

uses: ./.github/workflows/flakybot.yaml
needs: [test]
1 change: 1 addition & 0 deletions .github/workflows/utils/workflows.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[
"aml-ai",
"appengine/analytics",
"appengine/building-an-app/build",
"appengine/building-an-app/update",
Expand Down
1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ vision @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/nodejs-samples-revi

# Self-service
ai-platform @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/text-embedding @GoogleCloudPlatform/cloud-samples-reviewers
aml-ai @GoogleCloudPlatform/aml-ai @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers
asset @GoogleCloudPlatform/cloud-asset-analysis-team @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers
dlp @GoogleCloudPlatform/googleapis-dlp @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers
security-center @GoogleCloudPlatform/gcp-security-command-center @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers
Expand Down
41 changes: 41 additions & 0 deletions aml-ai/listLocations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* Copyright 2024 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.
*/

'use strict';

const main = (projectId = process.env.GOOGLE_CLOUD_PROJECT) => {
// [START antimoneylaunderingai_list_locations]
// Import google-auth-library for authentication.
const {GoogleAuth} = require('google-auth-library');

const listLocations = async () => {
const auth = new GoogleAuth({
scopes: 'https://www.googleapis.com/auth/cloud-platform',
headers: {'Content-Type': 'application/json; charset=utf-8'},
});
// TODO(developer): uncomment these lines before running the sample
// const projectId = 'my-project-id';
const url = `https://financialservices.googleapis.com/v1/projects/${projectId}/locations`;
const client = await auth.getClient();
const response = await client.request({url, method: 'GET'});
console.log(JSON.stringify(response.data));
};

listLocations();
// [END antimoneylaunderingai_list_locations]
};

// node listLocations.js <projectId>
main(...process.argv.slice(2));
19 changes: 19 additions & 0 deletions aml-ai/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "nodejs-docs-samples-aml-ai",
"version": "0.0.1",
"private": true,
"license": "Apache-2.0",
"author": "Google LLC",
"repository": "GoogleCloudPlatform/nodejs-docs-samples",
"engines": {
"node": ">=12.0.0"
},
"scripts": {
"test": "c8 mocha -p -j 2 system-test/*.test.js --timeout=60000"
},
"devDependencies": {
"c8": "^10.0.0",
"google-auth-library": "^9.0.0",
"mocha": "^10.0.0"
}
}
30 changes: 30 additions & 0 deletions aml-ai/system-test/aml-ai.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* Copyright 2024 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.
*/

'use strict';

const assert = require('assert');
const path = require('path');
const cwd = path.join(__dirname, '..');
const {execSync} = require('child_process');
const {it} = require('mocha');

const projectId = process.env.GCLOUD_PROJECT;
const cloudRegion = 'us-central1';

it('should get the AML AI API locations', () => {
const output = execSync(`node listLocations.js ${projectId}`, {cwd});
assert.ok(output.includes(cloudRegion));
});