Skip to content

Commit d52f48e

Browse files
committed
ci: update Python runtime to 3.14 in GHA workflow
1 parent b0089df commit d52f48e

8 files changed

Lines changed: 98 additions & 69 deletions

File tree

‎.github/workflows/main.yml‎

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,16 @@ name: A workflow for updating discovery artifacts
1616
# Controls when the action will run.
1717

1818
on:
19+
pull_request:
1920
schedule:
2021
# * is a special character in YAML so you have to quote this string
2122
# Run this Github Action every Tuesday at 7 AM UTC
2223
- cron: '0 7 * * 2'
2324
workflow_dispatch:
2425

26+
permissions:
27+
contents: read
28+
2529
jobs:
2630
build:
2731
name: Update Discovery Artifacts PR
@@ -40,24 +44,35 @@ jobs:
4044
GITHUB_TOKEN: ${{ secrets.YOSHI_CODE_BOT_TOKEN }}
4145

4246
- name: Check out main branch
43-
uses: actions/checkout@v4
47+
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
4448
with:
4549
ref: refs/heads/main
4650
repository: 'yoshi-code-bot/google-api-python-client'
4751
token: ${{secrets.YOSHI_CODE_BOT_TOKEN}}
52+
persist-credentials: false
53+
fetch-depth: 0
4854

4955
- name: Create branch
5056
run: |
51-
git checkout -b update-discovery-artifacts-${{ steps.date.outputs.current_date }}
57+
git checkout -b update-discovery-artifacts-${STEPS_DATE_OUTPUTS_CURRENT_DATE}
58+
env:
59+
STEPS_DATE_OUTPUTS_CURRENT_DATE: ${{ steps.date.outputs.current_date }}
5260

53-
- name: Set up Python 3.9
54-
uses: actions/setup-python@v5
61+
- name: Set up Python 3.14
62+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
5563
with:
56-
python-version: 3.9
64+
python-version: 3.14
5765

5866
- name: Install google-api-python-client
5967
run: pip3 install -e .
6068

69+
# Checkout requirements.txt from the PR branch on the main repository
70+
- name: Checkout requirements.txt from PR branch
71+
if: github.event_name == 'pull_request'
72+
run: |
73+
git fetch https://github.com/googleapis/google-api-python-client.git refs/pull/${{ github.event.pull_request.number }}/head:pr-branch
74+
git checkout pr-branch -- scripts/
75+
6176
- name: Install script dependencies
6277
run: pip3 install -r requirements.txt
6378
working-directory: ./scripts
@@ -78,7 +93,9 @@ jobs:
7893
working-directory: ./scripts
7994

8095
- name: Push changes
81-
run: git push -u origin update-discovery-artifacts-${{ steps.date.outputs.current_date }}
96+
run: git push -u origin update-discovery-artifacts-${STEPS_DATE_OUTPUTS_CURRENT_DATE}
97+
env:
98+
STEPS_DATE_OUTPUTS_CURRENT_DATE: ${{ steps.date.outputs.current_date }}
8299

83100
- name: Prepare summary for PR Body
84101
id: pr_body
@@ -96,5 +113,6 @@ jobs:
96113
env:
97114
GITHUB_TOKEN: ${{ secrets.YOSHI_CODE_BOT_TOKEN }}
98115
PR_TITLE: "chore: Update discovery artifacts"
116+
STEPS_PR_BODY_OUTPUTS_CHANGE_SUMMARY: ${{ steps.pr_body.outputs.change_summary }}
99117
run: |
100-
gh pr create -R "googleapis/google-api-python-client" -B "main" --title "$PR_TITLE" --body "${{ steps.pr_body.outputs.change_summary }}"
118+
gh pr create -R "googleapis/google-api-python-client" -B "main" --title "$PR_TITLE" --body "${STEPS_PR_BODY_OUTPUTS_CHANGE_SUMMARY}"

‎googleapiclient/discovery.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ def __init__(self):
142142
# Library-specific reserved words beyond Python keywords.
143143
RESERVED_WORDS = frozenset(["body"])
144144

