Skip to content

Commit 87a468c

Browse files
committed
Add workflow for updating stubs
1 parent 41b013d commit 87a468c

2 files changed

Lines changed: 61 additions & 3 deletions

File tree

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Create updated stubs PR
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '0 0 * * 0' # every Sunday at midnight
7+
8+
jobs:
9+
create_pr:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
pull-requests: write
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Setup Python
18+
uses: actions/setup-python@v5
19+
20+
- name: Install uv
21+
uses: astral-sh/setup-uv@v2
22+
with:
23+
enable-cache: true
24+
25+
- name: Install dependencies
26+
run: uv sync
27+
28+
- name: Update stubs
29+
run: uv run python create_stubs.py
30+
31+
- name: Detect changes
32+
id: changes
33+
run: |
34+
if git diff --quiet; then
35+
echo "has_changes=false" >> "$GITHUB_OUTPUT"
36+
else
37+
echo "has_changes=true" >> "$GITHUB_OUTPUT"
38+
fi
39+
40+
- name: Bump minor version in pyproject.toml
41+
if: steps.changes.outputs.has_changes == 'true'
42+
run: uv version --bump minor
43+
44+
- name: Create pull request
45+
if: steps.changes.outputs.has_changes == 'true'
46+
uses: peter-evans/create-pull-request@v6
47+
with:
48+
commit-message: Update stubs
49+
author: henribru <6639509+henribru@users.noreply.github.com>
50+
committer: henribru <6639509+henribru@users.noreply.github.com>
51+
branch: create-updated-stubs-pr
52+
delete-branch: true
53+
title: Update stubs
54+
body: Update stubs
55+
56+

create_stubs.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,13 @@
22
import json
33
import keyword
44
import os
5-
import re
65
import shutil
76
import subprocess
87
import textwrap
98
from contextlib import contextmanager
109
from pathlib import Path
1110
from typing import Any, DefaultDict, Dict, List, Set
1211

13-
from mypy.api import run
14-
1512
from googleapiclient.discovery import fix_method_name, key2param
1613

1714

@@ -397,6 +394,11 @@ def copytree(src, dst, symlinks=False, ignore=None, overwrite=True):
397394

398395

399396
def main():
397+
subprocess.run(["uv", "remove", "google-api-python-client"])
398+
subprocess.run(["uv", "add", "google-api-python-client"])
399+
subprocess.run(["git", "clone", "https://github.com/googleapis/google-api-python-client.git"]);
400+
subprocess.run(["git", "restore", "."], cwd="google-api-python-client")
401+
subprocess.run(["git", "pull"], cwd="google-api-python-client")
400402
shutil.rmtree("apiclient-stubs", ignore_errors=True)
401403
apis = []
402404
ignored_apis = [

0 commit comments

Comments
 (0)