mirror of
https://github.com/shivammathur/setup-php.git
synced 2026-12-06 09:50:56 +00:00
Compare commits
1
Commits
develop
...
florian/asan
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
abf2248889 |
@@ -44,6 +44,7 @@ Setup PHP with required extensions, php.ini configuration, code-coverage support
|
|||||||
- [Nightly Build Setup](#nightly-build-setup)
|
- [Nightly Build Setup](#nightly-build-setup)
|
||||||
- [Debug Build Setup](#debug-build-setup)
|
- [Debug Build Setup](#debug-build-setup)
|
||||||
- [Thread Safe Setup](#thread-safe-setup)
|
- [Thread Safe Setup](#thread-safe-setup)
|
||||||
|
- [ASAN Build Setup](#asan-build-setup)
|
||||||
- [Force Update Setup](#force-update-setup)
|
- [Force Update Setup](#force-update-setup)
|
||||||
- [Verbose Setup](#verbose-setup)
|
- [Verbose Setup](#verbose-setup)
|
||||||
- [Multi-Arch Setup](#multi-arch-setup)
|
- [Multi-Arch Setup](#multi-arch-setup)
|
||||||
@@ -531,6 +532,13 @@ On GitHub Actions you can assign the `setup-php` step an `id`, you can use the s
|
|||||||
- By default, it is set to `nts`.
|
- By default, it is set to `nts`.
|
||||||
- See [thread safe setup](#thread-safe-setup) for more info.
|
- See [thread safe setup](#thread-safe-setup) for more info.
|
||||||
|
|
||||||
|
#### `asan` (optional)
|
||||||
|
|
||||||
|
- Specify to set up PHP with AddressSanitizer (ASAN) for memory error detection.
|
||||||
|
- Accepts `true` or `false`.
|
||||||
|
- Only available for PHP 8.0 and above on Linux runners.
|
||||||
|
- See [ASAN build setup](#asan-build-setup) for more info.
|
||||||
|
|
||||||
#### `update` (optional)
|
#### `update` (optional)
|
||||||
|
|
||||||
- Specify to update PHP on the runner to the latest patch version.
|
- Specify to update PHP on the runner to the latest patch version.
|
||||||
@@ -652,6 +660,44 @@ jobs:
|
|||||||
phpts: ts # specify ts or nts
|
phpts: ts # specify ts or nts
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### ASAN Build Setup
|
||||||
|
|
||||||
|
> Set up PHP with AddressSanitizer (ASAN) for memory error detection.
|
||||||
|
|
||||||
|
- ASAN builds include both `AddressSanitizer` and `UndefinedBehaviorSanitizer (UBSan)`.
|
||||||
|
- Only available for PHP 8.0 and above on Linux based runners.
|
||||||
|
- Useful for detecting memory errors such as buffer overflows, use-after-free, and memory leaks.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
jobs:
|
||||||
|
run:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Setup PHP with ASAN
|
||||||
|
steps:
|
||||||
|
- name: Setup PHP
|
||||||
|
uses: shivammathur/setup-php@v2
|
||||||
|
with:
|
||||||
|
php-version: '8.5'
|
||||||
|
env:
|
||||||
|
asan: true
|
||||||
|
```
|
||||||
|
|
||||||
|
You can combine ASAN with other options:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- name: Setup PHP with ASAN and thread safety
|
||||||
|
uses: shivammathur/setup-php@v2
|
||||||
|
with:
|
||||||
|
php-version: '8.5'
|
||||||
|
env:
|
||||||
|
asan: true
|
||||||
|
phpts: ts
|
||||||
|
```
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> - ASAN builds have a performance overhead due to the instrumentation, so they are recommended for testing and debugging only.
|
||||||
|
> - You can configure ASAN behavior using the `ASAN_OPTIONS` environment variable in your test steps.
|
||||||
|
|
||||||
### Force Update Setup
|
### Force Update Setup
|
||||||
|
|
||||||
> Update to the latest patch of PHP versions.
|
> Update to the latest patch of PHP versions.
|
||||||
|
|||||||
@@ -124,7 +124,11 @@ add_devtools() {
|
|||||||
|
|
||||||
# Function to setup PHP from the shivammathur/php-builder builds.
|
# Function to setup PHP from the shivammathur/php-builder builds.
|
||||||
setup_php_builder() {
|
setup_php_builder() {
|
||||||
run_script "php-builder" "${runner:?}" "$version" "${debug:?}" "${ts:?}"
|
if [[ -n "${asan:-}" && "$version" =~ ${no_asan_builds:?} ]]; then
|
||||||
|
add_log "${cross:?}" "PHP" "ASAN is only supported for PHP 8.0+"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
run_script "php-builder" "${runner:?}" "$version" "${debug:?}" "${ts:?}" "${asan:-}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to setup PHP 5.3, PHP 5.4 and PHP 5.5.
|
# Function to setup PHP 5.3, PHP 5.4 and PHP 5.5.
|
||||||
@@ -237,7 +241,7 @@ update_php() {
|
|||||||
# Function to install PHP.
|
# Function to install PHP.
|
||||||
add_php() {
|
add_php() {
|
||||||
if [ "${runner:?}" = "self-hosted" ] || [ "${use_builds_cache:-true}" = "false" ]; then
|
if [ "${runner:?}" = "self-hosted" ] || [ "${use_builds_cache:-true}" = "false" ]; then
|
||||||
if [[ "$version" =~ ${php_builder_versions:?} || "$ts" = "zts" ]]; then
|
if [[ "$version" =~ ${php_builder_versions:?} || "$ts" = "zts" || -n "${asan:-}" ]]; then
|
||||||
setup_php_builder
|
setup_php_builder
|
||||||
else
|
else
|
||||||
add_packaged_php
|
add_packaged_php
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ export jit_versions="8.[0-9]"
|
|||||||
export php_builder_versions="8.[3-9]"
|
export php_builder_versions="8.[3-9]"
|
||||||
export nightly_versions="8.[7-9]"
|
export nightly_versions="8.[7-9]"
|
||||||
export xdebug3_versions="7.[2-4]|8.[0-9]"
|
export xdebug3_versions="7.[2-4]|8.[0-9]"
|
||||||
|
export no_asan_builds="5.[3-6]|7.[0-4]"
|
||||||
export latest="releases/latest/download"
|
export latest="releases/latest/download"
|
||||||
export github="https://github.com/shivammathur"
|
export github="https://github.com/shivammathur"
|
||||||
export jsdeliver="https://cdn.jsdelivr.net/gh/shivammathur"
|
export jsdeliver="https://cdn.jsdelivr.net/gh/shivammathur"
|
||||||
@@ -84,6 +85,7 @@ read_env() {
|
|||||||
update="${update:-${UPDATE:-false}}"
|
update="${update:-${UPDATE:-false}}"
|
||||||
[ "${debug:-${DEBUG:-false}}" = "true" ] && debug=debug && update=true || debug=release
|
[ "${debug:-${DEBUG:-false}}" = "true" ] && debug=debug && update=true || debug=release
|
||||||
[[ "${phpts:-${PHPTS:-nts}}" = "ts" || "${phpts:-${PHPTS:-nts}}" = "zts" ]] && ts=zts && update=true || ts=nts
|
[[ "${phpts:-${PHPTS:-nts}}" = "ts" || "${phpts:-${PHPTS:-nts}}" = "zts" ]] && ts=zts && update=true || ts=nts
|
||||||
|
[[ "${asan:-${ASAN:-false}}" = "true" ]] && asan=asan && update=true || asan=
|
||||||
fail_fast="${fail_fast:-${FAIL_FAST:-false}}"
|
fail_fast="${fail_fast:-${FAIL_FAST:-false}}"
|
||||||
use_builds_cache="${use_builds_cache:-${use_package_cache:-}}"
|
use_builds_cache="${use_builds_cache:-${use_package_cache:-}}"
|
||||||
[[ ( -z "$ImageOS" && -z "$ImageVersion" ) ||
|
[[ ( -z "$ImageOS" && -z "$ImageVersion" ) ||
|
||||||
@@ -120,6 +122,7 @@ read_env() {
|
|||||||
export runner
|
export runner
|
||||||
export update
|
export update
|
||||||
export ts
|
export ts
|
||||||
|
export asan
|
||||||
export tool_path_dir
|
export tool_path_dir
|
||||||
export tool_cache_path_dir
|
export tool_cache_path_dir
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user