Skip to content

Commit 3352cac

Browse files
committed
Sync repo
1 parent 34f3a4f commit 3352cac

File tree

125 files changed

+25155
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+25155
-0
lines changed

.github/CODEOWNERS

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Code owners file.
2+
# This file controls who is tagged for review for any given pull request.
3+
#
4+
# For syntax help see:
5+
# https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners#codeowners-syntax
6+
7+
# Prefer GitHub teams over individuals to make it easier to find a suitable owner
8+
# when someone is OOO or leaves the team.
9+
10+
* @GoogleCloudPlatform/teams/generative-ai-devrel

.github/renovate.json5

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
{
2+
"extends": [
3+
"config:recommended"
4+
],
5+
"prConcurrentLimit": 0,
6+
"rebaseWhen": "never",
7+
"dependencyDashboard": true,
8+
"pip_requirements": {
9+
"fileMatch": [
10+
"requirements.txt",
11+
"requirements-test.txt",
12+
"requirements-composer.txt",
13+
"constraints.txt",
14+
"constraints-test.txt"
15+
]
16+
},
17+
"ignorePaths": [
18+
"**/target/**"
19+
],
20+
"packageRules": [
21+
{
22+
"matchDatasources": ["maven"],
23+
"matchFilePatterns": ["pom.xml"],
24+
"groupName": "Java Maven Dependencies"
25+
},
26+
{
27+
"matchDatasources": ["pypi"],
28+
"matchFilePatterns": ["requirements.txt"],
29+
"groupName": "Python pip Dependencies"
30+
},
31+
{
32+
"separateMinorPatch": true,
33+
"matchPackageNames": [
34+
"/pytest/"
35+
]
36+
},
37+
{
38+
"matchUpdateTypes": [
39+
"minor"
40+
],
41+
"extends": [
42+
"schedule:monthly"
43+
]
44+
},
45+
{
46+
"matchUpdateTypes": [
47+
"patch"
48+
],
49+
"extends": [
50+
"schedule:quarterly"
51+
]
52+
},
53+
{
54+
"matchDatasources": ["maven"],
55+
"matchUpdateTypes": ["minor"],
56+
"groupName": "Java Minor Updates",
57+
"extends": ["schedule:monthly"]
58+
},
59+
{
60+
"matchDatasources": ["maven"],
61+
"matchUpdateTypes": ["patch"],
62+
"groupName": "Java Patch Updates",
63+
"extends": ["schedule:quarterly"]
64+
}
65+
],
66+
"vulnerabilityAlerts": {
67+
"schedule": [
68+
"at any time"
69+
]
70+
},
71+
"platformAutomerge": true,
72+
"automergeType": "branch"
73+
}

.github/workflows/python-lint.yaml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Copyright 2025 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: Python Lint
16+
17+
on:
18+
push:
19+
branches:
20+
- main
21+
paths:
22+
- "samples/python/**"
23+
- ".github/workflows/python-lint.yaml"
24+
pull_request:
25+
types:
26+
- opened
27+
- reopened
28+
- synchronize
29+
paths:
30+
- "samples/python/**"
31+
- ".github/workflows/python-lint.yaml"
32+
schedule:
33+
- cron: "0 0 * * 0"
34+
35+
jobs:
36+
get_sample_dirs:
37+
runs-on: ubuntu-latest
38+
outputs:
39+
sample_dirs: ${{ steps.get_dirs.outputs.sample_dirs }}
40+
steps:
41+
- uses: actions/checkout@v4
42+
with:
43+
ref: ${{ github.event.pull_request.head.sha }}
44+
45+
- name: Get Sample Directories
46+
id: get_dirs
47+
run: |
48+
SAMPLE_DIRS=$(find samples/python/ -type d -maxdepth 5 ! -path "samples/python" | jq -R -s 'split("\n")[:-1]' )
49+
echo "sample_dirs=$SAMPLE_DIRS" >> $GITHUB_OUTPUT
50+
echo "SAMPLE_DIRS: $SAMPLE_DIRS" # For debugging
51+
52+
lint:
53+
runs-on: ubuntu-latest
54+
strategy:
55+
matrix:
56+
python-version: ["3.10", "3.11", "3.12"]
57+
sample_dir: ${{ fromJson(needs.get_sample_dirs.outputs.sample_dirs) }}
58+
fail-fast: false
59+
60+
needs:
61+
- get_sample_dirs
62+
63+
steps:
64+
- uses: actions/checkout@v4
65+
with:
66+
ref: ${{ github.event.pull_request.head.sha }}
67+
68+
- name: Set up Python ${{ matrix.python-version }}
69+
uses: actions/setup-python@v4
70+
with:
71+
python-version: ${{ matrix.python-version }}
72+
cache: "pip"
73+
74+
- name: Install dependencies
75+
run: |
76+
python -m pip install --upgrade pip
77+
pip install black flake8
78+
79+
- name: Run Black and Flake8 Linting in ${{ matrix.sample_dir }}
80+
run: |
81+
cd ${{ matrix.sample_dir }}
82+
black .
83+
flake8 .

