Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion docs/UPDATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ make update
| `ixatu-day` | Prepara o recupera la sesión diaria declarativa `ixatu` de Herdr |
| `make update` | Mismo flujo, invocado desde `~/dotfiles` |
| `make update-windows` | Ejecuta WinGet y `wsl --update` desde PowerShell/Windows |
| `make update-wsl` | Ejecuta APT, Node/tooling IA, OpenCode, shell, uv, MCPs e imágenes Docker |
| `make update-wsl` | Ejecuta APT (incluido Azure CLI), Node/tooling IA, OpenCode, shell, uv, MCPs e imágenes Docker |
| `make update-projects` | Actualiza proyectos personales como `~/proyectos/jesuserro` y RenderCV |
| `make update-check` | Diagnóstico no mutante de requisitos de actualización y MCPs |
| `make github-identity-check` / `github-identity-check` | Diagnóstico read-only de remotos, cuenta `gh` efectiva y tokens de entorno |
Expand All @@ -48,6 +48,20 @@ make update

`make update` no sustituye `chezmoi apply` y no regenera secretos.

En la fase APT, una Azure CLI ya instalada se actualiza mediante el `apt-get
upgrade` general. Si `az` no existe, el flujo llama al instalador idempotente
`scripts/install-azure-cli.sh`; no inicia sesión ni toca `~/.azure`. El resumen
registra la versión anterior y posterior, y conserva como incidente cualquier
fallo de instalación sin detener el resto del mantenimiento.

Para consultar la sesión y suscripción seleccionada sin modificar Azure:
`bash scripts/check-azure-tools.sh`. Para autenticarte manualmente usa
`az login --tenant cafb7744-aedc-4c62-8a02-0474058bbfaa` y verifica la
suscripción con `az account show --query '{id:id,name:name,tenantId:tenantId}' --output table`.
Si necesitas cambiarla, usa `az account set --subscription '<ID>'`
**manualmente** y repite el diagnóstico. No sincronizar `~/.azure`,
tokens ni caches entre equipos, y no registrar credenciales en los logs.

## Windows + WSL

Desde Ubuntu/WSL, `make update` crea un directorio de ejecución en una ruta visible por Windows y WSL. La pestaña WSL ejecuta el mantenimiento Linux; una nueva pestaña PowerShell ejecuta WinGet y `wsl --update`.
Expand Down
28 changes: 19 additions & 9 deletions scripts/check-azure-tools.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#!/usr/bin/env bash
# Read-only Azure workstation readiness check for WSL2/Linux.
# This script never logs in, selects subscriptions, creates resources, or deletes
# resources. It only checks local tooling and reports actionable next steps.
# resources. Azure account output is restricted to subscription ID and name for
# the expected tenant; users, credentials, and secrets are never printed.

set -u

critical_missing=0
warnings=0
EXPECTED_AZURE_TENANT_ID="cafb7744-aedc-4c62-8a02-0474058bbfaa"

