Merge 4c9c2be10e3e6b80d46087df6c874be7e315e072 into 5efa2a774eb6c55954af5652a1f947afbc8dd282
This commit is contained in:
commit
fb090fab02
45
README.md
45
README.md
@ -41,6 +41,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)
|
||||||
@ -463,6 +464,13 @@ Disable coverage for these reasons:
|
|||||||
- Accepts a `string` in csv-format. For example: `phpunit, phpcs`
|
- Accepts a `string` in csv-format. For example: `phpunit, phpcs`
|
||||||
- See [tools support](#wrench-tools-support) for tools supported.
|
- See [tools support](#wrench-tools-support) for tools supported.
|
||||||
|
|
||||||
|
#### `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.
|
||||||
|
|
||||||
#### `github-token` (optional)
|
#### `github-token` (optional)
|
||||||
|
|
||||||
- Specify the GitHub token to use for authentication.
|
- Specify the GitHub token to use for authentication.
|
||||||
@ -621,6 +629,43 @@ 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 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'
|
||||||
|
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'
|
||||||
|
asan: true
|
||||||
|
env:
|
||||||
|
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.
|
||||||
|
|||||||
@ -27,6 +27,9 @@ inputs:
|
|||||||
tools:
|
tools:
|
||||||
description: 'Setup popular tools globally.'
|
description: 'Setup popular tools globally.'
|
||||||
required: false
|
required: false
|
||||||
|
asan:
|
||||||
|
description: 'Setup PHP with Address Sanitizer (ASAN). PHP 8.0+ on Linux only.'
|
||||||
|
required: false
|
||||||
github-token:
|
github-token:
|
||||||
description: 'GitHub token to use for authentication.'
|
description: 'GitHub token to use for authentication.'
|
||||||
default: ${{ github.token }}
|
default: ${{ github.token }}
|
||||||
|
|||||||
2
dist/index.js
vendored
2
dist/index.js
vendored
File diff suppressed because one or more lines are too long
@ -53,6 +53,7 @@ export async function getScript(os: string): Promise<string> {
|
|||||||
export async function setEnv(): Promise<void> {
|
export async function setEnv(): Promise<void> {
|
||||||
process.env['fail_fast'] = await utils.getInput('fail-fast', false);
|
process.env['fail_fast'] = await utils.getInput('fail-fast', false);
|
||||||
process.env['GITHUB_TOKEN'] ??= await utils.getInput('github-token', false);
|
process.env['GITHUB_TOKEN'] ??= await utils.getInput('github-token', false);
|
||||||
|
process.env['ASAN'] = await utils.getInput('asan', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -114,7 +114,7 @@ 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:?}"
|
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.
|
||||||
@ -186,7 +186,15 @@ update_php() {
|
|||||||
|
|
||||||
# Function to install PHP.
|
# Function to install PHP.
|
||||||
add_php() {
|
add_php() {
|
||||||
if [ "${runner:?}" = "self-hosted" ] || [ "${use_package_cache:-true}" = "false" ]; then
|
# ASAN is only supported for PHP 8.0+
|
||||||
|
if [[ -n "${asan:-}" && ! "$version" =~ ^8\. ]]; then
|
||||||
|
add_log "${cross:?}" "PHP" "ASAN is only supported for PHP 8.0+"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
# ASAN builds are only available from php-builder
|
||||||
|
if [[ -n "${asan:-}" ]]; then
|
||||||
|
setup_php_builder
|
||||||
|
elif [ "${runner:?}" = "self-hosted" ] || [ "${use_package_cache:-true}" = "false" ]; then
|
||||||
if [[ "$version" =~ ${php_builder_versions:?} || "$ts" = "zts" ]]; then
|
if [[ "$version" =~ ${php_builder_versions:?} || "$ts" = "zts" ]]; then
|
||||||
setup_php_builder
|
setup_php_builder
|
||||||
else
|
else
|
||||||
|
|||||||
@ -52,6 +52,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}}"
|
||||||
[[ ( -z "$ImageOS" && -z "$ImageVersion" ) ||
|
[[ ( -z "$ImageOS" && -z "$ImageVersion" ) ||
|
||||||
( -n "$RUNNER_ENVIRONMENT" && "$RUNNER_ENVIRONMENT" = "self-hosted" ) ||
|
( -n "$RUNNER_ENVIRONMENT" && "$RUNNER_ENVIRONMENT" = "self-hosted" ) ||
|
||||||
@ -78,6 +79,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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user