Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into chore/php82
Browse files Browse the repository at this point in the history
  • Loading branch information
theofidry committed Nov 18, 2023
2 parents 91be936 + 6a3a69e commit 038609a
Show file tree
Hide file tree
Showing 11 changed files with 117 additions and 81 deletions.
25 changes: 25 additions & 0 deletions .github/actions/install-tool/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: 'Install a vendor-bin tool'

description: >
Install a tool installed via bamarni/composer-bin-plugin and runs the associated Makefile command to ensure the
target is up to date.
inputs:
vendor-bin-tool:
required: true
type: string
makefile-command:
required: true
type: string

runs:
using: composite
steps:
- name: Install PHP-CS-Fixer
uses: ramsey/composer-install@v2
with:
working-directory: 'vendor-bin/${{ inputs.vendor-bin-tool }}'

- name: Ensure PHP-CS-Fixer Makefile target is up to date
run: make ${{ inputs.makefile-command }}
shell: sh
17 changes: 17 additions & 0 deletions .github/actions/install-vendor/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: 'Install Composer dependencies'

description: >
Install the dependencies installed via Composer.
runs:
using: composite
steps:
# https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions#setting-an-environment-variable
- name: Configure composer root version
run: |
. ./.composer-root-version
echo "COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION}" >> $GITHUB_ENV
shell: sh

- name: Install Composer dependencies
uses: ramsey/composer-install@v2
18 changes: 5 additions & 13 deletions .github/workflows/composer-root-version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,17 @@ jobs:
tools: composer
coverage: none

# https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions#setting-an-environment-variable
- name: Configure composer root version
run: |
source .composer-root-version
echo "COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION}" >> $GITHUB_ENV
- name: Install the Composer (root) dependencies
uses: ramsey/composer-install@v2
- name: Install Composer dependencies
uses: ./.github/actions/install-vendor

- name: Ensure that the root dependencies are updated correctly
run: make vendor_install

- name: Install PHP-CS-Fixer
uses: ramsey/composer-install@v2
uses: ./.github/actions/install-tool
with:
working-directory: 'vendor-bin/php-cs-fixer'

- name: Ensure that PHP-CS-Fixer dependencies are updated correctly
run: make php_cs_fixer_install
vendor-bin-tool: php-cs-fixer
makefile-command: php_cs_fixer_install

- name: Install the Composer dependencies
uses: ramsey/composer-install@v2
Expand Down
15 changes: 2 additions & 13 deletions .github/workflows/e2e-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,8 @@ jobs:
tools: composer
coverage: none

# https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions#setting-an-environment-variable
- name: Configure composer root version
run: |
source .composer-root-version
echo "COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION}" >> $GITHUB_ENV
- name: Install Composer dependencies
uses: ramsey/composer-install@v2
uses: ./.github/actions/install-vendor

- name: Build PHAR
run: make build
Expand Down Expand Up @@ -121,13 +115,8 @@ jobs:
# This is necessary when installing a tool with a specific version
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Configure composer root version
run: |
source .composer-root-version
echo "COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION}" >> $GITHUB_ENV
- name: Install Composer dependencies
uses: ramsey/composer-install@v2
uses: ./.github/actions/install-vendor

- name: Retrieve built PHAR
uses: actions/download-artifact@v3
Expand Down
57 changes: 33 additions & 24 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,14 @@ jobs:
tools: composer
coverage: none

# https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions#setting-an-environment-variable
- name: Configure composer root version
run: |
source .composer-root-version
echo "COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION}" >> $GITHUB_ENV
- name: Install Composer dependencies
uses: ramsey/composer-install@v2
uses: ./.github/actions/install-vendor

- name: Install PHP-CS-Fixer
uses: ramsey/composer-install@v2
uses: ./.github/actions/install-tool
with:
working-directory: 'vendor-bin/php-cs-fixer'

- name: Ensure PHP-CS-Fixer Makefile target is up to date
run: make php_cs_fixer_install
vendor-bin-tool: php-cs-fixer
makefile-command: php_cs_fixer_install

- run: make cs_lint
phpstan:
Expand All @@ -60,24 +52,40 @@ jobs:
tools: composer
coverage: none

# https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions#setting-an-environment-variable
- name: Configure composer root version
run: |
source .composer-root-version
echo "COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION}" >> $GITHUB_ENV
- name: Install Composer dependencies
uses: ramsey/composer-install@v2
uses: ./.github/actions/install-vendor

