Skip to content

Commit f94cfc7

Browse files
author
Vatsal
committed
Merge branch 'model-armor-snippet-quickstart' of github.com:rudrakhsha-crest/nodejs-docs-samples into model-armor-snippet-quickstart
2 parents 8b1bc81 + 74265aa commit f94cfc7

38 files changed

+619
-127
lines changed

.github/config/nodejs-dev.jsonc

+6-2
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@
3636
".github/ISSUE_TEMPLATE/",
3737
".github/PULL_REQUEST_TEMPLATE.md",
3838
".github/auto-label.yaml",
39-
".github/blunderbuss.yaml",
39+
".github/blunderbuss.yml",
4040
".github/flakybot.yaml",
41-
".github/header-checker-lint.yaml",
41+
".github/header-checker-lint.yml",
4242
".github/scripts/",
4343
".github/snippet-bot.yml",
4444
".github/trusted-contribution.yml",
@@ -100,6 +100,9 @@
100100
"auth",
101101
"batch",
102102
"cloud-language",
103+
"cloud-sql/mysql/mysql",
104+
"cloud-sql/mysql/mysql2",
105+
"cloud-sql/postgres/knex",
103106
"cloud-tasks/snippets",
104107
"cloud-tasks/tutorial-gcf/app",
105108
"cloud-tasks/tutorial-gcf/function",
@@ -202,6 +205,7 @@
202205
"run/image-processing",
203206
"run/jobs",
204207
"run/logging-manual",
208+
"run/idp-sql",
205209
"run/markdown-preview/editor",
206210
"run/markdown-preview/renderer",
207211
"run/pubsub",

.github/config/nodejs-prod.jsonc renamed to .github/config/nodejs.jsonc

+2-6
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@
3636
".github/ISSUE_TEMPLATE/",
3737
".github/PULL_REQUEST_TEMPLATE.md",
3838
".github/auto-label.yaml",
39-
".github/blunderbuss.yaml",
39+
".github/blunderbuss.yml",
4040
".github/flakybot.yaml",
41-
".github/header-checker-lint.yaml",
41+
".github/header-checker-lint.yml",
4242
".github/scripts/",
4343
".github/snippet-bot.yml",
4444
".github/trusted-contribution.yml",
@@ -77,9 +77,6 @@
7777
// TODO: fix these
7878
"ai-platform/snippets", // PERMISSION_DENIED: Permission denied: Consumer 'projects/undefined' has been suspended.
7979
"automl", // (untested) FAILED_PRECONDITION: Google Cloud AutoML Natural Language was retired on March 15, 2024. Please migrate to Vertex AI instead
80-
"cloud-sql/mysql/mysql", // (untested) Error: expected 200 "OK", got 500 "Internal Server Error"
81-
"cloud-sql/mysql/mysql2", // (untested) Error: Cannot find module './connect-connector-with-iam-authn.js'
82-
"cloud-sql/postgres/knex", // (untested) CloudSQLConnectorError: Malformed instance connection name provided: expected format of "PROJECT:REGION:INSTANCE", got undefined
8380
"cloud-sql/sqlserver/mssql", // (untested) TypeError: The "config.server" property is required and must be of type string.
8481
"cloud-sql/sqlserver/tedious", // (untested) TypeError: The "config.server" property is required and must be of type string.
8582
"compute", // GoogleError: The resource 'projects/long-door-651/zones/us-central1-a/disks/disk-from-pool-name' was not found
@@ -92,7 +89,6 @@
9289
"functions/slack", // TypeError [ERR_INVALID_ARG_TYPE]: The "key" argument must be of type ... Received undefined
9390
"healthcare/fhir", // Error: Cannot find module 'whatwg-url'
9491
"iam/deny", // PERMISSION_DENIED: Permission iam.googleapis.com/denypolicies.create denied on resource cloudresourcemanager.googleapis.com/projects/long-door-651
95-
"run/idp-sql", // (untested) Error: Invalid contents in the credentials file
9692
"storagetransfer", // CredentialsError: Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1
9793
"video-intelligence", // PERMISSION_DENIED: The caller does not have permission
9894
"workflows", // SyntaxError: Cannot use import statement outside a module

