Skip to content

Commit 4854f7e

Browse files
authored
Merge branch 'main' into feat/centralize-mypy-handwritten
2 parents 8dd9661 + 0d2d40d commit 4854f7e

609 files changed

Lines changed: 124977 additions & 38850 deletions

File tree

Some content is hidden

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

.github/release-please.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
handleGHRelease: true
2+
manifest: true
3+
tagPullRequestNumber: true
4+
5+
branches:
6+
- branch: main
7+
handleGHRelease: true
8+
tagPullRequestNumber: true
9+
manifest: true
10+
manifestFile: .release-please-bulk-manifest.json
11+
manifestConfig: release-please-bulk-config.json
12+
- branch: main
13+
handleGHRelease: true
14+
tagPullRequestNumber: true
15+
manifest: true
16+
manifestFile: .release-please-individual-manifest.json
17+
manifestConfig: release-please-individual-config.json

.github/workflows/librarian_config_check.yml

Lines changed: 0 additions & 43 deletions
This file was deleted.

.github/workflows/unittest.yml

Lines changed: 87 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
python -m pip install nox
3737
- name: Run unit tests
3838
env:
39-
COVERAGE_FILE: .coverage-${{ matrix.python }}
39+
COVERAGE_FILE: ${{ github.workspace }}/.coverage-${{ matrix.python }}
4040
BUILD_TYPE: presubmit
4141
TARGET_BRANCH: ${{ github.base_ref || github.event.merge_group.base_ref }}
4242
TEST_TYPE: unit
@@ -46,8 +46,9 @@ jobs:
4646
- name: Upload coverage results
4747
uses: actions/upload-artifact@v4
4848
with:
49-
name: coverage-artifact-${{ '{{' }} matrix.python {{ '}}' }}
49+
name: coverage-artifact-${{ matrix.python }}
5050
path: .coverage-${{ matrix.python }}
51+
include-hidden-files: true
5152

