Skip to content

Commit 94caba0

Browse files
refactor: fold ruby fix into build, streamline update-bindings workflow
- Call scripts/fix-ruby-escaping.sh from bindings/ruby/build.sh so a single ./scripts/build.sh always emits valid Ruby; drop the now-redundant call from update-bindings.sh - Workflow: use uv + prek instead of setup-python + pre-commit, run the linter once (ruff --fix is single-pass), and only bump the version and open a PR when the regenerated bindings actually differ Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 4784a86 commit 94caba0

3 files changed

Lines changed: 28 additions & 35 deletions

File tree

.github/workflows/update-bindings.yml

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,29 @@ jobs:
2727
with:
2828
ruby-version: "3.4"
2929

30-
- name: Set up Python
31-
uses: actions/setup-python@v5
32-
with:
33-
python-version: "3.12"
30+
- name: Set up uv
31+
uses: astral-sh/setup-uv@v5
3432

35-
- name: Install pre-commit
36-
run: pip install pre-commit
33+
- name: Generate bindings
34+
run: ./scripts/build.sh
3735

38-
- name: Determine versions
36+
- name: Apply lint autofixes
37+
# ruff --fix applies every fixable issue in a single pass; a non-zero exit
38+
# only signals that it modified files, which is expected and desired.
39+
run: uvx prek run --all-files || true
40+
41+
- name: Detect changes
42+
id: detect
43+
run: |
44+
if [ -n "${{ inputs.version }}" ] || [ -n "$(git status --porcelain)" ]; then
45+
echo "changed=true" >> "$GITHUB_OUTPUT"
46+
else
47+
echo "changed=false" >> "$GITHUB_OUTPUT"
48+
echo "Bindings already match the current API; no PR needed."
49+
fi
50+
51+
- name: Bump version and regenerate
52+
if: steps.detect.outputs.changed == 'true'
3953
id: versions
4054
run: |
4155
api_version=$(curl -s --max-time 30 "https://api.cloudsmith.io/status/check/basic/" | jq -r '.version')
@@ -53,30 +67,15 @@ jobs:
5367
new_version="${major}.${minor}.$((patch + 1))"
5468
fi
5569
70+
sed -i -E "s/^package_version=.*/package_version=\"${new_version}\"/" scripts/common.sh
71+
./scripts/build.sh
72+
uvx prek run --all-files || true
73+
5674
echo "api_version=$api_version" >> "$GITHUB_OUTPUT"
5775
echo "new_version=$new_version" >> "$GITHUB_OUTPUT"
5876
59-
- name: Bump package_version
60-
run: |
61-
sed -i -E 's/^package_version=.*/package_version="${{ steps.versions.outputs.new_version }}"/' scripts/common.sh
62-
63-
- name: Generate bindings
64-
run: ./scripts/build.sh
65-
66-
- name: Fix Ruby apostrophe escaping
67-
run: ./scripts/fix-ruby-escaping.sh
68-
69-
- name: Run pre-commit to convergence
70-
run: |
71-
for attempt in 1 2 3 4 5; do
72-
if pre-commit run --all-files; then
73-
exit 0
74-
fi
75-
done
76-
echo "pre-commit hooks did not converge after 5 attempts" >&2
77-
exit 1
78-
7977
- name: Create pull request
78+
if: steps.detect.outputs.changed == 'true'
8079
uses: peter-evans/create-pull-request@v7
8180
with:
8281
branch: automated/update-bindings-v${{ steps.versions.outputs.new_version }}

bindings/ruby/build.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,5 @@ docker container run --rm -v $self_dir:/local "${swagger_codegen_cli_image:?}" g
3838
-o /local/src \
3939
-t /local/templates \
4040
$common_codegen_options
41+
42+
$root_dir/scripts/fix-ruby-escaping.sh

scripts/update-bindings.sh

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,6 @@ generate_bindings() {
142142
log_error "Failed to generate bindings"
143143
exit 1
144144
fi
145-
146-
log_info "Fixing Ruby apostrophe escaping..."
147-
if ./scripts/fix-ruby-escaping.sh; then
148-
log_success "Ruby apostrophe escaping fixed"
149-
else
150-
log_error "Failed to fix Ruby apostrophe escaping"
151-
exit 1
152-
fi
153145
}
154146

155147
run_precommit_to_convergence() {

0 commit comments

Comments
 (0)