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

Add Rector in archive creation #135

Merged
merged 11 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
24 changes: 19 additions & 5 deletions .github/workflows/build-plugin-archive.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ jobs:
!./.github
run-build-tools:
name: Process build steps
timeout-minutes: 5
timeout-minutes: 10
runs-on: ubuntu-latest
needs: checkout-dependencies
env:
Expand All @@ -153,7 +153,7 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ inputs.PHP_VERSION_BUILD }}
tools: humbug/php-scoper:dev-main
tools: humbug/php-scoper:dev-main, rector
- name: Check optional Composer build tools
id: composer-tools
run: |
Expand All @@ -164,12 +164,12 @@ jobs:
echo "$EXIT"
exit 0
fi
jq '.extra | has("composer-asset-compiler")' < composer.json >/dev/null 2>&1
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")' < composer.json >/dev/null 2>&1
jq '.extra | has("wp-translation-downloader")' --exit-status < composer.json >/dev/null 2>&1
local EXIT=$?
echo "$EXIT"
}
Expand All @@ -178,9 +178,15 @@ jobs:
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

- name: Set up node cache mode
run: |
Expand Down Expand Up @@ -215,6 +221,11 @@ jobs:
composer global require inpsyde/wp-translation-downloader
composer wp-translation-downloader:download

- name: Run Rector
if: steps.composer-tools.outputs.rector == '0'
run: |
rector

- name: Run PHP Scoper
if: steps.composer-tools.outputs.php-scoper == '0'
run: |
Expand All @@ -223,7 +234,10 @@ jobs:
sed -i "s/'__composer_autoload_files'/\'__composer_autoload_files_${{ github.sha }}'/g" "build/vendor/composer/autoload_real.php"
- name: Move unchanged code to build directory
if: steps.composer-tools.outputs.php-scoper != '0'
run: mv * build 2>/dev/null
run: |
shopt -s extglob dotglob
mkdir build
mv !(build) build

- name: Set artifact name
id: set-artifact-name
Expand Down
10 changes: 6 additions & 4 deletions docs/archive-creation.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ To achieve that, the reusable workflow:
1. Installs dependencies (including dev-dependencies) defined in `composer.json`
2. Executes `inpsyde/composer-assets-compiler` if required & configured by the package
3. Executes `inpsyde/wp-translation-downloader` if required & configured by the package
4. Re-installs dependencies without dev-dependencies
5. Sets current commit hash and plugin version in the plugin's main file
6. Runs `wp dist-archive` to create the final archive (with builtin support for a `.distignore` file)
7. Uploads it as an artifact for download or further processing
4. Executes PHP-Scoper if configured by the package
5. Executes Rector if configured by the package
6. Re-installs dependencies without dev-dependencies
7. Sets current commit hash and plugin version in the plugin's main file
8. Runs `wp dist-archive` to create the final archive (with builtin support for a `.distignore` file)
9. Uploads it as an artifact for download or further processing

## Simple usage example:

Expand Down