Skip to content

Commit f841dc5

Browse files
authored
[python] fix CI (#10874)
1 parent 455c98a commit f841dc5

3 files changed

Lines changed: 33 additions & 13 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
changeKind: internal
3+
packages:
4+
- "@typespec/http-client-python"
5+
---
6+
7+
Only copy the legacy code paths required for tests from the baseline sparse-checkout instead of copying the entire `azure/` and `unbranded/` baseline trees.

packages/http-client-python/eng/scripts/ci/regenerate-common.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -716,15 +716,31 @@ export async function prepareBaselineOfGeneratedCode(generatedFolder: string): P
716716
run(`git fetch --depth 1 origin ${branch}`);
717717
run(`git checkout FETCH_HEAD`);
718718

719+
// we don't copy whole generated folder, just the specific subfolders needed for tests
720+
// to verify correct preservation/deletion of files and folders during regeneration,
721+
// to avoid accidentally including any manually edited code that might be in the repo
722+
// and cause confusion when it doesn't get updated during regeneration
723+
const legacyCodePathNeededForTests = [
724+
"azure/authentication-api-key",
725+
"unbranded/authentication-api-key",
726+
"azure/authentication-union",
727+
"azure/generation-subdir",
728+
"azure/generation-subdir2",
729+
"unbranded/generation-subdir",
730+
"unbranded/generation-subdir2",
731+
];
732+
719733
const sourceRoot = join(tempDir, ...sourceSubdir.split("/"));
720-
for (const flavor of ["azure", "unbranded"]) {
721-
const src = join(sourceRoot, flavor);
722-
const dest = join(testsGeneratedDir, flavor);
734+
for (const subPath of legacyCodePathNeededForTests) {
735+
const segments = subPath.split("/");
736+
const src = join(sourceRoot, ...segments);
737+
const dest = join(testsGeneratedDir, ...segments);
723738
if (!existsSync(src)) {
724739
console.warn(pc.yellow(`Baseline folder not found: ${src}`));
725740
continue;
726741
}
727-
console.log(pc.dim(`Copying ${flavor}/ -> ${dest}`));
742+
console.log(pc.dim(`Copying ${subPath} -> ${dest}`));
743+
await mkdir(dirname(dest), { recursive: true });
728744
await cp(src, dest, { recursive: true });
729745
}
730746

packages/http-client-python/generator/pygen/preprocess/__init__.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,7 @@ def _get_etag_role(parameter: dict[str, Any]) -> Optional[str]:
171171
return parameter.get("etagRole")
172172

173173

174-
def _pick_etag_slot(
175-
candidates: list[dict[str, Any]], standard_wire_name: str
176-
) -> Optional[dict[str, Any]]:
174+
def _pick_etag_slot(candidates: list[dict[str, Any]], standard_wire_name: str) -> Optional[dict[str, Any]]:
177175
"""Choose which etag-typed header should be promoted to the etag/match_condition slot.
178176
179177
When more than one etag-typed header is present in an operation, prefer the
@@ -258,15 +256,14 @@ def _process_operation_etag_headers(
258256
elif role == "ifNoneMatch":
259257
if_none_match_candidates.append(p)
260258

261-
property_if_match, property_if_none_match = _resolve_etag_pair(
262-
if_match_candidates, if_none_match_candidates
263-
)
259+
property_if_match, property_if_none_match = _resolve_etag_pair(if_match_candidates, if_none_match_candidates)
264260

265261
if property_if_match and property_if_none_match:
266262
etag_params = {id(property_if_match), id(property_if_none_match)}
267-
operation["parameters"] = [
268-
item for item in operation["parameters"] if id(item) not in etag_params
269-
] + [property_if_match, property_if_none_match]
263+
operation["parameters"] = [item for item in operation["parameters"] if id(item) not in etag_params] + [
264+
property_if_match,
265+
property_if_none_match,
266+
]
270267
operation["hasEtag"] = True
271268
client["hasEtag"] = True
272269

0 commit comments

Comments
 (0)