5253
cover:
5354
runs-on: ubuntu-latest
@@ -67,20 +68,97 @@ jobs:
6768
python-version: "3.10"
6869
- name: Set number of files changes in packages directory
6970
id: packages
70-
run: echo "::set-output name=num_files_changed::$(git diff HEAD~1 -- packages | wc -l)"
71+
run: |
72+
git diff HEAD~1 -- packages > /dev/null
73+
num_files_changed=$(git diff HEAD~1 -- packages | wc -l | tr -d ' ')
74+
echo "num_files_changed=${num_files_changed}" >> "$GITHUB_OUTPUT"
7175
- name: Install coverage
72-
if: steps.packages.num_files_changed > 0
76+
if: ${{ steps.packages.outputs.num_files_changed > 0 }}
7377
run: |
7478
python -m pip install --upgrade setuptools pip wheel
7579
python -m pip install coverage
7680
- name: Download coverage results
77-
if: ${{ steps.date.packages.num_files_changed > 0 }}
81+
if: ${{ steps.packages.outputs.num_files_changed > 0 }}
7882
uses: actions/download-artifact@v4
7983
with:
8084
path: .coverage-results/
8185
- name: Report coverage results
82-
if: ${{ steps.date.packages.num_files_changed > 0 }}
86+
if: ${{ steps.packages.outputs.num_files_changed > 0 }}
87+
env:
88+
# TODO: default to 100% coverage after next gapic-generator release
89+
# https://github.com/googleapis/google-cloud-python/issues/17459
90+
DEFAULT_FAIL_UNDER: 99
8391
run: |
84-
find .coverage-results -type f -name '*.zip' -exec unzip {} \;
85-
coverage combine .coverage-results/**/.coverage*
86-
coverage report --show-missing --fail-under=100
92+
if [ -d .coverage-results ]; then
93+
# Unzip any zipped coverage results
94+
find .coverage-results -type f -name '*.zip' -exec unzip -o {} \;
95+
96+
# Find all coverage files and combine them.
97+
# We find files starting with .coverage (excluding .coveragerc files and templates)
98+
coverage_files=$(find .coverage-results . -type f -name '.coverage*' ! -name '.coveragerc*')
99+
if [ -n "${coverage_files}" ]; then
100+
coverage combine ${coverage_files}
101+
else
102+
echo "Error: No coverage files found to combine."
103+
exit 1
104+
fi
105+
106+
# Find all modified packages
107+
modified_packages=$(git diff --name-only HEAD~1 -- packages | cut -d/ -f1,2 | sort -u)
108+
109+
failed_packages=()
110+
passed_packages=()
111+
112+
for pkg in ${modified_packages}; do
113+
if [ -d "${pkg}" ]; then
114+
echo "============================================================"
115+
echo "Evaluating coverage for package: ${pkg}"
116+
echo "============================================================"
117+
118+
set +e
119+
if [ -f "${pkg}/.coveragerc" ]; then
120+
echo "Using package-specific configuration: ${pkg}/.coveragerc"
121+
# If fail_under is specified in the package-specific .coveragerc, coverage report
122+
# will automatically enforce it. Otherwise, we enforce the default.
123+
if grep -q "fail_under" "${pkg}/.coveragerc"; then
124+
coverage report --rcfile="${pkg}/.coveragerc" --include="${pkg}/**"
125+
else
126+
echo "No fail_under specified in ${pkg}/.coveragerc, enforcing default"
127+
coverage report --rcfile="${pkg}/.coveragerc" --include="${pkg}/**" --fail-under="${DEFAULT_FAIL_UNDER}"
128+
fi
129+
else
130+
echo "No .coveragerc found for ${pkg}, enforcing default"
131+
coverage report --include="${pkg}/**" --fail-under="${DEFAULT_FAIL_UNDER}"
132+
fi
133+
status=$?
134+
set -e
135+
136+
if [ ${status} -ne 0 ]; then
137+
failed_packages+=("${pkg}")
138+
else
139+
passed_packages+=("${pkg}")
140+
fi
141+
fi
142+
done
143+
144+
echo "============================================================"
145+
echo "Coverage Evaluation Summary"
146+
echo "============================================================"
147+
if [ ${#passed_packages[@]} -gt 0 ]; then
148+
echo "Passed packages:"
149+
for pkg in "${passed_packages[@]}"; do
150+
echo " - ${pkg}"
151+
done
152+
fi
153+
if [ ${#failed_packages[@]} -gt 0 ]; then
154+
echo "Failed packages:"
155+
for pkg in "${failed_packages[@]}"; do
156+
echo " - ${pkg}"
157+
done
158+
exit 1
159+
fi
160+
else
161+
echo "Error: No coverage results were downloaded from the unit test jobs."
162+
echo "This usually means the unit tests did not run or failed to upload their coverage files."
163+
exit 1
164+
fi
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Version Scan
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- '**version-scanner**'
8+
schedule:
9+
- cron: '0 * * * *' # Run hourly at the top of the hour
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: read
14+
issues: write
15+
16+
jobs:
17+
scan:
18+
name: Version Scan
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v6
22+
23+
- name: Set up Python
24+
uses: actions/setup-python@v6
25+
with:
26+
python-version: '3.14'
27+
28+
- name: Install dependencies
29+
run: |
30+
python -m pip install --upgrade pip
31+
pip install pyyaml
32+
33+
- name: Run Version Scanner
34+
run: |
35+
# Uses -o to output a detailed, raw CSV to a file
36+
# Uses --stdout to print a slim, easier to parse summary to the GitHub Actions UI
37+
# Uses --soft-fail to temporarily limit causing CI/CD failures during the migration to full operation.
38+
python scripts/version_scanner/version_scanner.py -d python -v 3.7 --stdout -o version_scanner_output.csv --soft-fail
39+
40+
- name: Upload CSV Results
41+
if: always()
42+
uses: actions/upload-artifact@v7
43+
with:
44+
name: version-scanner-results
45+
path: version_scanner_output.csv
46+
47+
- name: Create or update issue on finding
48+
if: failure()
49+
env:
50+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
run: |
52+
TITLE="Version Scanner found deprecated dependencies"
53+
RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
54+
55+
# Read the first 50 lines to prevent blowing up the issue body if it's massive
56+
CSV_PREVIEW=$(head -n 50 version_scanner_output.csv)
57+
58+
BODY="The [Version Scanner]($RUN_URL) found deprecated dependencies in the repository.
59+
60+
**Matches Found:**
61+
\`\`\`csv
62+
$CSV_PREVIEW
63+
\`\`\`
64+
*(If there are more than 50 matches, see the workflow logs for the full list)*"
65+
66+
# Mirroring regenerate-all.yml: check if an issue already exists to prevent spam
67+
EXISTING_ISSUE=$(gh issue list --state open --search "in:title \"$TITLE\"" --json number --jq '.[0].number')
68+
69+
if [ -z "$EXISTING_ISSUE" ]; then
70+
echo "WOULD HAVE CREATED ISSUE:"
71+
echo "gh issue create --title \"$TITLE\" --body \"$BODY\""
72+
# gh issue create --title "$TITLE" --body "$BODY"
73+
else
74+
echo "Issue #$EXISTING_ISSUE already exists."
75+
echo "WOULD HAVE ADDED COMMENT:"
76+
echo "gh issue comment \"$EXISTING_ISSUE\" --body \"Another scanner run found deprecated dependencies: $RUN_URL\""
77+
# gh issue comment "$EXISTING_ISSUE" --body "Another scanner run found deprecated dependencies: $RUN_URL"
78+
fi

.librarian/config.yaml

Lines changed: 0 additions & 45 deletions
This file was deleted.

.librarian/generator-input/client-post-processing/datastore-integration.yaml

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -39,42 +39,6 @@ replacements:
3939
"google-cloud-core >= 2.0.0, <3.0.0",
4040
"grpcio >= 1.59.0, < 2.0.0",
4141
count: 1
42-
- paths: [
43-
"packages/google-cloud-datastore/mypy.ini",
44-
]
45-
before: |-
46-
# Performance: reuse results from previous runs to speed up 'nox'
47-
incremental = True
48-
after: |-
49-
# Performance: reuse results from previous runs to speed up "nox"
50-
incremental = True
51-
52-
[mypy-google.cloud.datastore._app_engine_key_pb2]
53-
ignore_errors = True
54-
55-
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2410):
56-
# Remove once this generator bug is fixed
57-
[mypy-google.cloud.datastore_v1.services.datastore.async_client]
58-
ignore_errors = True
59-
60-
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2410):
61-
# Remove once this generator bug is fixed
62-
[mypy-google.cloud.datastore_v1.services.datastore.client]
63-
ignore_errors = True
64-
count: 1
65-
- paths: [
66-
"packages/google-cloud-datastore/mypy.ini",
67-
]
68-
before: |
69-
ignore_missing_imports = False
70-
71-
# TODO\(https://github.com/googleapis/gapic-generator-python/issues/2563\):
72-
# Dependencies that historically lacks py.typed markers
73-
\[mypy-google\.iam\.\*\]
74-
ignore_missing_imports = True
75-
after: |
76-
ignore_missing_imports = True
77-
count: 1
7842
- paths: [
7943
"packages/google-cloud-datastore/docs/index.rst",
8044
]

0 commit comments

Comments
 (0)