section() {
printf '\n==> %s\n' "$1"
Expand Down Expand Up @@ -129,17 +131,25 @@ check_any_recommended_command "lsb-release" lsb_release lsb-release --version

section "Azure CLI"
if command -v az >/dev/null 2>&1; then
if az account show --output table >/dev/null 2>&1; then
line "OK" "Sesión Azure activa:"
az account show --output table 2>/dev/null
active_tenant="$(az account show --query tenantId --output tsv 2>/dev/null || true)"
if [[ -z "${active_tenant}" ]]; then
warn "No hay sesión Azure activa o no se pudo verificar el tenant actual."
printf ' Para iniciar sesión manualmente usa Azure CLI login.\n'
elif [[ "${active_tenant}" != "${EXPECTED_AZURE_TENANT_ID}" ]]; then
warn "La sesión Azure activa no pertenece al tenant esperado."
else
warn "No hay sesión Azure activa o no se pudo leer la cuenta actual."
printf ' Para iniciar sesión manualmente: az %s\n' "login"
line "OK" "Tenant Azure esperado verificado."
selected_id="$(az account show --query id --output tsv 2>/dev/null || true)"
selected_name="$(az account show --query name --output tsv 2>/dev/null || true)"
if [[ -n "${selected_id}" && -n "${selected_name}" ]]; then
line "OK" "Suscripción seleccionada: ${selected_name} (${selected_id})"
else
warn "No fue posible identificar la suscripción seleccionada."
fi
fi

if az extension show --name containerapp --output table >/dev/null 2>&1; then
line "OK" "Extensión Azure CLI 'containerapp' disponible:"
az extension show --name containerapp --output table 2>/dev/null
if az extension show --name containerapp --query name --output tsv >/dev/null 2>&1; then
line "OK" "Extensión Azure CLI 'containerapp' disponible."
else
warn "Extensión Azure CLI 'containerapp' no disponible."
printf ' Recomendación: az extension add --name containerapp --upgrade\n'
Expand Down
10 changes: 10 additions & 0 deletions scripts/update/update-wsl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -153,17 +153,26 @@ run_versioned_step() {

run_apt() {
section "APT"
local azure_cli_before azure_cli_after
azure_cli_before="$(probe_named_version "Azure CLI" az version --query '"azure-cli"' --output tsv || true)"
if is_truthy "${DOTFILES_UPDATE_MOCK:-}"; then
result_ok "WSL" "APT" "mocked"
record_version_transition "WSL" "Azure CLI" "$azure_cli_before" "$azure_cli_before"
return 0
fi
if ! command -v sudo >/dev/null 2>&1; then
result_fail "WSL" "APT" "sudo not found"
record_version_transition "WSL" "Azure CLI" "$azure_cli_before" "$azure_cli_before"
return 0
fi
run_step "WSL" "APT update" "${LOG_DIR}/wsl-apt-update.log" sudo apt-get update -y
run_step "WSL" "APT upgrade" "${LOG_DIR}/wsl-apt-upgrade.log" sudo apt-get upgrade -y
run_step "WSL" "APT autoremove" "${LOG_DIR}/wsl-apt-autoremove.log" sudo apt-get autoremove -y
if ! command -v az >/dev/null 2>&1; then
run_step "WSL" "Azure CLI install" "${LOG_DIR}/wsl-azure-cli.log" "${DOTFILES_ROOT}/scripts/install-azure-cli.sh"
fi
azure_cli_after="$(probe_named_version "Azure CLI" az version --query '"azure-cli"' --output tsv || true)"
record_version_transition "WSL" "Azure CLI" "$azure_cli_before" "$azure_cli_after"
}

ensure_node_runtime() {
Expand Down Expand Up @@ -512,6 +521,7 @@ snapshot_current_tool() {
}

capture_workstation_snapshot() {
snapshot_current_tool "Azure CLI" az version --query '"azure-cli"' --output tsv
snapshot_current_tool "Python" python3 --version
snapshot_current_tool "Node.js" node --version
snapshot_current_tool "npm" npm --version
Expand Down
69 changes: 69 additions & 0 deletions tests/bats/system/azure-tools.bats
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ setup() {
CHECK_SCRIPT="${DOTFILES_DIR}/scripts/check-azure-tools.sh"
AZURE_ALIASES="${DOTFILES_DIR}/zsh/55-aliases-azure.zsh"
AZURE_DOC="${DOTFILES_DIR}/docs/ops/azure-tooling.md"
setup_temp_dir
}

teardown() {
teardown_temp_dir
}

@test "check-azure-tools.sh exists" {
Expand Down Expand Up @@ -60,3 +65,67 @@ setup() {
run grep -n '55-aliases-azure.zsh' "${DOTFILES_DIR}/zshrc"
[[ "${status}" -eq 0 ]]
}

@test "Azure account check verifies expected tenant and selected subscription" {
local stub_dir="${TEST_TEMP_DIR}/bin"
local az_log="${TEST_TEMP_DIR}/az.log"
mkdir -p "$stub_dir"
for cmd in git make jq curl; do
ln -s "$(command -v "$cmd")" "$stub_dir/$cmd"
done
cat >"${stub_dir}/docker" <<'EOF'
#!/usr/bin/env bash
exit 0
EOF
cat >"${stub_dir}/az" <<'EOF'
#!/usr/bin/env bash
printf '%s\n' "$*" >>"${AZ_TEST_LOG}"
case "$*" in
"version --query \"azure-cli\" --output tsv") printf '2.79.0\n' ;;
"account show --query tenantId --output tsv") printf 'cafb7744-aedc-4c62-8a02-0474058bbfaa\n' ;;
"account show --query id --output tsv") printf '00000000-0000-0000-0000-000000000001\n' ;;
"account show --query name --output tsv") printf 'Production\n' ;;
"extension show --name containerapp --query name --output tsv") printf 'containerapp\n' ;;
esac
EOF
chmod +x "${stub_dir}/az" "${stub_dir}/docker"

run env AZ_TEST_LOG="$az_log" PATH="${stub_dir}:/usr/bin:/bin" "$CHECK_SCRIPT"
[[ "$status" -eq 0 ]]
[[ "$output" == *"Production (00000000-0000-0000-0000-000000000001)"* ]]
[[ "$output" != *"Development"* ]]
[[ "$output" != *"operator@example.com"* ]]
[[ "$output" != *"client-secret"* ]]
grep -Fq "account show --query tenantId --output tsv" "$az_log"
grep -Fq "account show --query id --output tsv" "$az_log"
}