.github/workflows/python-tests.yaml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# Copyright 2025 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: Python Tests
16+
17+
on:
18+
push:
19+
branches:
20+
- main
21+
paths:
22+
- "samples/python/**"
23+
- ".github/workflows/python-tests.yaml"
24+
pull_request:
25+
types:
26+
- opened
27+
- reopened
28+
- synchronize
29+
paths:
30+
- "samples/python/**"
31+
- ".github/workflows/python-tests.yaml"
32+
schedule:
33+
- cron: "0 0 * * 0"
34+
35+
jobs:
36+
build:
37+
runs-on: ubuntu-latest
38+
strategy:
39+
matrix:
40+
python-version: ["3.10", "3.11", "3.12"]
41+
sample_dir: ${{ fromJson(needs.get_sample_dirs.outputs.sample_dirs) }}
42+
fail-fast: false # Important: Don't stop if one matrix configuration fails
43+
44+
needs:
45+
- get_sample_dirs
46+
47+
steps:
48+
- uses: actions/checkout@v4
49+
with:
50+
ref: ${{ github.event.pull_request.head.sha }}
51+
52+
- name: Get Sample Directories
53+
id: get_sample_dirs
54+
run: |
55+
SAMPLE_DIRS=$( find $PYTHON_DIR -type d -not -path "*/.venv*" -exec test -e '{}'/requirements.txt \; -print )
56+
echo "sample_dirs=$SAMPLE_DIRS" >> $GITHUB_OUTPUT
57+
echo "SAMPLE_DIRS: $SAMPLE_DIRS" # For debugging
58+
59+
- name: Set up Python ${{ matrix.python-version }}
60+
uses: actions/setup-python@v4
61+
with:
62+
python-version: ${{ matrix.python-version }}
63+
cache: "pip"
64+
65+
- name: Install dependencies
66+
run: |
67+
python -m pip install --upgrade pip
68+
pip install pytest coverage
69+
pip install -r ${{ matrix.sample_dir }}/requirements.txt
70+
pip install -r ${{ matrix.sample_dir }}/requirements-test.txt
71+
72+
- name: Run pytest in ${{ matrix.sample_dir }}
73+
run: |
74+
cd ${{ matrix.sample_dir }}
75+
pytest | tee pytest.txt
76+
77+
- name: Show failed tests and overall summary
78+
run: |
79+
grep -E "FAILED tests|ERROR tests|[0-9]+ passed," pytest.txt
80+
failed_count=$(grep -E "FAILED tests|ERROR tests" pytest.txt | wc -l | tr -d '[:space:]')
81+
if [[ $failed_count -gt 0 ]]; then
82+
echo "$failed_count failed lines found! Task failed."
83+
exit 1
84+
fi
85+
86+
- name: Upload pytest test results
87+
uses: actions/upload-artifact@v3
88+
with:
89+
name: pytest-results-${{ matrix.python-version }}-${{ matrix.sample_dir }}
90+
path: |
91+
pytest.txt
92+
./htmlcov/
93+
retention-days: 30
94+
if: ${{ always() }}

0 commit comments

Comments
 (0)