.github/workflows/ai-platform-snippets.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
id: npm-cache-dir
6363
shell: bash
6464
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
65-
- uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4
65+
- uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4
6666
id: npm-cache
6767
with:
6868
path: ${{ steps.npm-cache-dir.outputs.dir }}
@@ -82,7 +82,7 @@ jobs:
8282
CAIP_PROJECT_ID: ${{ steps.secrets.outputs.caip_id }}
8383
- name: upload test results for FlakyBot workflow
8484
if: github.event.action == 'schedule' && always()
85-
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4
85+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
8686
env:
8787
MOCHA_REPORTER_OUTPUT: "${{github.run_id}}_sponge_log.xml"
8888
with:

.github/workflows/ci-scripts.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
working-directory: .github/scripts
3232
steps:
3333
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
34-
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4
34+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
3535
with:
3636
node-version: 20
3737
- run: npm install

.github/workflows/custard-ci-dev.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
name: custard CI (dev)
15+
name: Custard CI (dev)
1616
on:
1717
push:
1818
branches:
@@ -45,7 +45,7 @@ jobs:
4545
- name: Create `bin` directory for cloud-samples-tools binaries
4646
run: mkdir bin
4747
working-directory: cloud-samples-tools
48-
- uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5
48+
- uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5
4949
with:
5050
go-version: ${{ env.GO_VERSION }}
5151
- name: Build Custard (from cloud-samples-tools)
@@ -81,7 +81,7 @@ jobs:
8181
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
8282
with:
8383
ref: ${{ github.event.pull_request.head.sha }}
84-
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4
84+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
8585
with:
8686
node-version: ${{ fromJson(env.CI_SETUP).node-version }}
8787
- uses: google-github-actions/auth@6fc4af4b145ae7821d527454aa9bd537d1f2dc5f # v2

.github/workflows/custard-ci.yaml

+8-7
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
name: custard CI
15+
name: Custard CI
1616
on:
1717
push:
1818
branches:
@@ -25,6 +25,7 @@ on:
2525
env:
2626
GO_VERSION: ^1.22.0
2727

