Skip to content

Commit 4d64ebc

Browse files
authored
ci: pre-populate synthtool cache to avoid race condition (#17230)
This PR resolves a blocking parallel generation issue on GitHub Actions and updates Spanner's post-processing config to align with recent template updates. ### 1. Fix GHA parallel generation race condition When running `librarian generate --all` in GHA, multiple libraries are generated in parallel. They concurrently invoke `synthtool`, which races to clone/update the templates repository (`googleapis/synthtool`) in the shared cache directory `~/.cache/synthtool/synthtool`. This results in either: * A **clone race**: One process starts cloning, and others see the half-created directory, assume it's valid, and fail with `fatal: failed to resolve HEAD as a valid ref` when running `git branch`. * An **update race**: Multiple processes try to run `git checkout` / `git pull` concurrently, failing with `fatal: Unable to create ... index.lock: File exists`. **Fix**: We now clone `googleapis/synthtool` once sequentially at the beginning of the workflow (`Clone Synthtool Templates`), and configure `SYNTHTOOL_TEMPLATES` environment variable globally to point to this local directory. This completely bypasses all concurrent git clone/pull operations during parallel generation, resolving the race conditions and speeding up the build. ### 2. Fix Spanner post-processing AssertionError We removed the obsolete `Supported Python Versions` replacement block from `.librarian/generator-input/client-post-processing/spanner-integration.yaml`. **Why it was needed**: * On **May 19, 2026** (commit `2408166fec`), Python 3.7-3.9 support was dropped specifically for Spanner. Because the `synthtool` templates still generated `Python >= 3.9` in `README.rst` by default, a post-processing workaround was added to force it to `3.10`. * On **May 21, 2026** (commit `e643ce8` in `googleapis/synthtool`), `synthtool` templates were updated globally to drop Python 3.9 support for all mono-repo libraries. * As a result, the freshly generated `README.rst` for Spanner now already defaults to `Python >= 3.10`. The May 19 workaround became obsolete and failed with `AssertionError: Replaced 0 rather than 1 instances` because the "before" pattern (expecting `3.9`) no longer exists. TAG=agy CONV=acb0ee9b-3d87-4b9e-b3c6-0d4aa3efbd35
1 parent 357c62e commit 4d64ebc

2 files changed

Lines changed: 5 additions & 31 deletions

File tree

.github/workflows/regenerate-all.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ jobs:
1414
runs-on: ubuntu-latest
1515
env:
1616
PANDOC_VERSION: 3.8.2
17+
SYNTHTOOL_TEMPLATES: /home/runner/synthtool/synthtool/gcp/templates
1718

1819
steps:
1920
- name: Checkout
@@ -41,6 +42,10 @@ jobs:
4142
version=$(sed -n 's/^version: *//p' librarian.yaml)
4243
go run "github.com/googleapis/librarian/cmd/librarian@${version}" install
4344
45+
- name: Clone Synthtool Templates
46+
run: |
47+
git clone --recurse-submodules --single-branch https://github.com/googleapis/synthtool.git /home/runner/synthtool
48+
4449
- name: Regenerate
4550
run: |
4651
version=$(sed -n 's/^version: *//p' librarian.yaml)

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

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -607,38 +607,7 @@ replacements:
607607
Next Steps
608608
count: 1
609609

610-
- paths: [
611-
packages/google-cloud-spanner/README.rst
612-
]
613-
before: |
614-
Supported Python Versions
615-
\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^
616-
Our client libraries are compatible with all current `active`_ and `maintenance`_ versions of
617-
Python\.
618-
619-
Python >= 3\.9, including 3\.14
620-
621-
\.\. _active: https://devguide\.python\.org/devcycle/#in-development-main-branch
622-
\.\. _maintenance: https://devguide\.python\.org/devcycle/#maintenance-branches
623610

624-
Unsupported Python Versions
625-
\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^
626-
Python <= 3\.8
627-
after: |
628-
Supported Python Versions
629-
^^^^^^^^^^^^^^^^^^^^^^^^^
630-
Our client libraries are compatible with all current `active`_ and `maintenance`_ versions of
631-
Python.
632-
633-
Python >= 3.10, including 3.14
634-
635-
.. _active: https://devguide.python.org/devcycle/#in-development-main-branch
636-
.. _maintenance: https://devguide.python.org/devcycle/#maintenance-branches
637-
638-
Unsupported Python Versions
639-
^^^^^^^^^^^^^^^^^^^^^^^^^^^
640-
Python <= 3.9
641-
count: 1
642611

643612
# Note: noxfile.py is heavily customized so we clobber the whole file.
644613
- paths: [

0 commit comments

Comments
 (0)