Skip to content

Commit 3592d11

Browse files
authored
ci: simplify extension check - always require version bump (#2380)
Previous check could not cope with releases off-main. This simpler form just means sometimes versions need to be bumped unnecessarily (have already been bumped since last release) but that is not a problem. See https://github.com/CQCL/hugr/actions/runs/15928196052/job/44930533975
1 parent 885aa8c commit 3592d11

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

.github/workflows/ci-py.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,14 +200,13 @@ jobs:
200200
# Check against latest tag on the target branch
201201
# When not on a pull request, base_ref should be empty so we default to HEAD
202202
if [ -z "$TARGET_REF" ]; then
203-
BASE_SHA=""
203+
BASE_SHA="HEAD~1"
204204
else
205205
BASE_SHA=$(git rev-parse origin/$TARGET_REF)
206206
fi
207-
LAST_TAG=$(git describe --abbrev=0 --match="hugr-*" $BASE_SHA)
208-
echo "Latest tag on target: $LAST_TAG"
207+
echo "Comparing to ref: $BASE_SHA"
209208
210-
python ./scripts/check_extension_versions.py $LAST_TAG
209+
python ./scripts/check_extension_versions.py $BASE_SHA
211210
env:
212211
TARGET_REF: ${{ github.base_ref }}
213212

scripts/check_extension_versions.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,13 @@ def check_version_changes(changed_files: list[Path], target: str) -> list[str]:
4848

4949
if current_version == target_version:
5050
errors.append(
51-
f"Error: {file_path} was modified but version was not updated. "
52-
f"Current: {current_version}, base: {target_version}"
51+
f"Error: {file_path} was modified but version {current_version}"
52+
" was not updated."
53+
)
54+
else:
55+
print(
56+
f"Version updated in {file_path}: {target_version}"
57+
f" -> {current_version}"
5358
)
5459

5560
else:
@@ -59,7 +64,6 @@ def check_version_changes(changed_files: list[Path], target: str) -> list[str]:
5964
except json.JSONDecodeError:
6065
# File is new or not valid JSON in target
6166
pass
62-
6367
return errors
6468

6569

@@ -75,7 +79,7 @@ def main() -> int:
7579
errors = check_version_changes(changed_files, target)
7680
if errors:
7781
for error in errors:
78-
print(error)
82+
sys.stderr.write(error)
7983
return 1
8084

8185
print("All changed extension files have updated versions.")

0 commit comments

Comments
 (0)