Skip to content

Commit 0862ab0

Browse files
authored
Require pre-commit for inferred backports (#7355)
# Description Require inference-resolved release backports to pass the repository pre-commit suite before the workflow can commit the resolution or open a draft PR. The resolver prompt now calls out the pre-commit requirement. If hooks make automatic fixes, the workflow stages only paths from the original source PR, revalidates the candidate scope, and runs pre-commit again. Any remaining failure stops the backport without creating a PR. ## Type of change - Bug fix (non-breaking change which fixes an issue) ## Release backport - [ ] <!-- backport-active-release --> Backport this pull request to the active release branch after it merges into `develop` Not applicable for this default-branch PR; a matching `develop` PR carries the change to the active release branch. ## Validation - `uv run isaaclab -f` - Parsed the workflow YAML - Checked the embedded pre-commit shell block with `bash -n` ## Checklist - [x] I have read and understood the contribution guidelines - [x] I have run the pre-commit checks - [x] My changes generate no new warnings - [x] No documentation, unit-test, or package changelog change is required for this workflow-only fix - [x] My name already exists in `CONTRIBUTORS.md`
1 parent b25387f commit 0862ab0

2 files changed

Lines changed: 35 additions & 1 deletion

File tree

.github/scripts/resolve_backport_conflicts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ def _completion_payload(model: str, context: dict[str, Any]) -> dict[str, Any]:
203203
204204
Return a complete final UTF-8 file body for every required write action. Return empty content for every required delete
205205
action. Use exactly the paths and required actions supplied. Do not add cleanup or changes unrelated to the source
206-
commit.
206+
commit. The final files must pass the repository's pre-commit hooks.
207207
208208
Return only one JSON object without Markdown. It must satisfy this JSON Schema exactly:
209209
{json.dumps(schema, ensure_ascii=False, separators=(",", ":"))}"""

.github/workflows/backport-release-3.0.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,40 @@ jobs:
245245
--model "$primary_model" \
246246
--model "$fallback_model"
247247
248+
- name: Set up Python for inferred-resolution checks
249+
if: steps.cherry_pick.outputs.conflict == 'true'
250+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
251+
with:
252+
python-version: "3.12"
253+
254+
- name: Run pre-commit on inferred resolution
255+
if: steps.cherry_pick.outputs.conflict == 'true'
256+
working-directory: repository
257+
env:
258+
SKIP: check-changelog-fragments
259+
SOURCE_PARENT: ${{ steps.source.outputs.source_parent }}
260+
SOURCE_SHA: ${{ github.event.pull_request.merge_commit_sha }}
261+
TARGET_SHA: ${{ steps.source.outputs.target_sha }}
262+
run: |
263+
set -euo pipefail
264+
python -m pip install pre-commit==4.6.2
265+
266+
set +e
267+
pre-commit run --show-diff-on-failure --color=always --all-files
268+
pre_commit_status=$?
269+
set -e
270+
271+
if [ "$pre_commit_status" -ne 0 ]; then
272+
while IFS= read -r -d '' path; do
273+
git add --all -- "$path"
274+
done < <(git diff --no-renames --name-only -z "$SOURCE_PARENT" "$SOURCE_SHA" --)
275+
python3 ../automation/.github/scripts/backport.py validate-candidate \
276+
--source_parent "$SOURCE_PARENT" \
277+
--source "$SOURCE_SHA" \
278+
--target "$TARGET_SHA"
279+
pre-commit run --show-diff-on-failure --color=always --all-files
280+
fi
281+
248282
- name: Validate and commit inferred resolution
249283
if: steps.cherry_pick.outputs.conflict == 'true'
250284
working-directory: repository

0 commit comments

Comments
 (0)