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
148 changes: 148 additions & 0 deletions qualification/composer-container-trust.json
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,154 @@
"mode": 420
}
}
},
"sample-app-php-ci": {
"target": "sample-app",
"matrix": {
"php": [
"8.4",
"8.5"
]
},
"workflows": {
"ci.yml": [
"test",
"microservice-test"
]
},
"commands": [
"bash \"$GITHUB_WORKSPACE/scripts/ci/setup-php-container.sh\" \"${{ matrix.php }}\""
],
"environment": [
"SAMPLE_APP_PHP_CI_IMAGE",
"SAMPLE_APP_PHP_CI_ROOT",
"SAMPLE_APP_PHP_CI_STATE"
],
"absent_files": [
"docker/php-ci/Dockerfile.dockerignore"
],
"files": {
".dockerignore": {
"sha256": "3d3b99f9bbf9d4ce35b7dc8462c4da1c87983b2b65a3a829d8ec9d80f43551cc",
"mode": 420
},
"docker/php-ci/Dockerfile": {
"sha256": "dcdd1e2f99db98825f9cf6b89ab2b0191252d2816001af09f391b6fb1a8b035a",
"mode": 420
},
"scripts/ci/php-container-images.json": {
"sha256": "fc4d410589d1fdb322107e404bfcf9f4593e6ac7e3fcce729b1d78fafd9be1c4",
"mode": 420
},
"scripts/ci/run-php-container.sh": {
"sha256": "f4030f583b9bf148cb12209ad5d709308593c60b9e04a08acc4d07c614aa8883",
"mode": 493
},
"scripts/ci/setup-php-container.sh": {
"sha256": "051301e9af4a65503a34c513a1e91c802a59e66c3b0c00c1425c87e30797bb08",
"mode": 493
},
"tests/ci/test_php_container_tls.py": {
"sha256": "673e53e9b1f9a91f7c986cad50ca96aeff38a530fb426aefd1a7cf585d102b2c",
"mode": 420
},
".devcontainer/docker/verify-php-trust.php": {
"sha256": "bd8682984a757eb28887e996f77c9cafed32634cc7e19155b9885da1bb5b48c9",
"mode": 420
},
"docker/install-phpredis.sh": {
"sha256": "17b21ea9724199f502605abeeff6856f8af721027691e1de74d12cc6ccb7d33b",
"mode": 420
},
"docker/brotli/install-vendor.sh": {
"sha256": "d7eb8b2a3e0af1c3072a56bcb81632b22f061f211d8fe5e57ee901c8bf94c92f",
"mode": 420
},
"docker/brotli/verify-runtime.php": {
"sha256": "580cc465e349f3872eca592355294e7320fe7f1a4560ff5d4c83d5900921c00e",
"mode": 420
},
"docker/brotli/verify-system-brotli.c": {
"sha256": "3353927d206aaf5e63157e46be715c6cbee46bac777e29f8f9e25c4c1f656667",
"mode": 420
},
"docker/brotli/version": {
"sha256": "e064953e075ddb99fb7b48ad29e215f2dfa075812c127eb1d6ab680e9920fba2",
"mode": 420
}
}
},
"sample-app-php84-ci": {
"target": "sample-app",
"workflows": {
"composer-lock-audit.yml": [
"audit"
],
"playground-journeys.yml": [
"journeys"
]
},
"commands": [
"bash \"$GITHUB_WORKSPACE/scripts/ci/setup-php-container.sh\" \"8.4\""
],
"environment": [
"SAMPLE_APP_PHP_CI_IMAGE",
"SAMPLE_APP_PHP_CI_ROOT",
"SAMPLE_APP_PHP_CI_STATE"
],
"absent_files": [
"docker/php-ci/Dockerfile.dockerignore"
],
"files": {
".dockerignore": {
"sha256": "3d3b99f9bbf9d4ce35b7dc8462c4da1c87983b2b65a3a829d8ec9d80f43551cc",
"mode": 420
},
"docker/php-ci/Dockerfile": {
"sha256": "dcdd1e2f99db98825f9cf6b89ab2b0191252d2816001af09f391b6fb1a8b035a",
"mode": 420
},
"scripts/ci/php-container-images.json": {
"sha256": "fc4d410589d1fdb322107e404bfcf9f4593e6ac7e3fcce729b1d78fafd9be1c4",
"mode": 420
},
"scripts/ci/run-php-container.sh": {
"sha256": "f4030f583b9bf148cb12209ad5d709308593c60b9e04a08acc4d07c614aa8883",
"mode": 493
},
"scripts/ci/setup-php-container.sh": {
"sha256": "051301e9af4a65503a34c513a1e91c802a59e66c3b0c00c1425c87e30797bb08",
"mode": 493
},
"tests/ci/test_php_container_tls.py": {
"sha256": "673e53e9b1f9a91f7c986cad50ca96aeff38a530fb426aefd1a7cf585d102b2c",
"mode": 420
},
".devcontainer/docker/verify-php-trust.php": {
"sha256": "bd8682984a757eb28887e996f77c9cafed32634cc7e19155b9885da1bb5b48c9",
"mode": 420
},
"docker/install-phpredis.sh": {
"sha256": "17b21ea9724199f502605abeeff6856f8af721027691e1de74d12cc6ccb7d33b",
"mode": 420
},
"docker/brotli/install-vendor.sh": {
"sha256": "d7eb8b2a3e0af1c3072a56bcb81632b22f061f211d8fe5e57ee901c8bf94c92f",
"mode": 420
},
"docker/brotli/verify-runtime.php": {
"sha256": "580cc465e349f3872eca592355294e7320fe7f1a4560ff5d4c83d5900921c00e",
"mode": 420
},
"docker/brotli/verify-system-brotli.c": {
"sha256": "3353927d206aaf5e63157e46be715c6cbee46bac777e29f8f9e25c4c1f656667",
"mode": 420
},
"docker/brotli/version": {
"sha256": "e064953e075ddb99fb7b48ad29e215f2dfa075812c127eb1d6ab680e9920fba2",
"mode": 420
}
}
}
}
}
67 changes: 67 additions & 0 deletions tests/fixtures/sample-app-php-ci/799df847/run-php-container.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/env bash
set -euo pipefail