145+
145146
# patch _write_lines to avoid munging '\r' into '\n'
146147
# ( https://bugs.python.org/issue18886 https://bugs.python.org/issue19003 )
147148
class _BytesGenerator(BytesGenerator):
@@ -1325,7 +1326,7 @@ def method(self, **kwargs):
13251326
enumDesc = paramdesc.get("enumDescriptions", [])
13261327
if enum and enumDesc:
13271328
docs.append(" Allowed values\n")
1328-
for (name, desc) in zip(enum, enumDesc):
1329+
for name, desc in zip(enum, enumDesc):
13291330
docs.append(" %s - %s\n" % (name, desc))
13301331
if "response" in methodDesc:
13311332
if methodName.endswith("_media"):

‎googleapiclient/mimeparse.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def fitness_and_quality_parsed(mime_type, parsed_ranges):
9595
best_fitness = -1
9696
best_fit_q = 0
9797
(target_type, target_subtype, target_params) = parse_media_range(mime_type)
98-
for (type, subtype, params) in parsed_ranges:
98+
for type, subtype, params in parsed_ranges:
9999
type_match = type == target_type or type == "*" or target_type == "*"
100100
subtype_match = (
101101
subtype == target_subtype or subtype == "*" or target_subtype == "*"

‎noxfile.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import nox
1919

20-
BLACK_VERSION = "black==22.3.0"
20+
BLACK_VERSION = "black==23.7.0"
2121
ISORT_VERSION = "isort==5.10.1"
2222
BLACK_PATHS = [
2323
"apiclient",
@@ -31,7 +31,7 @@
3131
"setup.py",
3232
]
3333

34-
DEFAULT_PYTHON_VERSION = "3.10"
34+
DEFAULT_PYTHON_VERSION = "3.14"
3535

3636
test_dependencies = [
3737
"django>=2.0.0",

‎samples/compute/requirements.txt‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
google-api-python-client==2.134.0
2-
google-auth==2.30.0
3-
google-auth-httplib2==0.2.0
1+
google-api-python-client==2.199.0
2+
google-auth==2.57.0
3+
google-auth-httplib2==0.4.2

‎scripts/requirements.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pandas==2.2.2
1+
pandas==3.0.5

‎scripts/updatediscoveryartifacts.py‎

Lines changed: 63 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -29,56 +29,66 @@
2929
REFERENCE_DOC_DIR = SCRIPTS_DIR / ".." / "docs" / "dyn"
3030
TEMP_DIR = SCRIPTS_DIR / "temp"
3131

32-
# Clear discovery documents and reference documents directory
33-
shutil.rmtree(DISCOVERY_DOC_DIR, ignore_errors=True)
34-
shutil.rmtree(REFERENCE_DOC_DIR, ignore_errors=True)
35-
36-
# Clear temporary directory
37-
shutil.rmtree(TEMP_DIR, ignore_errors=True)
38-
39-
# Check out a fresh copy
40-
subprocess.call(["git", "checkout", DISCOVERY_DOC_DIR])
41-
subprocess.call(["git", "checkout", REFERENCE_DOC_DIR])
42-
43-
# Snapshot current discovery artifacts to a temporary directory
44-
with tempfile.TemporaryDirectory() as current_discovery_doc_dir:
45-
shutil.copytree(DISCOVERY_DOC_DIR, current_discovery_doc_dir, dirs_exist_ok=True)
46-
47-
# Download discovery artifacts and generate documentation
48-
describe.generate_all_api_documents(
49-
doc_destination_dir=REFERENCE_DOC_DIR,
50-
artifact_destination_dir=DISCOVERY_DOC_DIR,
51-
)
52-
53-
# Get a list of files changed using `git diff`
54-
git_diff_output = subprocess.check_output(
55-
[
56-
"git",
57-
"diff",
58-
"origin/main",
59-
"--name-only",
60-
"--",
61-
DISCOVERY_DOC_DIR / "*.json",
62-
REFERENCE_DOC_DIR / "*.html",
63-
REFERENCE_DOC_DIR / "*.md",
64-
],
65-
universal_newlines=True,
66-
)
67-
68-
# Create lists of the changed files
69-
all_changed_files = [
70-
pathlib.Path(file_name).name for file_name in git_diff_output.split("\n")
71-
]
72-
json_changed_files = [file for file in all_changed_files if file.endswith(".json")]
73-
74-
# Create temporary directory
75-
pathlib.Path(TEMP_DIR).mkdir()
76-
77-
# Analyze the changes in discovery artifacts using the changesummary module
78-
changesummary.ChangeSummary(
79-
DISCOVERY_DOC_DIR, current_discovery_doc_dir, TEMP_DIR, json_changed_files
80-
).detect_discovery_changes()
81-
82-
# Write a list of the files changed to a file called `changed files` which will be used in the `createcommits.sh` script.
83-
with open(TEMP_DIR / "changed_files", "w") as f:
84-
f.writelines("\n".join(all_changed_files))
32+
33+
def main():
34+
# Clear discovery documents and reference documents directory
35+
shutil.rmtree(DISCOVERY_DOC_DIR, ignore_errors=True)
36+
shutil.rmtree(REFERENCE_DOC_DIR, ignore_errors=True)
37+
38+
# Clear temporary directory
39+
shutil.rmtree(TEMP_DIR, ignore_errors=True)
40+
41+
# Check out a fresh copy
42+
subprocess.call(["git", "checkout", DISCOVERY_DOC_DIR])
43+
subprocess.call(["git", "checkout", REFERENCE_DOC_DIR])
44+
45+
# Snapshot current discovery artifacts to a temporary directory
46+
with tempfile.TemporaryDirectory() as current_discovery_doc_dir:
47+
shutil.copytree(
48+
DISCOVERY_DOC_DIR, current_discovery_doc_dir, dirs_exist_ok=True
49+
)
50+
51+
# Download discovery artifacts and generate documentation
52+
describe.generate_all_api_documents(
53+
doc_destination_dir=REFERENCE_DOC_DIR,
54+
artifact_destination_dir=DISCOVERY_DOC_DIR,
55+
)
56+
57+
# Get a list of files changed using `git diff`
58+
git_diff_output = subprocess.check_output(
59+
[
60+
"git",
61+
"diff",
62+
"origin/main",
63+
"--name-only",
64+
"--",
65+
DISCOVERY_DOC_DIR / "*.json",
66+
REFERENCE_DOC_DIR / "*.html",
67+
REFERENCE_DOC_DIR / "*.md",
68+
],
69+
universal_newlines=True,
70+
)
71+
72+
# Create lists of the changed files
73+
all_changed_files = [
74+
pathlib.Path(file_name).name for file_name in git_diff_output.split("\n")
75+
]
76+
json_changed_files = [
77+
file for file in all_changed_files if file.endswith(".json")
78+
]
79+
80+
# Create temporary directory
81+
pathlib.Path(TEMP_DIR).mkdir()
82+
83+
# Analyze the changes in discovery artifacts using the changesummary module
84+
changesummary.ChangeSummary(
85+
DISCOVERY_DOC_DIR, current_discovery_doc_dir, TEMP_DIR, json_changed_files
86+
).detect_discovery_changes()
87+
88+
# Write a list of the files changed to a file called `changed files` which will be used in the `createcommits.sh` script.
89+
with open(TEMP_DIR / "changed_files", "w") as f:
90+
f.writelines("\n".join(all_changed_files))
91+
92+
93+
if __name__ == "__main__":
94+
main()

‎tests/test_model.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464

6565
class TestPatch(unittest.TestCase):
6666
def test_patch(self):
67-
for (msg, orig, mod, expected_patch) in TEST_CASES:
67+
for msg, orig, mod, expected_patch in TEST_CASES:
6868
self.assertEqual(expected_patch, makepatch(orig, mod), msg=msg)
6969

7070

0 commit comments

Comments
 (0)