Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MLP-2247] Fix/debug assets compiler on build plugin archive #175

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 4 additions & 46 deletions .github/workflows/build-plugin-archive.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,41 +165,7 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ inputs.PHP_VERSION_BUILD }}
tools: humbug/php-scoper, sniccowp/php-scoper-wordpress-excludes, rector

- name: Check optional Composer build tools
id: composer-tools
run: |
hasAssetConfig(){
test -f assets-compiler.json
local EXIT=$?
if [ ! $EXIT ]; then
echo "$EXIT"
exit 0
fi
jq '.extra | has("composer-asset-compiler")' --exit-status < composer.json >/dev/null 2>&1
local EXIT=$?
echo "$EXIT"
}
hasTranslateConfig(){
jq '.extra | has("wp-translation-downloader")' --exit-status < composer.json >/dev/null 2>&1
local EXIT=$?
echo "$EXIT"
}
hasScoperConfig(){
test -f scoper.inc.php
local EXIT=$?
echo "$EXIT"
}
hasRectorConfig(){
test -f rector.php
local EXIT=$?
echo "$EXIT"
}
echo "assets-compiler=$( hasAssetConfig )" >> $GITHUB_OUTPUT
echo "translation-downloader=$( hasTranslateConfig )" >> $GITHUB_OUTPUT
echo "php-scoper=$( hasScoperConfig )" >> $GITHUB_OUTPUT
echo "rector=$( hasRectorConfig )" >> $GITHUB_OUTPUT
tools: rector, php-scoper, sniccowp/php-scoper-wordpress-excludes, composer/installers, inpsyde/composer-assets-compiler, inpsyde/wp-translation-downloader

- name: Set up node cache mode
run: |
Expand All @@ -212,42 +178,34 @@ jobs:
fi

- name: Set up node
if: steps.composer-tools.outputs.assets-compiler == '0'
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.NODE_VERSION }}
registry-url: ${{ inputs.NPM_REGISTRY_DOMAIN }}
cache: ${{ env.NODE_CACHE_MODE }}

- name: Install and run Composer Asset Compiler
if: steps.composer-tools.outputs.assets-compiler == '0'
run: |
composer global config --no-plugins --no-interaction allow-plugins.inpsyde/composer-assets-compiler true
composer global require inpsyde/composer-assets-compiler
composer compile-assets ${{ inputs.COMPILE_ASSETS_ARGS }}

- name: Install and run WordPress Translation Downloader
if: steps.composer-tools.outputs.translation-downloader == '0'
run: |
composer global config --no-plugins --no-interaction allow-plugins.composer/installers true
composer global config --no-plugins --no-interaction allow-plugins.inpsyde/wp-translation-downloader true
composer global require inpsyde/wp-translation-downloader
composer wp-translation-downloader:download

- name: Run Rector
if: steps.composer-tools.outputs.rector == '0'
if: ${{ hashFiles('rector.php') != '' }}
run: |
rector

- name: Run PHP-Scoper
if: steps.composer-tools.outputs.php-scoper == '0'
if: ${{ hashFiles('scoper.inc.php') != '' }}
run: |
php-scoper add-prefix --force --output-dir=build
composer --working-dir=build dump-autoload -o
sed -i "s/'__composer_autoload_files'/\'__composer_autoload_files_${{ github.sha }}'/g" "build/vendor/composer/autoload_real.php"

- name: Move code to the `build/` directory
if: steps.composer-tools.outputs.php-scoper != '0'
if: ${{ hashFiles('scoper.inc.php') == '' }}
run: |
shopt -s extglob dotglob
mkdir build
Expand Down
Loading