command="${0##*/}"
case "$command" in php|composer) ;; *) echo 'Invoke this launcher as php or composer.' >&2; exit 2 ;; esac
root="${SAMPLE_APP_PHP_CI_ROOT:?PHP CI repository root is required}"
state="${SAMPLE_APP_PHP_CI_STATE:?PHP CI state directory is required}"
image="${SAMPLE_APP_PHP_CI_IMAGE:?PHP CI image is required}"
if [[ ! "$image" =~ ^sha256:[0-9a-f]{64}$ ]]; then
echo 'PHP CI must use the inspected immutable image config ID.' >&2
exit 1
fi

options=(--rm --init --interactive --name "sample-app-php-ci-${command}-${BASHPID}"
--cpus 2 --memory 2g --pids-limit 512 --network host
--cap-drop ALL --security-opt no-new-privileges
--user "$(id -u):$(id -g)" --workdir "$PWD"
--mount "type=bind,source=$root,target=$root"
--mount "type=bind,source=$state,target=$state")

# Composer's guard is a composite action outside the repository checkout.
if [[ -n "${GITHUB_ACTION_PATH:-}" ]]; then
options+=(--mount "type=bind,source=$GITHUB_ACTION_PATH,target=$GITHUB_ACTION_PATH,readonly")
fi
# A local worktree has its Git metadata outside the source mount.
git_directory="$(git -C "$root" rev-parse --path-format=absolute --git-common-dir)"
if [[ "$git_directory" != "$root/"* ]]; then
options+=(--mount "type=bind,source=$git_directory,target=$git_directory,readonly")
fi

declare -A mounted=()
for variable in SSL_CERT_FILE CURL_CA_BUNDLE GIT_SSL_CAINFO COMPOSER_CAFILE \
REQUESTS_CA_BUNDLE PIP_CERT NPM_CONFIG_CAFILE CARGO_HTTP_CAINFO CARGO_HTTP_PROXY_CAINFO \
SSL_CERT_DIR GIT_SSL_CAPATH COMPOSER_CAPATH; do
if [[ -n "${!variable:-}" ]]; then
selected="${!variable}"
if [[ -z "${mounted[$selected]:-}" ]]; then
options+=(--mount "type=bind,source=$selected,target=$selected,readonly")
mounted[$selected]=1
fi
options+=(--env "$variable")
fi
done

# Pass the CI configuration and the playground's separate synthetic role credentials.
while IFS= read -r variable; do
case "$variable" in
APP_*|DB_*|SHARED_DB_*|REDIS_*|CACHE_*|QUEUE_*|SESSION_*|MAIL_*|BCRYPT_ROUNDS|\
COMPOSER_HOME|COMPOSER_CACHE_DIR|COMPOSER_MAX_PARALLEL_*|COMPOSER_IPRESOLVE|\
SAMPLE_APP_ROOT|SAMPLE_APP_PLAYGROUND_SCENARIO|SAMPLE_APP_PLAYGROUND_WORKFLOW_ID_PREFIX|\
DURABLE_WORKFLOW_RUNTIME_URL|DURABLE_WORKFLOW_SERVER_URL|DURABLE_WORKFLOW_NAMESPACE|\
DURABLE_WORKFLOW_TASK_QUEUE|DURABLE_WORKFLOW_WORKER_ID|\
DURABLE_WORKFLOW_WORKER_TOKEN|DURABLE_WORKFLOW_CLIENT_TOKEN|\
DW_CI_CA_SHA256|GITHUB_ACTIONS|CI|TMPDIR|TZ)
options+=(--env "$variable") ;;
esac
done < <(compgen -e)