28+
# TODO: remove all jobs except region-tags (should be tested by custard-run workflows)
2829
jobs:
2930
affected:
3031
name: Finding affected tests
@@ -45,7 +46,7 @@ jobs:
4546
- name: Create `bin` directory for cloud-samples-tools binaries
4647
run: mkdir bin
4748
working-directory: cloud-samples-tools
48-
- uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5
49+
- uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5
4950
with:
5051
go-version: ${{ env.GO_VERSION }}
5152
- name: Build Custard (from cloud-samples-tools)
@@ -56,9 +57,9 @@ jobs:
5657
- name: Find Node.js affected packages
5758
id: nodejs
5859
run: |
59-
echo "paths=$(./cloud-samples-tools/bin/custard affected .github/config/nodejs-prod.jsonc diffs.txt paths.txt)" >> $GITHUB_OUTPUT
60+
echo "paths=$(./cloud-samples-tools/bin/custard affected .github/config/nodejs.jsonc diffs.txt paths.txt)" >> $GITHUB_OUTPUT
6061
cat paths.txt
61-
echo "setups=$(./cloud-samples-tools/bin/custard setup-files .github/config/nodejs-prod.jsonc paths.txt)" >> $GITHUB_OUTPUT
62+
echo "setups=$(./cloud-samples-tools/bin/custard setup-files .github/config/nodejs.jsonc paths.txt)" >> $GITHUB_OUTPUT
6263
6364
lint:
6465
needs: affected
@@ -68,7 +69,7 @@ jobs:
6869
- name: Checkout
6970
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
7071
- name: Setup Node
71-
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4
72+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
7273
with:
7374
node-version: 20
7475
- run: npm install
@@ -112,7 +113,7 @@ jobs:
112113
timeout-minutes: 5
113114
steps:
114115
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
115-
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4
116+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
116117
with:
117118
node-version: 20
118119
- run: ./.github/workflows/utils/region-tags-tests.sh
@@ -137,7 +138,7 @@ jobs:
137138
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
138139
with:
139140
ref: ${{ github.event.pull_request.head.sha }}
140-
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4
141+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
141142
with:
142143
node-version: ${{ fromJson(env.CI_SETUP).node-version }}
143144
- uses: google-github-actions/auth@6fc4af4b145ae7821d527454aa9bd537d1f2dc5f # v2
+124
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# Copyright 2024 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: (experimental / dev) Custard run
16+
17+
on:
18+
# Run tests when a pull request is created or updated.
19+
# This allows to run tests from forked repos (after reviewer's approval).
20+
workflow_run:
21+
workflows:
22+
- Custard CI # .github/workflows/custard-ci.yaml
23+
types:
24+
- in_progress
25+
26+
# Run tests again as validation when a PR merge into main.
27+
push:
28+
branches:
29+
- main
30+
31+
# To do manual runs through the Actions UI.
32+
workflow_dispatch:
33+
inputs:
34+
run-all:
35+
description: Run all tests
36+
type: boolean
37+
default: false
38+
paths:
39+
description: Comma separated packages to test
40+
type: string
41+
ref:
42+
description: Branch, tag, or commit SHA to run tests on
43+
type: string
44+
default: main
45+
46+
jobs:
47+
affected:
48+
uses: GoogleCloudPlatform/cloud-samples-tools/.github/workflows/affected.yaml@967334777b636ec212c32bf60e69b6635971b593 # v0.2.3
49+
permissions:
50+
statuses: write
51+
with:
52+
head-sha: ${{ github.event.workflow_run.head_sha || inputs.ref || github.sha }}
53+
config-file: .github/config/nodejs-dev.jsonc
54+
paths: ${{ (inputs.run-all && '.') || inputs.paths || '' }}
55+
check-name: (experimental / dev) Custard CI
56+
create-check-if: ${{ !!github.event.workflow_run }}
57+
58+
test:
59+
if: needs.affected.outputs.paths != '[]'
60+
needs: affected
61+
runs-on: ubuntu-latest
62+
timeout-minutes: 120 # 2 hours hard limit
63+
permissions:
64+
id-token: write
65+
statuses: write
66+
strategy:
67+
fail-fast: false
68+
matrix:
69+
path: ${{ needs.affected.outputs.paths }}
70+
continue-on-error: true
71+
env:
72+
GOOGLE_SAMPLES_PROJECT: long-door-651
73+
GOOGLE_SERVICE_ACCOUNT: [email protected]
74+
steps:
75+
- name: Check queued
76+
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/create-check@967334777b636ec212c32bf60e69b6635971b593 # v0.2.3
77+
id: queued
78+
with:
79+
sha: ${{ github.event.workflow_run.head_sha || inputs.ref || github.sha }}
80+
name: (experimental / dev) Custard CI / ${{ github.job }} (${{ matrix.path }})
81+
job-name: ${{ github.job }} (${{ matrix.path }})
82+
if: ${{ !!github.event.workflow_run }}
83+
- name: Setup Custard
84+
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/setup-custard@967334777b636ec212c32bf60e69b6635971b593 # v0.2.3
85+
with:
86+
path: ${{ matrix.path }}
87+
ci-setup: ${{ toJson(fromJson(needs.affected.outputs.ci-setups)[matrix.path]) }}
88+
project-id: ${{ env.GOOGLE_SAMPLES_PROJECT }}
89+
workload-identity-provider: projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider
90+
service-account: ${{ env.GOOGLE_SERVICE_ACCOUNT }}
91+
- name: Check in_progress
92+
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/update-check@967334777b636ec212c32bf60e69b6635971b593 # v0.2.3
93+
id: in_progress
94+
with:
95+
check: ${{ steps.queued.outputs.check }}
96+
status: in_progress
97+
- name: Run tests for ${{ matrix.path }}
98+
run: |
99+
timeout ${{ fromJson(needs.affected.outputs.ci-setups)[matrix.path].timeout-minutes }}m \
100+
make test dir=${{ matrix.path }}
101+
- name: Check success
102+
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/update-check@967334777b636ec212c32bf60e69b6635971b593 # v0.2.3
103+
with:
104+
check: ${{ steps.in_progress.outputs.check }}
105+
status: success
106+
- name: Check failure
107+
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/update-check@967334777b636ec212c32bf60e69b6635971b593 # v0.2.3
108+
if: failure()
109+
with:
110+
check: ${{ steps.in_progress.outputs.check }}
111+
status: failure
112+
113+
done:
114+
needs: [affected, test]
115+
if: always()
116+
runs-on: ubuntu-latest
117+
permissions:
118+
statuses: write
119+
steps:
120+
- name: Check success
121+
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/update-check@967334777b636ec212c32bf60e69b6635971b593 # v0.2.3
122+
with:
123+
check: ${{ needs.affected.outputs.check }}
124+
status: success

0 commit comments

Comments
 (0)