diff --git a/.github/actions/install-tool/action.yaml b/.github/actions/install-tool/action.yaml new file mode 100644 index 00000000..69853cad --- /dev/null +++ b/.github/actions/install-tool/action.yaml @@ -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 diff --git a/.github/actions/install-vendor/action.yaml b/.github/actions/install-vendor/action.yaml new file mode 100644 index 00000000..e56ad5b3 --- /dev/null +++ b/.github/actions/install-vendor/action.yaml @@ -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 \ No newline at end of file diff --git a/.github/workflows/composer-root-version.yaml b/.github/workflows/composer-root-version.yaml index 446c57b3..1e4388cc 100644 --- a/.github/workflows/composer-root-version.yaml +++ b/.github/workflows/composer-root-version.yaml @@ -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 diff --git a/.github/workflows/e2e-tests.yaml b/.github/workflows/e2e-tests.yaml index e4eb7be5..daee4a51 100644 --- a/.github/workflows/e2e-tests.yaml +++ b/.github/workflows/e2e-tests.yaml @@ -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 @@ -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 diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index a7832547..ee0c79b1 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -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: @@ -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 @@ -90,6 +98,7 @@ jobs: needs: - cs - phpstan + - rector if: always() steps: - name: Successful run diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index b9120ec3..2df37985 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -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 diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 2797d122..4d5d75f6 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -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 diff --git a/Makefile b/Makefile index 2038dc5c..f1d8fa3f 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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) diff --git a/tests/Console/Command/AddPrefixCommandIntegrationTest.php b/tests/Console/Command/AddPrefixCommandIntegrationTest.php index 4f528a6d..724ea30b 100644 --- a/tests/Console/Command/AddPrefixCommandIntegrationTest.php +++ b/tests/Console/Command/AddPrefixCommandIntegrationTest.php @@ -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(...), ); } @@ -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, + ); + } } diff --git a/vendor-bin/rector/composer.json b/vendor-bin/rector/composer.json index ee0c8312..2d623534 100644 --- a/vendor-bin/rector/composer.json +++ b/vendor-bin/rector/composer.json @@ -1,5 +1,5 @@ { "require-dev": { - "rector/rector": ">=0.18.0" + "rector/rector": ">=0.18" } } diff --git a/vendor-bin/rector/composer.lock b/vendor-bin/rector/composer.lock index 3ee6a8cf..8a791475 100644 --- a/vendor-bin/rector/composer.lock +++ b/vendor-bin/rector/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "edb28a1f893cb167dc82cfe680c4fa27", + "content-hash": "ddf57e5c834bdc01bd0d08b45b9fb8dc", "packages": [], "packages-dev": [ {