@test "Azure account check does not print account details for a different tenant" {
local stub_dir="${TEST_TEMP_DIR}/bin-mismatch"
mkdir -p "$stub_dir"
for cmd in git make jq curl; do
ln -s "$(command -v "$cmd")" "$stub_dir/$cmd"
done
cat >"${stub_dir}/docker" <<'EOF'
#!/usr/bin/env bash
exit 0
EOF
cat >"${stub_dir}/az" <<'EOF'
#!/usr/bin/env bash
case "$*" in
"version --query \"azure-cli\" --output tsv") printf '2.79.0\n' ;;
"account show --query tenantId --output tsv") printf '11111111-1111-1111-1111-111111111111\n' ;;
"account show --query id --output tsv") printf 'SHOULD-NOT-PRINT\n' ;;
"account show --query name --output tsv") printf 'Secret Subscription\n' ;;
"extension show --name containerapp --query name --output tsv") printf 'containerapp\n' ;;
esac
EOF
chmod +x "${stub_dir}/az" "${stub_dir}/docker"

run env PATH="${stub_dir}:/usr/bin:/bin" "$CHECK_SCRIPT"
[[ "$status" -eq 0 ]]
[[ "$output" == *"no pertenece al tenant esperado"* ]]
[[ "$output" != *"SHOULD-NOT-PRINT"* ]]
[[ "$output" != *"Secret Subscription"* ]]
[[ "$output" != *"11111111-1111-1111-1111-111111111111"* ]]
}
40 changes: 29 additions & 11 deletions tests/bats/system/install-azure-cli.bats
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ make_install_stubs() {
#!/usr/bin/env bash
echo "curl $*" >>"${AZURE_TEST_LOG}"
case "$*" in
*"dists/resolute/Release"*)
*"dists/futurecodename/Release"*)
exit 22
;;
*"dists/noble/Release"*)
Expand Down Expand Up @@ -103,6 +103,22 @@ done
exit 0
EOF
chmod +x "${stub_dir}/curl" "${stub_dir}/sudo" "${stub_dir}/apt-get" "${stub_dir}/dpkg" "${stub_dir}/gpg"
# Test-only isolation: a workstation with /usr/bin/az must still exercise
# the missing-tool installer path. Only the temporary stub can satisfy az.
cat >"${stub_dir}/isolate-az.bash" <<'AZENV'
command() {
if [[ "${1:-}" == "-v" && "${2:-}" == "az" ]]; then
local found
found="$(builtin command -v az 2>/dev/null)" || return 1
case "${found}" in
"${AZURE_TEST_STUB_DIR}"/*) printf '%s\n' "${found}"; return 0 ;;
*) return 1 ;;
esac
fi
builtin command "$@"
}
AZENV
export BASH_ENV="${stub_dir}/isolate-az.bash"
}

@test "install-azure-cli.sh exists and passes bash -n" {
Expand Down Expand Up @@ -136,7 +152,7 @@ EOF
local source_dir="${TEST_TEMP_DIR}/sources"
local keyring="${TEST_TEMP_DIR}/keyrings/microsoft.gpg"
local log="${TEST_TEMP_DIR}/commands.log"
write_os_release "resolute"
write_os_release "futurecodename"
make_install_stubs "${stub_dir}"
mkdir -p "${source_dir}" "$(dirname "${keyring}")"
: >"${log}"
Expand All @@ -152,9 +168,9 @@ EOF

[[ "${status}" -ne 0 ]]
[[ "${output}" == *"Microsoft no publica Azure CLI"* ]]
[[ "${output}" == *"resolute"* ]]
[[ "${output}" == *"futurecodename"* ]]
[[ ! -e "${source_dir}/azure-cli.list" ]]
[[ "$(cat "${log}")" == *"dists/resolute/Release"* ]]
[[ "$(cat "${log}")" == *"dists/futurecodename/Release"* ]]
[[ "$(cat "${log}")" != *"apt-get update"* ]]
[[ "$(cat "${log}")" != *"apt-get install -y azure-cli"* ]]
}
Expand All @@ -164,7 +180,7 @@ EOF
local source_dir="${TEST_TEMP_DIR}/sources"
local keyring="${TEST_TEMP_DIR}/keyrings/microsoft.gpg"
local log="${TEST_TEMP_DIR}/commands.log"
write_os_release "noble"
write_os_release "resolute"
make_install_stubs "${stub_dir}"
mkdir -p "${source_dir}" "$(dirname "${keyring}")"
: >"${log}"
Expand All @@ -179,11 +195,11 @@ EOF
bash "${INSTALL_AZURE}"

[[ "${status}" -eq 0 ]]
[[ "${output}" == *"Microsoft publica Azure CLI para 'noble'"* ]]
[[ "${output}" == *"Microsoft publica Azure CLI para 'resolute'"* ]]
[[ "${output}" == *"Azure CLI instalado"* ]]
[[ -f "${source_dir}/azure-cli.list" ]]
[[ "$(cat "${source_dir}/azure-cli.list")" == *" noble main"* ]]
[[ "$(cat "${log}")" == *"dists/noble/Release"* ]]
[[ "$(cat "${source_dir}/azure-cli.list")" == *" resolute main"* ]]
[[ "$(cat "${log}")" == *"dists/resolute/Release"* ]]
[[ "$(cat "${log}")" == *"apt-get install -y azure-cli"* ]]
}

Expand Down Expand Up @@ -225,10 +241,10 @@ EOF
local source_dir="${TEST_TEMP_DIR}/sources"
local keyring="${TEST_TEMP_DIR}/keyrings/microsoft.gpg"
local log="${TEST_TEMP_DIR}/commands.log"
write_os_release "resolute"
write_os_release "futurecodename"
make_install_stubs "${stub_dir}"
mkdir -p "${source_dir}" "$(dirname "${keyring}")"
printf 'deb https://packages.microsoft.com/repos/azure-cli/ resolute main\n' >"${source_dir}/azure-cli.list"
printf 'deb https://packages.microsoft.com/repos/azure-cli/ futurecodename main\n' >"${source_dir}/azure-cli.list"
printf 'deb https://packages.microsoft.com/repos/edge/ stable main\n' >"${source_dir}/microsoft-edge.list"
: >"${log}"

Expand Down Expand Up @@ -355,7 +371,9 @@ EOF
@test "deps-check default does not include optional azure-cli" {
run python3 "${HELPER_SCRIPT}" list --inventory "${DOTFILES_DIR}/system/packages/tooling.yaml"
[[ "${status}" -eq 0 ]]
[[ "${output}" != *"azure-cli"* ]]
# Match package-column boundaries, not the worktree path
# (which may itself be named azure-cli-update).
[[ "${output}" != *$'\tazure-cli\t'* ]]
[[ "${output}" != *$'\taz\t'* ]]
}

Expand Down
Loading
Loading