mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 11:51:07 +07:00
Add support to use existing COMPOSER_PROCESS_TIMEOUT
This commit is contained in:
parent
1a5ac4aa9a
commit
a6ce3f5633
10
README.md
10
README.md
@ -307,6 +307,16 @@ These tools can be set up globally using the `tools` input. It accepts a string
|
||||
- If you do not want to use all your dev-dependencies in workflow, you can run composer with `--no-dev` and install required tools using `tools` input to speed up your workflow.
|
||||
- By default, `COMPOSER_NO_INTERACTION` is set to `1` and `COMPOSER_PROCESS_TIMEOUT` is set to `0`. In effect, this means that Composer commands in your scripts do not need to specify `--no-interaction`.
|
||||
- Also, `COMPOSER_NO_AUDIT` is set to `1`. So if you want to audit your dependencies for security vulnerabilities, it is recommended to add a `composer audit` step before you install them.
|
||||
- If you want to set a different `COMPOSER_PROCESS_TIMEOUT`, you can set it in your workflow file using the `env` keyword.
|
||||
|
||||
```yaml
|
||||
- name: Setup PHP with composer and custom process timeout
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '8.3'
|
||||
env:
|
||||
COMPOSER_PROCESS_TIMEOUT: 300
|
||||
```
|
||||
|
||||
## :signal_strength: Coverage Support
|
||||
|
||||
|
@ -23,7 +23,7 @@ Function Edit-ComposerConfig() {
|
||||
if (-not(Test-Path $composer_json)) {
|
||||
Set-Content -Path $composer_json -Value "{}"
|
||||
}
|
||||
Add-EnvPATH $src\configs\composer.env
|
||||
Set-ComposerEnv
|
||||
Add-Path $composer_bin
|
||||
Set-ComposerAuth
|
||||
}
|
||||
@ -52,6 +52,14 @@ Function Set-ComposerAuth() {
|
||||
}
|
||||
}
|
||||
|
||||
# Function to set composer environment variables.
|
||||
Function Set-ComposerEnv() {
|
||||
if ($env:COMPOSER_PROCESS_TIMEOUT) {
|
||||
(Get-Content $src\configs\composer.env -Raw) -replace '(?m)^COMPOSER_PROCESS_TIMEOUT=.*$', "COMPOSER_PROCESS_TIMEOUT=$env:COMPOSER_PROCESS_TIMEOUT" | Set-Content $src\configs\composer.env
|
||||
}
|
||||
Add-EnvPATH $src\configs\composer.env
|
||||
}
|
||||
|
||||
# Function to extract tool version.
|
||||
Function Get-ToolVersion() {
|
||||
Param (
|
||||
|
@ -42,7 +42,7 @@ configure_composer() {
|
||||
echo '{}' | tee "$composer_json" >/dev/null
|
||||
chmod 644 "$composer_json"
|
||||
fi
|
||||
add_env_path "${src:?}"/configs/composer.env
|
||||
set_composer_env
|
||||
add_path "$composer_bin"
|
||||
set_composer_auth
|
||||
}
|
||||
@ -68,6 +68,16 @@ set_composer_auth() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to set composer environment variables.
|
||||
set_composer_env() {
|
||||
composer_env="${src:?}"/configs/composer.env
|
||||
if [ -n "$COMPOSER_PROCESS_TIMEOUT" ]; then
|
||||
sed_arg="s/COMPOSER_PROCESS_TIMEOUT.*/COMPOSER_PROCESS_TIMEOUT=$COMPOSER_PROCESS_TIMEOUT/"
|
||||
sed -i "$sed_arg" "$composer_env" 2>/dev/null || sed -i '' "$sed_arg" "$composer_env"
|
||||
fi
|
||||
add_env_path "$composer_env"
|
||||
}
|
||||
|
||||
# Helper function to configure tools.
|
||||
add_tools_helper() {
|
||||
tool=$1
|
||||
|
Loading…
Reference in New Issue
Block a user