@@ -1069,6 +1069,149 @@ def test_native_macos_optional_component_args_execute_under_system_bash( |
1069 | 1069 | ], |
1070 | 1070 | ) |
1071 | 1071 |
|
| 1072 | + def test_release_pinned_rstack_smoke_reuses_custom_installation_paths( |
| 1073 | + self, |
| 1074 | + ) -> None: |
| 1075 | + _, document = workflow("release-candidate.yml") |
| 1076 | + smoke = step_run( |
| 1077 | + document, |
| 1078 | + "assemble", |
| 1079 | + "Smoke release-pinned rstack installation from verified local assets", |
| 1080 | + ) |
| 1081 | + post_install = ( |
| 1082 | + 'set -euo pipefail\nversion="0.44.0"\n' |
| 1083 | + 'destination="${RUNNER_TEMP}/rstack-install-smoke"\n' |
| 1084 | + + 'test -L ' |
| 1085 | + + smoke.split("test -L ", 1)[1] |
| 1086 | + ) |
| 1087 | + |
| 1088 | + with tempfile.TemporaryDirectory( |
| 1089 | + prefix="candidate-rstack-smoke-" |
| 1090 | + ) as temporary_directory: |
| 1091 | + root = Path(temporary_directory) |
| 1092 | + runner_temp = root / "runner temp" |
| 1093 | + destination = runner_temp / "rstack-install-smoke" |
| 1094 | + bin_dir = destination / "bin" |
| 1095 | + install_root = destination / "lib" |
| 1096 | + stub_dir = root / "stub commands" |
| 1097 | + stub = stub_dir / "rstack" |
| 1098 | + invocation_log = root / "rstack arguments" |
| 1099 | + isolated_home = root / "isolated home" |
| 1100 | + bin_dir.mkdir(parents=True) |
| 1101 | + install_root.mkdir(parents=True) |
| 1102 | + stub_dir.mkdir(parents=True) |
| 1103 | + isolated_home.mkdir(parents=True) |
| 1104 | + stub.write_text( |
| 1105 | + "#!/usr/bin/env bash\n" |
| 1106 | + "set -euo pipefail\n" |
| 1107 | + 'printf "%s\\037" "$@" >> "${CAPTURE_ARGS:?}"\n' |
| 1108 | + 'printf "\\n" >> "${CAPTURE_ARGS:?}"\n' |
| 1109 | + 'install_root="${HOME}/.local/lib/registrystack"\n' |
| 1110 | + 'bin_dir="${HOME}/.local/bin"\n' |
| 1111 | + 'arguments=("$@")\n' |
| 1112 | + "command=()\n" |
| 1113 | + 'for ((index = 0; index < ${#arguments[@]}; index++)); do\n' |
| 1114 | + ' case "${arguments[index]}" in\n' |
| 1115 | + " --install-root)\n" |
| 1116 | + " ((index += 1))\n" |
| 1117 | + ' install_root="${arguments[index]}"\n' |
| 1118 | + " ;;\n" |
| 1119 | + " --bin-dir)\n" |
| 1120 | + " ((index += 1))\n" |
| 1121 | + ' bin_dir="${arguments[index]}"\n' |
| 1122 | + " ;;\n" |
| 1123 | + " --format)\n" |
| 1124 | + " ((index += 1))\n" |
| 1125 | + " ;;\n" |
| 1126 | + " *)\n" |
| 1127 | + ' command+=("${arguments[index]}")\n' |
| 1128 | + " ;;\n" |
| 1129 | + " esac\n" |
| 1130 | + "done\n" |
| 1131 | + "selected=false\n" |
| 1132 | + 'if [[ "${install_root}" == "${EXPECTED_INSTALL_ROOT:?}" ' |
| 1133 | + '&& "${bin_dir}" == "${EXPECTED_BIN_DIR:?}" ]]; then\n' |
| 1134 | + " selected=true\n" |
| 1135 | + "fi\n" |
| 1136 | + 'case "${command[*]}" in\n' |
| 1137 | + ' "--version")\n' |
| 1138 | + " printf 'rstack 0.44.0\\n'\n" |
| 1139 | + " ;;\n" |
| 1140 | + ' "components list")\n' |
| 1141 | + ' if [[ "${selected}" == true ]]; then\n' |
| 1142 | + " printf '%s\\n' " |
| 1143 | + "'{\"schema_version\":\"registry.rstack.components.v1\"," |
| 1144 | + "\"components\":[{\"name\":\"breg\",\"installed\":true}," |
| 1145 | + "{\"name\":\"evidence\",\"installed\":true}]}'\n" |
| 1146 | + " else\n" |
| 1147 | + " printf '%s\\n' " |
| 1148 | + "'{\"schema_version\":\"registry.rstack.components.v1\"," |
| 1149 | + "\"components\":[{\"name\":\"breg\",\"installed\":false}," |
| 1150 | + "{\"name\":\"evidence\",\"installed\":false}]}'\n" |
| 1151 | + " fi\n" |
| 1152 | + " ;;\n" |
| 1153 | + ' "breg --version")\n' |
| 1154 | + ' [[ "${selected}" == true ]]\n' |
| 1155 | + " printf 'bregctl 0.44.0\\n'\n" |
| 1156 | + " ;;\n" |
| 1157 | + ' "evidence --version")\n' |
| 1158 | + ' [[ "${selected}" == true ]]\n' |
| 1159 | + " printf 'evidencectl 0.44.0\\n'\n" |
| 1160 | + " ;;\n" |
| 1161 | + " *)\n" |
| 1162 | + " exit 2\n" |
| 1163 | + " ;;\n" |
| 1164 | + "esac\n", |
| 1165 | + encoding="utf-8", |
| 1166 | + ) |
| 1167 | + stub.chmod(0o755) |
| 1168 | + (bin_dir / "rstack").symlink_to(stub) |
| 1169 | + environment = { |
| 1170 | + **os.environ, |
| 1171 | + "CAPTURE_ARGS": str(invocation_log), |
| 1172 | + "EXPECTED_BIN_DIR": str(bin_dir), |
| 1173 | + "EXPECTED_INSTALL_ROOT": str(install_root), |
| 1174 | + "HOME": str(isolated_home), |
| 1175 | + "RUNNER_TEMP": str(runner_temp), |
| 1176 | + } |
| 1177 | + result = subprocess.run( |
| 1178 | + ["/bin/bash", "--noprofile", "--norc"], |
| 1179 | + input=post_install, |
| 1180 | + cwd=root, |
| 1181 | + env=environment, |
| 1182 | + capture_output=True, |
| 1183 | + text=True, |
| 1184 | + check=False, |
| 1185 | + ) |
| 1186 | + invocations = [ |
| 1187 | + [argument for argument in line.split("\x1f") if argument] |
| 1188 | + for line in invocation_log.read_text(encoding="utf-8").splitlines() |
| 1189 | + ] |
| 1190 | + command = [ |
| 1191 | + "--bin-dir", |
| 1192 | + str(bin_dir), |
| 1193 | + "--install-root", |
| 1194 | + str(install_root), |
| 1195 | + ] |
| 1196 | + self.assertEqual( |
| 1197 | + result.returncode, |
| 1198 | + 0, |
| 1199 | + f"stdout={result.stdout!r} stderr={result.stderr!r} " |
| 1200 | + f"invocations={invocations!r}", |
| 1201 | + ) |
| 1202 | + self.assertEqual(result.stdout, "") |
| 1203 | + self.assertEqual(result.stderr, "") |
| 1204 | + self.assertEqual( |
| 1205 | + invocations, |
| 1206 | + [ |
| 1207 | + [*command, "--version"], |
| 1208 | + [*command, "components", "list", "--format", "json"], |
| 1209 | + [*command, "components", "list", "--format", "json"], |
| 1210 | + [*command, "breg", "--version"], |
| 1211 | + [*command, "evidence", "--version"], |
| 1212 | + ], |
| 1213 | + ) |
| 1214 | + |
1072 | 1215 | def test_release_embeds_evidencectl_tag_and_publishes_latest_alias(self) -> None: |
1073 | 1216 | _, document = workflow("release-candidate.yml") |
1074 | 1217 | assemble = step_run( |
|