Skip to content

Commit 46704df

Browse files
committed
1 parent a6fb75a commit 46704df

2 files changed

Lines changed: 42 additions & 0 deletions

File tree

‎.agents/setup‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env bash
2+
# Prepares an Amp orb: installs PHP, Composer, project dependencies and the coding standard.
3+
set -euo pipefail
4+
cd "$(dirname "${BASH_SOURCE[0]}")/.."
5+
6+
step() {
7+
echo "==> $(basename "$PWD"): $*"
8+
SECONDS=0
9+
}
10+
11+
step "PHP"
12+
packages=(php8.2-cli php8.2-curl php8.2-intl php8.2-mbstring php8.2-xml php8.2-zip unzip)
13+
missing=()
14+
for package in "${packages[@]}"; do
15+
dpkg-query -W -f='${Status}' "$package" 2>/dev/null | grep -q 'install ok installed' || missing+=("$package")
16+
done
17+
if ((${#missing[@]})); then
18+
sudo apt-get update -qq
19+
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends "${missing[@]}"
20+
fi
21+
echo " $(php -r 'echo PHP_VERSION;') (${SECONDS}s)"
22+
23+
step "Composer"
24+
if ! command -v composer >/dev/null 2>&1; then
25+
tmp="$(mktemp -d)"
26+
curl -fsSL -o "$tmp/composer.phar" https://getcomposer.org/download/latest-stable/composer.phar
27+
curl -fsSL -o "$tmp/composer.phar.sha256sum" https://getcomposer.org/download/latest-stable/composer.phar.sha256sum
28+
(cd "$tmp" && sed 's/ .*/ composer.phar/' composer.phar.sha256sum | sha256sum -c --quiet)
29+
sudo install -m 0755 "$tmp/composer.phar" /usr/local/bin/composer
30+
rm -rf "$tmp"
31+
fi
32+
echo " $(composer --version --no-ansi 2>/dev/null | head -n1) (${SECONDS}s)"
33+
34+
step "composer update"
35+
# There is no committed lockfile, so resolve like CI does.
36+
composer update --no-interaction --no-progress --quiet
37+
echo " (${SECONDS}s)"
38+
39+
step "make cs-install"
40+
make -s cs-install
41+
echo " (${SECONDS}s)"

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
/vendor
44
/composer.lock
55
.phpunit.result.cache
6+
/.amp/portals/*

0 commit comments

Comments
 (0)