Repository navigation
Expand file tree
/
Copy pathcloud.sh
More file actions
executable file
·79 lines (68 loc) · 3.32 KB
/
Copy pathcloud.sh
File metadata and controls
executable file
·79 lines (68 loc) · 3.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env bash
# Codex Cloud environment for worktrunk's test suite.
#
# The environment uses the `universal` image, caching, unrestricted internet,
# and no variables or secrets. Configure its settings fields with these
# commands:
#
# bash .codex/cloud.sh setup
# bash .codex/cloud.sh maintain
#
# Validate a built environment with `cargo run -- hook pre-merge --yes`.
#
# The universal image is missing the shells, tools, and git version the suite
# needs. `setup` installs them; `maintain` re-warms the toolchain and caches for
# an environment restored from cache. Both run as root, which is how Codex Cloud
# runs the agent — so the tests that need an unprivileged uid skip, as they
# already do under `task setup-web`. The standing TODO is in
# tests/integration_tests/approval_pty.rs.
#
# The gate runs `--all-features`, so nu and pwsh drive PTY snapshots their own
# versions can move. cargo-insta, cargo-nextest, and nu are kept level with the
# pins in .github/actions/test-setup/action.yaml. CI has no pwsh pin — it takes
# whatever the runner image ships — so that version answers to nothing but this
# file.
set -euo pipefail
PRE_COMMIT_VERSION=4.7.0
INSTA_VERSION=1.49.0
NEXTEST_VERSION=0.9.150
NU_VERSION=0.116.1
PWSH_VERSION=7.6.9
cd "$(dirname "${BASH_SOURCE[0]}")/.."
setup() {
export DEBIAN_FRONTEND=noninteractive
apt-get update -qq
apt-get install -y -qq --no-install-recommends software-properties-common
add-apt-repository -y ppa:git-core/ppa
apt-get update -qq
apt-get install -y -qq --no-install-recommends git zsh fish xz-utils lsof
uv tool install --force pre-commit=="$PRE_COMMIT_VERSION"
tmp="$(mktemp -d)"
curl -fsSL "https://github.com/mitsuhiko/insta/releases/download/$INSTA_VERSION/cargo-insta-x86_64-unknown-linux-gnu.tar.xz" | tar -xJ -C "$tmp"
install -D -m 0755 "$tmp/cargo-insta-x86_64-unknown-linux-gnu/cargo-insta" /root/.local/bin/cargo-insta
curl -fsSL "https://github.com/nextest-rs/nextest/releases/download/cargo-nextest-$NEXTEST_VERSION/cargo-nextest-$NEXTEST_VERSION-x86_64-unknown-linux-gnu.tar.gz" | tar -xz -C "$tmp"
install -D -m 0755 "$tmp/cargo-nextest" /root/.local/bin/cargo-nextest
curl -fsSL "https://github.com/nushell/nushell/releases/download/$NU_VERSION/nu-$NU_VERSION-x86_64-unknown-linux-gnu.tar.gz" | tar -xz -C "$tmp"
install -D -m 0755 "$tmp/nu-$NU_VERSION-x86_64-unknown-linux-gnu/nu" /root/.local/bin/nu
rm -r -- "$tmp"
install -d /opt/microsoft/powershell/7
curl -fsSL "https://github.com/PowerShell/PowerShell/releases/download/v$PWSH_VERSION/powershell-$PWSH_VERSION-linux-x64.tar.gz" | tar -xz -C /opt/microsoft/powershell/7
chmod 0755 /opt/microsoft/powershell/7/pwsh
ln -sf /opt/microsoft/powershell/7/pwsh /usr/local/bin/pwsh
# pwsh needs the image's libicu, and without it lands on PATH but aborts at
# startup — so run it rather than looking for it.
pwsh -NoLogo -NoProfile -Command '$PSVersionTable.PSVersion.ToString()'
# A stale git fails the suite obscurely; fail here instead.
dpkg --compare-versions "$(git version | awk '{print $3}')" ge 2.54.0
git config --system --add safe.directory "$PWD"
}
maintain() {
rustup component add rust-docs
pre-commit install-hooks
cargo fetch --locked
}
case "${1-}" in
setup) setup; maintain ;;
maintain) maintain ;;
*) echo "usage: bash .codex/cloud.sh setup|maintain" >&2; exit 1 ;;
esac