- name: Install PHPStan
uses: ramsey/composer-install@v2
uses: ./.github/actions/install-tool
with:
working-directory: 'vendor-bin/phpstan'

- name: Ensure PHPStan Makefile target is up to date
run: make phpstan_install
vendor-bin-tool: phpstan
makefile-command: phpstan_install

- run: make phpstan
rector:
runs-on: ubuntu-latest
name: Rector
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
tools: composer
coverage: none

- name: Install Composer dependencies
uses: ./.github/actions/install-vendor

- name: Install Rector
uses: ./.github/actions/install-tool
with:
vendor-bin-tool: rector
makefile-command: rector_install

- run: make rector_lint

# This is a "trick", a meta task which does not change, and we can use in
# the protected branch rules as opposed to the E2E tests one above which
Expand All @@ -90,6 +98,7 @@ jobs:
needs:
- cs
- phpstan
- rector
if: always()
steps:
- name: Successful run
Expand Down
8 changes: 1 addition & 7 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,8 @@ jobs:
tools: composer
coverage: none

# https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions#setting-an-environment-variable
- name: Configure composer root version
run: |
source .composer-root-version
echo "COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION}" >> $GITHUB_ENV
- name: Install Composer dependencies
uses: ramsey/composer-install@v2
uses: ./.github/actions/install-vendor

- name: Configure the PHP platform
run: composer config platform.php $(php -r 'echo phpversion();') && composer update --lock
Expand Down
8 changes: 1 addition & 7 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,8 @@ jobs:
tools: composer
coverage: none

# https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions#setting-an-environment-variable
- name: Configure composer root version
run: |
source .composer-root-version
echo "COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION}" >> $GITHUB_ENV
- name: Install Composer dependencies
uses: ramsey/composer-install@v2
uses: ./.github/actions/install-vendor

- name: Run tests
run: make phpunit
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ phpstan: $(PHPSTAN_BIN)

.PHONY: autoreview
autoreview: ## Runs the AutoReview checks
autoreview: cs_lint phpstan covers_validator
autoreview: cs_lint phpstan rector_lint covers_validator

.PHONY: test
test: ## Runs all the tests
Expand Down Expand Up @@ -274,6 +274,9 @@ vendor-bin/phpstan/composer.lock: vendor-bin/phpstan/composer.json
@echo "$(@) is not up to date. You may want to run the following command:"
@echo "$$ composer bin phpstan update --lock && touch -c $(@)"

.PHONY: rector_install
rector_install: $(RECTOR_BIN)

$(RECTOR_BIN): vendor-bin/rector/vendor
touch -c $@
vendor-bin/rector/vendor: vendor-bin/rector/composer.lock $(COMPOSER_BIN_PLUGIN_VENDOR)
Expand Down
41 changes: 27 additions & 14 deletions tests/Console/Command/AddPrefixCommandIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,24 +145,11 @@ public function test_scope_in_normal_mode(): void

EOF;

$extraNormalization = static fn (string $display) => str_replace(
[
'
1/4 [▓▓▓▓▓▓▓░░░░░░░░░░░░░░░░░░░░░] 25%',
'
2/4 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░░░░░░░░░] 50%',
'
3/4 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░░] 75%',
],
['', '', ''],
$display,
);

$this->assertExpectedOutput(
$expected,
0,
$this->createDisplayNormalizer(),
$extraNormalization,
self::replaceIntermediateProgressBarSteps(...),
);
}

Expand Down Expand Up @@ -349,4 +336,30 @@ static function (array $collectedFiles, SplFileInfo $file) use ($dir): array {
[],
);
}

private static function replaceIntermediateProgressBarSteps(string $output): string
{
return str_replace(
[
<<<'EOF'
1/5 [▓▓▓▓▓░░░░░░░░░░░░░░░░░░░░░░░] 20%
EOF,
<<<'EOF'
2/5 [▓▓▓▓▓▓▓▓▓▓░░░░░░░░░░░░░░░░░░] 40%
EOF,
<<<'EOF'
3/5 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░░░░░] 60%
EOF,
<<<'EOF'
4/5 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░] 80%
EOF,
],
['', '', ''],
$output,
);
}
}
2 changes: 1 addition & 1 deletion vendor-bin/rector/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"require-dev": {
"rector/rector": ">=0.18.0"
"rector/rector": ">=0.18"
}
}
2 changes: 1 addition & 1 deletion vendor-bin/rector/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 038609a

Please sign in to comment.