Skip to content

Commit aeebbae

Browse files
ci: rebuild-v2 python patch onto upstream main
1 parent aaf080c commit aeebbae

1 file changed

Lines changed: 58 additions & 6 deletions

File tree

‎.github/workflows/squash-once.yml‎

Lines changed: 58 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: squash-once
2+
# rebuild-v2-python-patch
23
on:
34
push:
45
paths:
@@ -31,11 +32,61 @@ jobs:
3132
UPSTREAM=$(git rev-parse upstream/main)
3233
echo "upstream/main=$UPSTREAM"
3334
git checkout -B rebuild "$UPSTREAM"
34-
git show 825e69ca5c6bbdbc93f87a1f1b583f3d47114eb9 -- temporalio/converter/_search_attributes.py tests/test_converter.py | git apply --index
3535
python3 <<'PY'
3636
from pathlib import Path
37-
p = Path("CHANGELOG.md")
38-
cl = p.read_text()
37+
38+
sa_path = Path("temporalio/converter/_search_attributes.py")
39+
sa = sa_path.read_text()
40+
old = (
41+
" # datetime needs to be in isoformat\n"
42+
" if isinstance(value, datetime):\n"
43+
" value = value.isoformat()"
44+
)
45+
new = (
46+
" # datetime needs to be in isoformat\n"
47+
" if isinstance(value, datetime):\n"
48+
" if value.tzinfo is None:\n"
49+
" raise ValueError(\"Timezone must be present on all search attribute dates\")\n"
50+
" value = value.isoformat()"
51+
)
52+
if old not in sa:
53+
raise SystemExit("search_attributes patch anchor missing")
54+
sa_path.write_text(sa.replace(old, new, 1))
55+
56+
tc_path = Path("tests/test_converter.py")
57+
tc = tc_path.read_text()
58+
imp_old = "encode_search_attribute_values,\n value_to_type,"
59+
imp_new = (
60+
"encode_search_attribute_values,\n"
61+
" encode_typed_search_attribute_value,\n"
62+
" value_to_type,"
63+
)
64+
if imp_old not in tc:
65+
raise SystemExit("test_converter import anchor missing")
66+
tc = tc.replace(imp_old, imp_new, 1)
67+
test_fn = (
68+
"def test_encode_typed_search_attribute_value_datetime_requires_timezone():\n"
69+
" key = temporalio.common.SearchAttributeKey.for_datetime(\"checkout_time\")\n"
70+
" with pytest.raises(ValueError, match=\"Timezone must be present\"):\n"
71+
" encode_typed_search_attribute_value(\n"
72+
" key, datetime(2024, 7, 5, 15, 43, 7, 875302)\n"
73+
" )\n"
74+
" payload = encode_typed_search_attribute_value(\n"
75+
" key, datetime(2024, 7, 5, 15, 43, 7, 875302, tzinfo=timezone.utc)\n"
76+
" )\n"
77+
" assert payload.metadata[\"type\"] == b\"Datetime\"\n"
78+
"\n"
79+
"\n"
80+
)
81+
anchor = "def test_decode_search_attributes():"
82+
if anchor not in tc:
83+
raise SystemExit("test_converter function anchor missing")
84+
if "test_encode_typed_search_attribute_value_datetime_requires_timezone" not in tc:
85+
tc = tc.replace(anchor, test_fn + anchor, 1)
86+
tc_path.write_text(tc)
87+
88+
cl_path = Path("CHANGELOG.md")
89+
cl = cl_path.read_text()
3990
bullet = (
4091
"- Encoding a datetime search attribute without a timezone now raises\n"
4192
" `ValueError(\"Timezone must be present on all search attribute dates\")` on\n"
@@ -50,10 +101,10 @@ jobs:
50101
if fixed < 0:
51102
raise SystemExit("Fixed section missing")
52103
insert = fixed + len("### Fixed\n\n")
53-
p.write_text(cl[:insert] + bullet + cl[insert:])
54-
print("CHANGELOG ok")
104+
cl_path.write_text(cl[:insert] + bullet + cl[insert:])
105+
print("patches applied")
55106
PY
56-
git add CHANGELOG.md
107+
git add temporalio/converter/_search_attributes.py tests/test_converter.py CHANGELOG.md
57108
rm -f .github/workflows/squash-once.yml .github/workflows/apply-review-fix.yml || true
58109
git rm -f --ignore-unmatch .github/workflows/squash-once.yml .github/workflows/apply-review-fix.yml || true
59110
find . -maxdepth 3 -name ".cursor-*" -type f -delete 2>/dev/null || true
@@ -83,4 +134,5 @@ jobs:
83134
test "$(git log -1 --format=%an)" = "Kailash Nelson"
84135
test "$(git log -1 --format=%ae)" = "37966146+KingLizard1020@users.noreply.github.com"
85136
! git log -1 --format=%B | grep -qi cursor
137+
git rev-parse HEAD^ | grep -qx "$UPSTREAM"
86138
git push --force origin "HEAD:cursor/datetime-search-attr-tz-0487"

0 commit comments

Comments
 (0)