# The host verifier discovers the launcher, but must inspect the real PHAR.
arguments=()
for argument in "$@"; do
if [[ "$argument" == "$state/bin/composer" ]]; then
argument=/usr/local/bin/composer
fi
arguments+=("$argument")
done
exec docker run "${options[@]}" "$image" "$command" "${arguments[@]}"
49 changes: 49 additions & 0 deletions tests/fixtures/sample-app-php-ci/799df847/setup-php-container.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env bash
set -euo pipefail

root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
minor="${1:?Usage: setup-php-container.sh 8.4|8.5}"
image="$(python3 -I -S -B - "$root/scripts/ci/php-container-images.json" "$minor" <<'PY'
import json,re,sys
images=json.load(open(sys.argv[1]))
image=images[sys.argv[2]]
assert re.fullmatch(r'php:8\.[45]\.\d+-cli-bookworm@sha256:[0-9a-f]{64}', image)
print(image)
PY
)"
test -f "$root/.central-apt-source/docker/apt/require-fixed-bookworm-apt.sh"
test "$(git -C "$root/.central-apt-source" rev-parse HEAD)" = 18783be6bef737cc778e4c7282a8797e39daa61a
echo '2a36a2417e8947357ea6f6cbc2f6c53a834f3c069f8013a34d6d861b7123d576 '"$root/.central-apt-source/docker/apt/require-fixed-bookworm-apt.sh" | sha256sum --check --strict

runtime="sample-app-php-ci:${minor}-${GITHUB_RUN_ID:-local}-${GITHUB_RUN_ATTEMPT:-1}"
docker build --file "$root/docker/php-ci/Dockerfile" --build-arg "PHP_IMAGE=$image" --tag "$runtime" "$root"
runtime_id="$(docker image inspect "$runtime" --format '{{.Id}}')"
docker run --rm --init --name "sample-app-php-ci-probe-${minor}-${GITHUB_RUN_ID:-local}" \
--cpus 1 --memory 512m --pids-limit 64 --network none "$runtime_id" \
php -r '
if (PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION !== $argv[1]) { throw new RuntimeException("The PHP matrix minor does not match the image."); }
foreach (["mbstring", "intl", "pdo_mysql", "redis", "bcmath", "gd", "zip", "curl", "pcntl"] as $extension) {
if (!extension_loaded($extension)) { throw new RuntimeException("Missing extension: ".$extension); }
}
if (extension_loaded("xdebug") || extension_loaded("pcov")) { throw new RuntimeException("Coverage must remain none."); }
if (php_ini_loaded_file() !== "/usr/local/etc/php/php.ini") { throw new RuntimeException("Production INI must be loaded."); }
echo json_encode(["php" => PHP_VERSION, "extensions" => get_loaded_extensions(), "ini" => php_ini_loaded_file(), "coverage" => "none"]), PHP_EOL;
' "$minor"
printf 'php_ci_image=%s\n' "$runtime_id"

state="${RUNNER_TEMP:?RUNNER_TEMP is required}/sample-app-php-ci"
mkdir -p "$state/bin" "$state/tmp" "$state/composer-home/cache"
ln -sf "$root/scripts/ci/run-php-container.sh" "$state/bin/php"
ln -sf "$root/scripts/ci/run-php-container.sh" "$state/bin/composer"
# Direct isolated execution keeps discovery from adding the checkout to sys.path.
SAMPLE_APP_PHP_CI_TEST_IMAGE="$runtime_id" SAMPLE_APP_PHP_CI_ROOT="$root" SAMPLE_APP_PHP_CI_STATE="$state" \
python3 -I -S -B "$root/tests/ci/test_php_container_tls.py" -v
{
echo "SAMPLE_APP_PHP_CI_IMAGE=$runtime_id"
echo "SAMPLE_APP_PHP_CI_ROOT=$root"
echo "SAMPLE_APP_PHP_CI_STATE=$state"
echo "COMPOSER_HOME=$state/composer-home"
echo "COMPOSER_CACHE_DIR=$state/composer-home/cache"
echo "TMPDIR=$state/tmp"
} >> "${GITHUB_ENV:?GITHUB_ENV is required}"
echo "$state/bin" >> "${GITHUB_PATH:?GITHUB_PATH is required}"
Loading
Loading