11name : Setup PHP and Composer Dependencies
2- description : Setup PHP, warm Composer cache, mark safe directories , and install dependencies .
2+ description : Setup PHP, install Composer dependencies when available , and expose a deterministic DevTools runtime .
33
44inputs :
55 php-version :
@@ -29,6 +29,21 @@ inputs:
2929 description : Additional newline-separated directories to mark as safe for git.
3030 required : false
3131 default : ' '
32+ dev-tools-source-directory :
33+ description : Checked-out DevTools workflow source used to resolve the fallback runtime when the consumer does not install DevTools locally.
34+ required : false
35+ default : .dev-tools-actions
36+
37+ outputs :
38+ dev-tools-binary :
39+ description : Absolute path to the resolved DevTools binary.
40+ value : ${{ steps.expose-dev-tools.outputs.binary }}
41+ dev-tools-autoload :
42+ description : Absolute path to the runtime autoload file used by packaged workflow helpers.
43+ value : ${{ steps.expose-dev-tools.outputs.autoload }}
44+ dev-tools-source :
45+ description : Runtime source selected for this job, either `local` or `workflow`.
46+ value : ${{ steps.expose-dev-tools.outputs.source }}
3247
3348runs :
3449 using : composite
4055 extensions : ${{ inputs.extensions }}
4156 coverage : ${{ inputs.coverage }}
4257
43- - name : Cache Composer dependencies
44- uses : actions/cache@v5
45- with :
46- path : ${{ inputs.cache-dir }}
47- key : ${{ runner.os }}-composer-${{ inputs.php-version }}-${{ hashFiles('**/composer.lock') }}
48- restore-keys : |
49- ${{ runner.os }}-composer-${{ inputs.php-version }}-
50- ${{ runner.os }}-composer-
51-
5258 - name : Mark workspace as safe for git
5359 shell : bash
5460 env :
@@ -64,11 +70,48 @@ runs:
6470 done
6571 fi
6672
67- - name : Install dependencies
73+ - name : Detect consumer Composer manifest
74+ id : consumer-composer
6875 shell : bash
76+ run : |
77+ if [ -f composer.json ]; then
78+ echo "present=true" >> "$GITHUB_OUTPUT"
79+ else
80+ echo "present=false" >> "$GITHUB_OUTPUT"
81+ fi
82+
83+ - name : Install consumer dependencies
84+ if : steps.consumer-composer.outputs.present == 'true'
85+ uses : ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0
6986 env :
7087 COMPOSER_AUTH : ' {"github-oauth": {"github.com": "${{ github.token }}"} }'
7188 COMPOSER_CACHE_DIR : ${{ inputs.cache-dir }}
7289 COMPOSER_ROOT_VERSION : ${{ inputs.root-version }}
73- INPUT_INSTALL_OPTIONS : ${{ inputs.install-options }}
74- run : composer install ${INPUT_INSTALL_OPTIONS}
90+ with :
91+ composer-options : ${{ inputs.install-options }}
92+
93+ - name : Resolve DevTools runtime source
94+ id : resolve-dev-tools
95+ shell : bash
96+ env :
97+ INPUT_DEV_TOOLS_SOURCE_DIRECTORY : ${{ inputs.dev-tools-source-directory }}
98+ run : ${{ github.action_path }}/detect-dev-tools-runtime.sh
99+
100+ - name : Install fallback DevTools runtime
101+ if : steps.resolve-dev-tools.outputs.needs-fallback == 'true'
102+ uses : ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0
103+ env :
104+ COMPOSER_AUTH : ' {"github-oauth": {"github.com": "${{ github.token }}"} }'
105+ COMPOSER_CACHE_DIR : ${{ inputs.cache-dir }}
106+ with :
107+ working-directory : ${{ inputs.dev-tools-source-directory }}
108+ composer-options : --prefer-dist --no-plugins --no-scripts
109+ require-lock-file : ' true'
110+ custom-cache-suffix : dev-tools-runtime
111+
112+ - name : Expose DevTools runtime
113+ id : expose-dev-tools
114+ shell : bash
115+ env :
116+ INPUT_DEV_TOOLS_SOURCE_DIRECTORY : ${{ inputs.dev-tools-source-directory }}
117+ run : ${{ github.action_path }}/expose-dev-tools-runtime.sh
0 commit comments