Skip to content

Commit a9af34f

Browse files
mmaymoo-samarastyrann0usBiontzhyian
authored
[MLP-2247] Fix/debug assets compiler on build plugin archive (#175)
* Add logs * Log before the condition * Remove lines to isolate problem * Return early if assets-compiler exists * Rename variables for clarity * Remove conditionals to add tools * Rename step * Use another syntax * Use an id instead of name * Rollback this branch as is in use * Remove conditional tools * Conditionally run php-scoper if there is no config it creates it and runs, we need to avoid that * Continue on error * Check the conclusion instead * Check with failure() * Use outputs * Use hashFiles() * Remove composer config * Try verbose to see why translate fails * Try v2 as verbose was not failing * Try verbose again without config * Rollback removing the config * Add composer/installers to the list of tools & remove leftover --------- Co-authored-by: Orestis Samaras <o.samaras@inpsyde.com> Co-authored-by: Philipp Bammes <8144115+tyrann0us@users.noreply.github.com> Co-authored-by: Moritz Meißelbach <m.meisselbach@inpsyde.com> Co-authored-by: Oleksandr Zhyian <oleksandr.zhyian@gmail.com>
1 parent 2b44fc5 commit a9af34f

File tree

1 file changed

+6
-52
lines changed

1 file changed

+6
-52
lines changed

.github/workflows/build-plugin-archive.yml

Lines changed: 6 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -164,41 +164,7 @@ jobs:
164164
uses: shivammathur/setup-php@v2
165165
with:
166166
php-version: ${{ inputs.PHP_VERSION_BUILD }}
167-
tools: humbug/php-scoper, sniccowp/php-scoper-wordpress-excludes, rector
168-
169-
- name: Check optional Composer build tools
170-
id: composer-tools
171-
run: |
172-
hasAssetConfig(){
173-
test -f assets-compiler.json
174-
local EXIT=$?
175-
if [ ! $EXIT ]; then
176-
echo "$EXIT"
177-
exit 0
178-
fi
179-
jq '.extra | has("composer-asset-compiler")' --exit-status < composer.json >/dev/null 2>&1
180-
local EXIT=$?
181-
echo "$EXIT"
182-
}
183-
hasTranslateConfig(){
184-
jq '.extra | has("wp-translation-downloader")' --exit-status < composer.json >/dev/null 2>&1
185-
local EXIT=$?
186-
echo "$EXIT"
187-
}
188-
hasScoperConfig(){
189-
test -f scoper.inc.php
190-
local EXIT=$?
191-
echo "$EXIT"
192-
}
193-
hasRectorConfig(){
194-
test -f rector.php
195-
local EXIT=$?
196-
echo "$EXIT"
197-
}
198-
echo "assets-compiler=$( hasAssetConfig )" >> $GITHUB_OUTPUT
199-
echo "translation-downloader=$( hasTranslateConfig )" >> $GITHUB_OUTPUT
200-
echo "php-scoper=$( hasScoperConfig )" >> $GITHUB_OUTPUT
201-
echo "rector=$( hasRectorConfig )" >> $GITHUB_OUTPUT
167+
tools: rector, php-scoper, sniccowp/php-scoper-wordpress-excludes, composer/installers, inpsyde/composer-assets-compiler, inpsyde/wp-translation-downloader
202168

203169
- name: Set up node cache mode
204170
run: |
@@ -211,7 +177,6 @@ jobs:
211177
fi
212178
213179
- name: Set up node
214-
if: steps.composer-tools.outputs.assets-compiler == '0'
215180
uses: actions/setup-node@v4
216181
env:
217182
NODE_OPTIONS: ${{ inputs.NODE_OPTIONS }}
@@ -221,32 +186,21 @@ jobs:
221186
registry-url: ${{ inputs.NPM_REGISTRY_DOMAIN }}
222187
cache: ${{ env.NODE_CACHE_MODE }}
223188

224-
- name: Install and run Composer Asset Compiler
225-
if: steps.composer-tools.outputs.assets-compiler == '0'
226-
env:
227-
COMPOSER_AUTH: '${{ secrets.COMPOSER_AUTH_JSON }}'
189+
- name: Run Composer Asset Compiler
228190
run: |
229-
composer global config --no-plugins --no-interaction allow-plugins.inpsyde/composer-assets-compiler true
230-
composer global require inpsyde/composer-assets-compiler
231191
composer compile-assets ${{ inputs.COMPILE_ASSETS_ARGS }}
232192
233-
- name: Install and run WordPress Translation Downloader
234-
if: steps.composer-tools.outputs.translation-downloader == '0'
235-
env:
236-
COMPOSER_AUTH: '${{ secrets.COMPOSER_AUTH_JSON }}'
193+
- name: Run WordPress Translation Downloader
237194
run: |
238-
composer global config --no-plugins --no-interaction allow-plugins.composer/installers true
239-
composer global config --no-plugins --no-interaction allow-plugins.inpsyde/wp-translation-downloader true
240-
composer global require inpsyde/wp-translation-downloader
241195
composer wp-translation-downloader:download
242196
243197
- name: Run Rector
244-
if: steps.composer-tools.outputs.rector == '0'
198+
if: ${{ hashFiles('rector.php') != '' }}
245199
run: |
246200
rector
247201
248202
- name: Run PHP-Scoper ensuring isolated file autoloading
249-
if: steps.composer-tools.outputs.php-scoper == '0'
203+
if: ${{ hashFiles('scoper.inc.php') != '' }}
250204
run: |
251205
php-scoper add-prefix --force --output-dir=build
252206
composer --working-dir=build dump-autoload -o
@@ -256,7 +210,7 @@ jobs:
256210
sed -i "s/'__composer_autoload_files'/\'__composer_autoload_files_${{ github.sha }}'/g" "build/vendor/composer/autoload_real.php"
257211
258212
- name: Move code to the `build/` directory
259-
if: steps.composer-tools.outputs.php-scoper != '0'
213+
if: ${{ hashFiles('scoper.inc.php') == '' }}
260214
run: |
261215
shopt -s extglob dotglob
262216
mkdir build

0 commit comments

Comments
 (0)