Skip to content

Commit bf20ab1

Browse files
mergify[bot]cdoernclaude
authored
fix(ci): generate ogx-client in-repo instead of cloning external repo (backport #6297) (#6299)
## Summary The `install-ogx-client` composite action resolved the Python client two ways that both cloned the now-retired `github.com/ogx-ai/ogx-client-python` repo: - **release branches** → `git ls-remote`/`pip install git+…/ogx-client-python@<branch>` - **`client-version: latest`** → `…@main` Now that the client SDK is generated in-repo from `client-sdks/openapi` (and `pypi.yml` already publishes `ogx-client` this way via `type: openapi-sdk`), the external repo is gone. On release branches this made **every build job fail** in the *Install dependencies* step: ``` ##[error]Branch release-1.2.x not found in ogx-client-python repository ``` ## Change For the release-branch and `latest` paths, generate the client from the current checkout instead of cloning: - Set up Java 11 + Node 20 + `@openapitools/openapi-generator-cli` (SHA-pinned actions), then run `make sdk OPEN=0` in `client-sdks/openapi` — the same toolchain `pypi.yml` already uses to build the published client. - Return the generated `client-sdks/openapi/sdks/python` path as `install-source`; the two consumers (`setup-runner`, `pre-commit.yml`) already `uv pip install --upgrade` it after `uv sync`, so they need no change. - `published` (PyPI via `uv sync`) and `sdk_install_url` paths are unchanged. TypeScript continues to use its external repo. The generation steps only run when generation is needed (guarded on a `generate` output), so `published` runs pay no extra cost. ## Test plan - `make sdk OPEN=0` verified locally to drive the generation pipeline (spec merge → hierarchy → generate). Full generation uses the pinned generator `7.19.0` via npm, matching CI. - pre-commit run on the changed files passes, including the SHA-pinned-actions check. - CI on this PR exercises the `latest` path end-to-end. Fixes the build-job failures seen on the `release-1.2.x` backport (#6293); intended to be backported to `release-1.2.x` after merge. 🤖 Generated with [Claude Code](https://claude.com/claude-code)<hr>This is an automatic backport of pull request #6297 done by [Mergify](https://mergify.com). Signed-off-by: Charlie Doern <cdoern@redhat.com> Co-authored-by: Charlie Doern <cdoern@redhat.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 0ab9550 commit bf20ab1

2 files changed

Lines changed: 48 additions & 15 deletions

File tree

.github/actions/install-ogx-client/action.yml

Lines changed: 47 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ runs:
3333
# If sdk_install_url is provided, use it directly
3434
if [ -n "${{ inputs.sdk_install_url }}" ]; then
3535
echo "Using provided sdk_install_url: ${{ inputs.sdk_install_url }}"
36+
echo "generate=false" >> $GITHUB_OUTPUT
3637
echo "install-after-sync=true" >> $GITHUB_OUTPUT
3738
echo "install-source=${{ inputs.sdk_install_url }}" >> $GITHUB_OUTPUT
3839
exit 0
@@ -51,28 +52,60 @@ runs:
5152
5253
echo "Working with branch: $BRANCH"
5354
54-
# On release branches: install client from the matching release branch in the client repo
55-
# On non-release branches: install based on client-version after sync
55+
# The ogx-client Python SDK is generated in-repo from client-sdks/openapi.
56+
# On release branches and when client-version=latest, generate the SDK from
57+
# the current checkout so tests run against the client built from this source.
58+
# When client-version=published, use the version resolved by uv sync from PyPI.
5659
if [[ "$BRANCH" =~ ^release-[0-9]+\.[0-9]+\.x$ ]]; then
57-
echo "Detected release branch: $BRANCH"
58-
59-
# Check if matching branch exists in client repo
60-
if ! git ls-remote --exit-code --heads https://github.com/ogx-ai/ogx-client-python.git "$BRANCH" > /dev/null 2>&1; then
61-
echo "::error::Branch $BRANCH not found in ogx-client-python repository"
62-
echo "::error::Please create the matching release branch in ogx-client-python before testing"
63-
exit 1
64-
fi
65-
60+
echo "Detected release branch: $BRANCH — generating client from checkout"
61+
echo "generate=true" >> $GITHUB_OUTPUT
6662
echo "install-after-sync=true" >> $GITHUB_OUTPUT
67-
echo "install-source=git+https://github.com/ogx-ai/ogx-client-python.git@$BRANCH" >> $GITHUB_OUTPUT
63+
echo "install-source=${{ github.workspace }}/client-sdks/openapi/sdks/python" >> $GITHUB_OUTPUT
6864
elif [ "${{ inputs.client-version }}" = "latest" ]; then
69-
# Install from main git after sync
65+
echo "Generating client from checkout (client-version=latest)"
66+
echo "generate=true" >> $GITHUB_OUTPUT
7067
echo "install-after-sync=true" >> $GITHUB_OUTPUT
71-
echo "install-source=git+https://github.com/ogx-ai/ogx-client-python.git@main" >> $GITHUB_OUTPUT
68+
echo "install-source=${{ github.workspace }}/client-sdks/openapi/sdks/python" >> $GITHUB_OUTPUT
7269
elif [ "${{ inputs.client-version }}" = "published" ]; then
7370
# Use published version from PyPI (installed by sync)
71+
echo "generate=false" >> $GITHUB_OUTPUT
7472
echo "install-after-sync=false" >> $GITHUB_OUTPUT
7573
elif [ -n "${{ inputs.client-version }}" ]; then
7674
echo "::error::Invalid client-version: ${{ inputs.client-version }}"
7775
exit 1
76+
else
77+
echo "generate=false" >> $GITHUB_OUTPUT
78+
fi
79+
80+
- name: Set up Java (SDK generation)
81+
if: steps.configure.outputs.generate == 'true'
82+
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
83+
with:
84+
distribution: 'temurin'
85+
java-version: '11'
86+
87+
- name: Set up Node.js (SDK generation)
88+
if: steps.configure.outputs.generate == 'true'
89+
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
90+
with:
91+
node-version: '20'
92+
93+
- name: Install openapi-generator-cli (SDK generation)
94+
if: steps.configure.outputs.generate == 'true'
95+
shell: bash
96+
run: npm install -g @openapitools/openapi-generator-cli
97+
98+
- name: Generate ogx-client SDK
99+
if: steps.configure.outputs.generate == 'true'
100+
shell: bash
101+
working-directory: client-sdks/openapi
102+
run: |
103+
echo "Generating ogx-client SDK (OPEN=0) from checkout..."
104+
make sdk OPEN=0
105+
106+
PY_FILE_COUNT=$(find sdks/python -name "*.py" | wc -l)
107+
echo "Generated Python files: $PY_FILE_COUNT"
108+
if [ "$PY_FILE_COUNT" -le 10 ]; then
109+
echo "::error::Too few Python files generated (expected > 10, got $PY_FILE_COUNT)"
110+
exit 1
78111
fi

.github/actions/setup-runner/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ inputs:
66
required: false
77
default: "3.12"
88
client-version:
9-
description: The ogx-client-python version to test against (latest or published)
9+
description: Which ogx-client to test against — 'latest' generates the SDK in-repo from client-sdks/openapi, 'published' uses the PyPI release
1010
required: false
1111
default: "latest"
1212
sdk_install_url:

0 commit comments

Comments
 (0)