Merge pull request #36 from beatz174-bit/codex/add-terraform-installation-to-scripts

Ensure Codex scripts install Terraform for local checks
This commit is contained in:
beatz174-bit
2026-04-29 12:48:02 +10:00
committed by GitHub
2 changed files with 27 additions and 0 deletions
+1
View File
@@ -10,6 +10,7 @@ cd_repo_root
log "Refreshing Codex environment and running repository checks" log "Refreshing Codex environment and running repository checks"
"$SCRIPT_DIR/setup.sh" "$SCRIPT_DIR/setup.sh"
export PATH="$(pwd)/.codex/bin:$PATH"
if [[ -x scripts/check.sh ]]; then if [[ -x scripts/check.sh ]]; then
./scripts/check.sh ./scripts/check.sh
+26
View File
@@ -14,6 +14,28 @@ for cmd in bash git; do
have "$cmd" || die "$cmd is required" have "$cmd" || die "$cmd is required"
done done
install_terraform() {
if have terraform; then
log "terraform detected: $(command -v terraform)"
return 0
fi
have curl || die "curl is required to install terraform"
have unzip || die "unzip is required to install terraform"
local tf_version tf_zip tf_url tf_install_dir tf_tmp_dir
tf_version="${TERRAFORM_VERSION:-1.11.4}"
tf_zip="terraform_${tf_version}_linux_amd64.zip"
tf_url="https://releases.hashicorp.com/terraform/${tf_version}/${tf_zip}"
tf_install_dir="$(pwd)/.codex/bin"
tf_tmp_dir="$(pwd)/.codex/tmp"
log "terraform not found; installing v${tf_version} into ${tf_install_dir}"
curl -fsSL "$tf_url" -o "${tf_tmp_dir}/${tf_zip}"
unzip -qo "${tf_tmp_dir}/${tf_zip}" -d "$tf_install_dir"
chmod +x "${tf_install_dir}/terraform"
}
validate_goproxy() { validate_goproxy() {
local value="$1" local value="$1"
local part trimmed local part trimmed
@@ -46,13 +68,17 @@ ensure_dir .codex/bin
ensure_dir .codex/cache ensure_dir .codex/cache
ensure_dir .codex/tmp ensure_dir .codex/tmp
ensure_dir .codex/logs ensure_dir .codex/logs
export PATH="$(pwd)/.codex/bin:$PATH"
cat > .codex/env <<'ENVEOF' cat > .codex/env <<'ENVEOF'
export CI=1 export CI=1
export TERM=xterm-256color export TERM=xterm-256color
export GIT_PAGER=cat export GIT_PAGER=cat
export PATH="$(pwd)/.codex/bin:$PATH"
ENVEOF ENVEOF
install_terraform
if have python3; then if have python3; then
log "python3 detected" log "python3 detected"
if [[ ! -d .codex/venv ]]; then if [[ ! -d .codex/venv ]]; then