From 89e87b6766295486d8867b42480928decbd61061 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= Date: Thu, 19 Oct 2023 00:38:45 +0200 Subject: [PATCH 01/22] Draft: debgu --- .github/workflows/phar-debug.yaml | 34 +++++++++++++++++++ .../Command/Composer/ComposerCheckVersion.php | 11 ++++++ 2 files changed, 45 insertions(+) create mode 100644 .github/workflows/phar-debug.yaml diff --git a/.github/workflows/phar-debug.yaml b/.github/workflows/phar-debug.yaml new file mode 100644 index 000000000..365a1b7bb --- /dev/null +++ b/.github/workflows/phar-debug.yaml @@ -0,0 +1,34 @@ +name: PHAR DEBUG + +on: + push: + branches: [ "main" ] + pull_request: ~ + +permissions: + contents: read + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Cache Composer packages + id: composer-cache + uses: actions/cache@v3 + with: + path: vendor + key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-php- + - name: Install dependencies + run: composer install --prefer-dist --no-progress + + - name: Dump env + run: bin/box composer:check-version + + - name: Dump env + run: php bin/box composer:check-version \ No newline at end of file diff --git a/src/Console/Command/Composer/ComposerCheckVersion.php b/src/Console/Command/Composer/ComposerCheckVersion.php index 1bc88ade7..878d4defe 100644 --- a/src/Console/Command/Composer/ComposerCheckVersion.php +++ b/src/Console/Command/Composer/ComposerCheckVersion.php @@ -18,6 +18,8 @@ use Fidry\Console\ExitCode; use Fidry\Console\Input\IO; use KevinGH\Box\Composer\ComposerOrchestrator; +use function ini_get; +use function KevinGH\Box\check_php_settings; /** * @private @@ -42,8 +44,17 @@ public function getConfiguration(): Configuration protected function orchestrate(ComposerOrchestrator $composerOrchestrator, IO $io): int { + check_php_settings($io); $composerOrchestrator->checkVersion(); + if (!class_exists('Phar', false)) { + dd([ + 'get_declared_classes' => get_declared_classes(), + 'phpversion' => phpversion(), + 'get_loaded_extensions' => get_loaded_extensions(), + ]); + } + return ExitCode::SUCCESS; } } From 467f5eee6e474dfcf92e0d59cf373f99b0882ca2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= Date: Thu, 19 Oct 2023 00:39:40 +0200 Subject: [PATCH 02/22] remvoe extract workflows --- .github/workflows/auto-review.yaml | 130 -------- .github/workflows/docker.yaml | 96 ------ .github/workflows/e2e-tests.yaml | 206 ------------ .github/workflows/gh-pages.yaml | 61 ---- .github/workflows/release.yaml | 203 ------------ .github/workflows/requirement-checker.yaml | 354 --------------------- .github/workflows/security.yaml | 39 --- .github/workflows/unit-tests.yaml | 165 ---------- 8 files changed, 1254 deletions(-) delete mode 100644 .github/workflows/auto-review.yaml delete mode 100644 .github/workflows/docker.yaml delete mode 100644 .github/workflows/e2e-tests.yaml delete mode 100644 .github/workflows/gh-pages.yaml delete mode 100644 .github/workflows/release.yaml delete mode 100644 .github/workflows/requirement-checker.yaml delete mode 100644 .github/workflows/security.yaml delete mode 100644 .github/workflows/unit-tests.yaml diff --git a/.github/workflows/auto-review.yaml b/.github/workflows/auto-review.yaml deleted file mode 100644 index ce100179b..000000000 --- a/.github/workflows/auto-review.yaml +++ /dev/null @@ -1,130 +0,0 @@ -name: AutoReview - -on: - push: - branches: [ main ] - pull_request: ~ - schedule: - # Do not make it the first of the month and/or midnight since it is a very busy time - - cron: "* 10 5 * *" - -# See https://stackoverflow.com/a/72408109 -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -env: - TERM: xterm - -jobs: - lint-cs: - runs-on: ubuntu-latest - name: Lint CS - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.1' - tools: composer - coverage: none - - - name: Install Composer dependencies - uses: ramsey/composer-install@v2 - - - name: Ensure that the make target is up to date - run: make _vendor_install - - - name: Install PHP-CS-Fixer - uses: ramsey/composer-install@v2 - with: - working-directory: vendor-bin/php-cs-fixer - - - name: Ensure that the PHP-CS-Fixer make target is up to date - run: make php_cs_fixer_install - - - run: make root_cs_lint - - composer-validate: - runs-on: ubuntu-latest - name: Composer Validate - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.1' - tools: composer - coverage: none - - - run: make composer_validate - - box-config-validate: - runs-on: ubuntu-latest - name: Box Validate - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.1' - tools: composer - coverage: none - - - name: Install Composer dependencies - uses: ramsey/composer-install@v2 - - - name: Ensure that the make target is up to date - run: make _vendor_install - - - run: make box_validate - - autoreview-test: - runs-on: ubuntu-latest - name: AutoReview Tests - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.1' - tools: composer - coverage: none - - - name: Install Composer dependencies - uses: ramsey/composer-install@v2 - - - name: Ensure that the make target is up to date - run: make _vendor_install - - - run: make phpunit_autoreview - - - # This is a "trick", a meta task which does not change, and we can use in - # the protected branch rules as opposed to the tests one above which - # may change regularly. - validate-autoreview: - name: AutoReview tests status - runs-on: ubuntu-latest - needs: - - lint-cs - - composer-validate - - box-config-validate - - autoreview-test - if: always() - steps: - - name: Successful run - if: ${{ !(contains(needs.*.result, 'failure')) }} - run: exit 0 - - - name: Failing run - if: ${{ contains(needs.*.result, 'failure') }} - run: exit 1 diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml deleted file mode 100644 index 4ab3da306..000000000 --- a/.github/workflows/docker.yaml +++ /dev/null @@ -1,96 +0,0 @@ -name: Docker - -on: - push: - branches: [ main ] - pull_request: ~ - schedule: - # Do not make it the first of the month and/or midnight since it is a very busy time - - cron: "* 10 5 * *" - release: - types: [ created ] - -# See https://stackoverflow.com/a/72408109 -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -env: - TERM: xterm - -permissions: - contents: read - packages: write - -jobs: - docker-build: - runs-on: ubuntu-20.04 - name: Publish the Docker image ${{ matrix.name }} - # See https://github.com/phpstan/phpstan/commit/4a535193101975e50fbaeea92ca6eca8c7a349b1 - concurrency: docker-build-${{ github.ref }}-${{ matrix.docker-file }} - strategy: - fail-fast: false - matrix: - include: - - name: PHP 7.2.5 - docker-file: .docker/php725 - image-tag: ghcr.io/box-project/box_php725 - - name: PHP 8.1 - docker-file: .docker/php81 - image-tag: ghcr.io/box-project/box_php81 - - name: PHP 8.1 (Xdebug) - docker-file: .docker/php81_xdebug - image-tag: ghcr.io/box-project/box_php81_xdebug - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Login to GitHub Container Registry - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build and export to Docker - uses: docker/build-push-action@v3 - with: - context: . - file: ${{ matrix.docker-file }} - platforms: linux/amd64 - tags: ${{ matrix.image-tag }} - load: true - - - name: Test the image - run: docker run --rm ${{ matrix.image-tag }} php --version - - - name: Build and push - if: ${{ github.ref_name == 'main' }} - uses: docker/build-push-action@v3 - with: - context: . - file: ${{ matrix.docker-file }} - platforms: linux/amd64 - tags: ${{ matrix.image-tag }} - push: true - # See https://github.com/phpstan/phpstan/pull/7373/files - # for the scope. - cache-from: type=gha, scope=${{ github.workflow }} - cache-to: type=gha, scope=${{ github.workflow }} - - # This is a "trick", a meta task which does not change, and we can use in - # the protected branch rules as opposed to the tests one above which - # may change regularly. - validate-images: - name: Docker status - runs-on: ubuntu-latest - needs: docker-build - if: always() - steps: - - run: exit 0 diff --git a/.github/workflows/e2e-tests.yaml b/.github/workflows/e2e-tests.yaml deleted file mode 100644 index 40f4b54ae..000000000 --- a/.github/workflows/e2e-tests.yaml +++ /dev/null @@ -1,206 +0,0 @@ -name: End-to-End Tests - -on: - push: - branches: [ main ] - pull_request: ~ - schedule: - # Do not make it the first of the month and/or midnight since it is a very busy time - - cron: "* 10 5 * *" - release: - types: [ created ] - -# See https://stackoverflow.com/a/72408109 -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -env: - POLLING_INTERVALS_SEC: 30 - SLEEP_TIME_SEC: 60s - TERM: xterm - -jobs: - wait-for-phar-and-docker-images: - runs-on: ubuntu-latest - name: Wait for the PHAR & Docker images - steps: - # Reduce the amount polling done without increasing the polling internal too much. - - name: Sleep - run: sleep ${{ env.SLEEP_TIME_SEC }} - shell: bash - - # I could not make this workflow work with a on.workflow_run. Hence instead of adding this - # wait step for _every_ e2e job, which will block more runners, we wait in one and only one - # runner. - - name: Wait for the PHAR to be built - uses: fountainhead/action-wait-for-check@v1.1.0 - with: - checkName: Build PHAR - ref: ${{ github.event.pull_request.head.sha || github.sha }} - token: ${{ secrets.GITHUB_TOKEN }} - intervalSeconds: ${{ env.POLLING_INTERVALS_SEC }} - - - name: Wait for the Docker images to be pushed - uses: fountainhead/action-wait-for-check@v1.1.0 - with: - checkName: Docker status - ref: ${{ github.event.pull_request.head.sha || github.sha }} - token: ${{ secrets.GITHUB_TOKEN }} - intervalSeconds: ${{ env.POLLING_INTERVALS_SEC }} - - e2e-tests: - runs-on: ubuntu-latest - name: Test ${{ matrix.e2e }} (PHP ${{ matrix.php }}, ${{ matrix.tools }}) - needs: wait-for-phar-and-docker-images - strategy: - fail-fast: false - matrix: - e2e: - - e2e_scoper_alias - - e2e_scoper_expose_symbols - - e2e_symfony - - e2e_symfony_runtime - - e2e_composer_installed_versions - - e2e_phpstorm_stubs - - e2e_dockerfile - - e2e_dockerfile_no_extension - - e2e_custom_composer_bin - - e2e_reproducible_build - php: [ '8.1', '8.2', '8.3' ] - tools: - - 'composer:2.2' - - 'composer:2.3' - - 'composer:2.4' - - 'composer' - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - ini-values: phar.readonly=0, display_errors=On, error_reporting=-1 - tools: ${{ matrix.tools }} - coverage: pcov - - - name: Allow Composer installation on future PHP versions - if: ${{ matrix.php == '8.3' }} - run: echo "COMPOSER_IGNORE_PLATFORM_REQ=--ignore-platform-req=php+" >> "$GITHUB_ENV" - - # We cannot use the regular actions/download-artifact here since the artifact is stored - # in a different workflow. - # See https://github.com/actions/download-artifact/issues/172 - - name: Retrieve built PHAR - uses: dawidd6/action-download-artifact@v2 - with: - github_token: ${{secrets.GITHUB_TOKEN}} - workflow: release.yaml - check_artifacts: true - name: box-phar - - # The original target is for the publishing, which is different from the internal name used. - - name: Ensure the make target is up to date - run: | - mkdir -p vendor - mv -vf box.phar bin/box.phar - touch -c bin/box.phar - - # See https://github.com/actions/download-artifact#limitations - # the permissions are not guaranteed to be preserved - - name: Ensure PHAR is executable - run: chmod 755 bin/box.phar - - - name: Check that the PHAR works - run: bin/box.phar --ansi --version - - - run: make ${{ matrix.e2e }} - - e2e-tests-docker: - runs-on: ubuntu-latest - name: Test ${{ matrix.e2e }} - needs: wait-for-phar-and-docker-images - strategy: - fail-fast: false - matrix: - e2e: - - _e2e_php_settings_checker_no_restart - - _e2e_php_settings_checker_xdebug_enabled - - _e2e_php_settings_checker_readonly_enabled - - _e2e_php_settings_checker_memory_limit_lower - - _e2e_php_settings_checker_memory_limit_higher - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.1' - ini-values: phar.readonly=0, display_errors=On, error_reporting=-1 - tools: composer - coverage: pcov - - # We cannot use the regular actions/download-artifact here since the artifact is stored - # in a different workflow. - # See https://github.com/actions/download-artifact/issues/172 - - name: Retrieve built PHAR - uses: dawidd6/action-download-artifact@v2 - with: - github_token: ${{secrets.GITHUB_TOKEN}} - workflow: release.yaml - check_artifacts: true - name: box-phar - - # The original target is for the publishing, which is different from the internal name used. - - name: Ensure the make target is up to date - run: | - mkdir -p vendor - mv -vf box.phar bin/box.phar - touch -c bin/box.phar - - # See https://github.com/actions/download-artifact#limitations - # the permissions are not guaranteed to be preserved - - name: Ensure PHAR is executable - run: chmod 755 bin/box.phar - - - name: Check that the PHAR works - run: bin/box.phar --ansi --version - - - name: Login to GitHub Container Registry - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Pull the docker image - run: | - docker pull ghcr.io/box-project/box_php81 - docker pull ghcr.io/box-project/box_php81_xdebug - - - run: make ${{ matrix.e2e }} - - # This is a "trick", a meta task which does not change, and we can use in - # the protected branch rules as opposed to the tests one above which - # may change regularly. - validate-tests: - name: E2E tests status - runs-on: ubuntu-latest - needs: - - e2e-tests - - e2e-tests-docker - if: always() - steps: - - name: Successful run - if: ${{ !(contains(needs.*.result, 'failure')) }} - run: exit 0 - - - name: Failing run - if: ${{ contains(needs.*.result, 'failure') }} - run: exit 1 diff --git a/.github/workflows/gh-pages.yaml b/.github/workflows/gh-pages.yaml deleted file mode 100644 index 1172db2ef..000000000 --- a/.github/workflows/gh-pages.yaml +++ /dev/null @@ -1,61 +0,0 @@ -name: GitHub-Pages - -on: - push: - branches: - - main - paths: - - doc/** - - mkdocs.yaml - - .github/workflows/gh-pages.yaml - -# See https://stackoverflow.com/a/72408109 -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -env: - TERM: xterm - -jobs: - deploy: - runs-on: ubuntu-20.04 - name: Deploy website - permissions: - contents: write - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup Python - uses: actions/setup-python@v3 - with: - python-version: '3.8' - - # install pip=>20.1 to use "pip cache dir" - - name: Upgrade pip - run: python3 -m pip install --upgrade pip - - - name: Get pip cache dir - id: pip-cache - run: echo "::set-output name=dir::$(pip cache dir)" - - - name: Cache dependencies - uses: actions/cache@v3 - with: - path: ${{ steps.pip-cache.outputs.dir }} - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip- - - - name: Install dependencies - run: python3 -m pip install mkdocs mkdocs-material - - - name: Rebuild website - run: make _website_build - - - name: Deploy - uses: peaceiris/actions-gh-pages@v3 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./dist/website diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml deleted file mode 100644 index a4e41203a..000000000 --- a/.github/workflows/release.yaml +++ /dev/null @@ -1,203 +0,0 @@ -name: Release - -on: - push: - branches: [ main ] - pull_request: ~ - schedule: - # Do not make it the first of the month and/or midnight since it is a very busy time - - cron: "* 10 5 * *" - release: - types: [ created ] - -# See https://stackoverflow.com/a/72408109 -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -env: - DOCKERFILE: .docker/Dockerfile - DOCKERHUB_USERNAME: boxproject - TERM: xterm - -jobs: - build-phar: - runs-on: ubuntu-latest - name: Build PHAR - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.1' - ini-values: phar.readonly=0 - tools: composer - coverage: none - - - name: Install Composer dependencies - uses: ramsey/composer-install@v2 - - - name: Ensure that the make target is up to date - run: make _vendor_install - - - name: Build PHAR - run: make compile - - # Smoke test - - name: Ensure the PHAR works - run: bin/box.phar --ansi --version - - - name: Ensure the PHAR is scoped - run: bin/box.phar namespace | php -r 'if (!str_starts_with(stream_get_contents(STDIN), "_HumbugBox")) exit (1);' - - - name: Import GPG key - if: github.event_name == 'release' - uses: crazy-max/ghaction-import-gpg@v5 - with: - gpg_private_key: ${{ secrets.GPG_KEY_41539BBD4020945DB378F98B2DF45277AEF09A2F }} - passphrase: ${{ secrets.GPG_KEY_41539BBD4020945DB378F98B2DF45277AEF09A2F_PASSPHRASE }} - - - name: Sign the PHAR - if: github.event_name == 'release' - run: | - gpg --local-user theo.fidry+box@gmail.com \ - --batch \ - --yes \ - --passphrase="${{ secrets.GPG_KEY_41539BBD4020945DB378F98B2DF45277AEF09A2F_PASSPHRASE }}" \ - --detach-sign \ - --output bin/box.phar.asc \ - bin/box.phar - - - uses: actions/upload-artifact@v3 - name: Upload the PHAR artifact - with: - name: box-phar - path: | - bin/box.phar - bin/box.phar.asc - - publish-phar: - runs-on: ubuntu-latest - name: Publish PHAR - needs: - - build-phar - if: github.event_name == 'release' - steps: - - uses: actions/download-artifact@v3 - with: - name: box-phar - path: . - - - name: Upload PHAR to the release - uses: softprops/action-gh-release@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} - files: | - box.phar - box.phar.asc - - - publish-homebrew-tap: - runs-on: ubuntu-latest - name: Publish Homebrew tap - needs: - - publish-phar - if: github.event_name == 'release' - steps: - - name: Update Homebrew formula - uses: dawidd6/action-homebrew-bump-formula@v3 - with: - token: ${{ secrets.BOX_HOMEBREW_TAP_TOKEN }} - tap: box-project/box - formula: box - tag: ${{ github.event.release.tag_name }} - revision: ${{ github.event.release.target_commitish }} - - - publish-docker-image: - runs-on: ubuntu-latest - name: Publish the Docker image - needs: - - build-phar - steps: - - name: Checkout - uses: actions/checkout@v3 - - - uses: actions/download-artifact@v3 - with: - name: box-phar - path: . - - # See https://github.com/actions/download-artifact#limitations - # the permissions are not guaranteed to be preserved - - name: Ensure PHAR is executable - run: | - chmod 755 box.phar - mv -vf box.phar bin/box.phar - ./bin/box.phar --ansi --version - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Login to Docker Container Registry - if: github.event_name == 'release' - uses: docker/login-action@v2 - with: - username: ${{ env.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Setup the Docker (release) tag(s) - if: github.event_name == 'release' - # Selects a random value for $EOF as a delimiter, and sets the DOCKER_TAGS environment variable - # as a multi-line environment variable. - run: | - EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) - - echo "DOCKER_TAGS<<$EOF" >> $GITHUB_ENV - echo "${{ env.DOCKERHUB_USERNAME }}/box:${{ github.ref_name }}" >> $GITHUB_ENV - echo "${{ env.DOCKERHUB_USERNAME }}/box:latest" >> $GITHUB_ENV - echo "$EOF" >> $GITHUB_ENV - echo "DOCKER_TEST_TAG=${{ env.DOCKERHUB_USERNAME }}/box:latest" >> $GITHUB_ENV - - - name: Login to GitHub Container Registry - if: github.event_name != 'release' - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Setup the Docker tag(s) - if: github.event_name != 'release' - run: | - echo "DOCKER_TAGS=ghcr.io/box-project/box" >> $GITHUB_ENV - echo "DOCKER_TEST_TAG=ghcr.io/box-project/box" >> $GITHUB_ENV - - - name: Build and export to Docker - uses: docker/build-push-action@v3 - with: - context: . - file: ${{ env.DOCKERFILE }} - platforms: linux/amd64 - tags: ${{ env.DOCKER_TAGS }} - load: true - - - name: Test the (release) image - run: docker run --rm ${{ env.DOCKER_TEST_TAG }} --version - - - name: Build and push - if: github.event_name == 'release' - uses: docker/build-push-action@v3 - with: - context: . - file: ${{ env.DOCKERFILE }} - platforms: linux/amd64 - tags: ${{ env.DOCKER_TAGS }} - push: true diff --git a/.github/workflows/requirement-checker.yaml b/.github/workflows/requirement-checker.yaml deleted file mode 100644 index 7953ee664..000000000 --- a/.github/workflows/requirement-checker.yaml +++ /dev/null @@ -1,354 +0,0 @@ -name: RequirementChecker - -on: - push: - branches: [ main ] - pull_request: ~ - schedule: - # Do not make it the first of the month and/or midnight since it is a very busy time - - cron: "* 10 5 * *" - -# See https://stackoverflow.com/a/72408109 -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -env: - POLLING_INTERVALS_SEC: 30 - SLEEP_TIME_SEC: 60s - #TERMINFO: /usr/lib/terminfo - TERM: xterm - -jobs: - cs-lint: - runs-on: ubuntu-latest - name: Lint CS - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.1' - tools: composer - coverage: none - - - name: Install the Composer (root) dependencies - uses: ramsey/composer-install@v2 - - - name: Ensure that the make target is up to date - run: make _vendor_install - - - name: Install PHP-CS-Fixer - uses: ramsey/composer-install@v2 - with: - working-directory: vendor-bin/php-cs-fixer - - - name: Ensure that the PHP-CS-Fixer make target is up to date - run: make php_cs_fixer_install - - - name: Install the Composer dependencies - uses: ramsey/composer-install@v2 - with: - working-directory: requirement-checker - - - name: Ensure that the make target is up to date - run: cd requirement-checker; make _vendor_install - - - name: Lint CS - run: cd requirement-checker; make cs_lint - - autoreview-test: - runs-on: ubuntu-latest - name: AutoReview Tests - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.1' - tools: composer - coverage: none - - - name: Install the Composer dependencies - uses: ramsey/composer-install@v2 - with: - working-directory: requirement-checker - - - name: Ensure that the make target is up to date - run: cd requirement-checker; make _vendor_install - - - name: Run tests - run: cd requirement-checker; make phpunit_autoreview - - unit-tests: - runs-on: ubuntu-latest - name: Unit Tests (PHP ${{ matrix.php }}, ${{ matrix.dependency }}${{ matrix.composer-options == null && ')' || format(', {0})', matrix.composer-options) }} - strategy: - fail-fast: false - matrix: - # The lowest dependency is tested via an e2e test rather than by executing the tests like so. - # The reason being using tools such as PHPUnit for a version as low as the lowest supported version - # is a serious strain for close to no benefits: the e2e test is simpler. - php: [ '8.1' ] - dependency: [ locked ] - composer-options: [ null ] - include: - - php: '8.1' - dependency: lowest - composer-options: ~ - - php: '8.1' - dependency: highest - composer-options: ~ - - php: '8.2' - dependency: highest - composer-options: ~ - - php: '8.3' - dependency: highest - composer-options: --ignore-platform-req=php+ - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - tools: composer - coverage: none - - - name: Install the Composer dependencies - uses: ramsey/composer-install@v2 - with: - working-directory: requirement-checker - dependency-versions: ${{ matrix.dependency }} - composer-options: ${{ matrix.composer-options }} - - - name: Ensure that the make target is up to date - run: cd requirement-checker; make _vendor_install - - - name: Install the Composer (root) dependencies - uses: ramsey/composer-install@v2 - with: - dependency-versions: ${{ matrix.php.dependency }} - composer-options: ${{ matrix.php.composer-options }} - - - name: Ensure that the make target is up to date - run: make _vendor_install - - - name: Install the Composer (requirement checker bin namespace) dependencies - uses: ramsey/composer-install@v2 - with: - working-directory: vendor-bin/requirement-checker - dependency-versions: highest - composer-options: ${{ matrix.php.composer-options }} - - - name: Ensure that the make target is up to date - run: make requirement_checker_install - - - name: Runs the tests - run: cd requirement-checker; make test_unit - - wait-for-phar-and-docker-images: - runs-on: ubuntu-latest - name: Wait for the PHAR & Docker images - steps: - # Reduce the amount polling done without increasing the polling internal too much. - - name: Sleep - run: sleep ${{ env.SLEEP_TIME_SEC }} - shell: bash - - # I could not make this workflow work with a on.workflow_run. Hence instead of adding this - # wait step for _every_ e2e job, which will block more runners, we wait in one and only one - # runner. - - name: Wait for the PHAR to be built - uses: fountainhead/action-wait-for-check@v1.1.0 - with: - checkName: Build PHAR - ref: ${{ github.event.pull_request.head.sha || github.sha }} - token: ${{ secrets.GITHUB_TOKEN }} - intervalSeconds: ${{ env.POLLING_INTERVALS_SEC }} - - - name: Wait for the Docker images to be pushed - uses: fountainhead/action-wait-for-check@v1.1.0 - with: - checkName: Docker status - ref: ${{ github.event.pull_request.head.sha || github.sha }} - token: ${{ secrets.GITHUB_TOKEN }} - intervalSeconds: ${{ env.POLLING_INTERVALS_SEC }} - - e2e-tests: - runs-on: ubuntu-latest - name: End-to-End Tests - needs: wait-for-phar-and-docker-images - strategy: - fail-fast: false - matrix: - e2e: - - command: _test_e2e_pass_no_config_min_composer_php - docker-image: ghcr.io/box-project/box_php725 - - command: _test_e2e_pass_no_config_min_box_php - docker-image: ghcr.io/box-project/box_php81 - - command: _test_e2e_pass_complete_min_composer_php - docker-image: ghcr.io/box-project/box_php725 - - command: _test_e2e_pass_complete_min_box_php - docker-image: ghcr.io/box-project/box_php81 - - command: _test_e2e_fail_complete_min_composer_php - docker-image: ghcr.io/box-project/box_php725 - - command: _test_e2e_fail_complete_min_box_php - docker-image: ghcr.io/box-project/box_php81 - - command: _test_e2e_skip_min_composer_php - docker-image: ghcr.io/box-project/box_php725 - - command: _test_e2e_pass_complete_requirement_checker_not_disabled - docker-image: ghcr.io/box-project/box_php725 - - command: _test_e2e_fail_conflict - docker-image: ghcr.io/box-project/box_php81 - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.1' - tools: composer - coverage: none - - # We cannot use the regular actions/download-artifact here since the artifact is stored - # in a different workflow. - # See https://github.com/actions/download-artifact/issues/172 - - name: Retrieve built PHAR - uses: dawidd6/action-download-artifact@v2 - with: - github_token: ${{secrets.GITHUB_TOKEN}} - workflow: release.yaml - check_artifacts: true - name: box-phar - - # The original target is for the publishing, which is different from the internal name used. - - name: Ensure the make target is up to date - run: | - mkdir -p vendor - mv -vf box.phar bin/box.phar - touch -c bin/box.phar - - # See https://github.com/actions/download-artifact#limitations - # the permissions are not guaranteed to be preserved - - name: Ensure PHAR is executable - run: chmod 755 bin/box.phar - - - name: Check that the PHAR works - run: bin/box.phar --ansi --version - - - name: Login to GitHub Container Registry - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Pull the docker image - run: docker pull ${{ matrix.e2e.docker-image }} - - - name: Runs the tests - run: cd requirement-checker; make ${{ matrix.e2e.command }} - - # This is a "trick", a meta task which does not change, and we can use in - # the protected branch rules as opposed to the tests one above which - # may change regularly. - validate-tests: - name: RequirementChecker status - runs-on: ubuntu-latest - needs: - - cs-lint - - autoreview-test - - unit-tests - - e2e-tests - if: always() - steps: - - name: Successful run - if: ${{ !(contains(needs.*.result, 'failure')) }} - run: exit 0 - - - name: Failing run - if: ${{ contains(needs.*.result, 'failure') }} - run: exit 1 - - update-requirement-checker: - name: "Update the RequirementChecker" - if: ${{ github.repository == 'box-project/box' && github.ref_name == 'main' }} - runs-on: "ubuntu-latest" - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - ref: ${{ github.head_ref }} - fetch-depth: '0' # Ensures the tags are fetched - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.1' - tools: composer - coverage: none - - - name: Install the Composer dependencies - uses: ramsey/composer-install@v2 - with: - working-directory: requirement-checker - dependency-versions: ${{ matrix.php.dependency }} - composer-options: ${{ matrix.php.composer-options }} - env: - COMPOSER_ROOT_VERSION: "4.x.x-dev" - - - name: Ensure that the make target is up to date - run: cd requirement-checker; make _vendor_install - - - name: Install the Composer (root) dependencies - uses: ramsey/composer-install@v2 - with: - dependency-versions: ${{ matrix.php.dependency }} - composer-options: ${{ matrix.php.composer-options }} - env: - COMPOSER_ROOT_VERSION: "4.x.x-dev" - - - name: Ensure that the make target is up to date - run: make _vendor_install - - - name: Install the Composer (requirement checker bin namespace) dependencies - uses: ramsey/composer-install@v2 - with: - working-directory: vendor-bin/requirement-checker - dependency-versions: highest - composer-options: ${{ matrix.php.composer-options }} - - - name: Ensure that the make target is up to date - run: make requirement_checker_install - - - name: Dump the requirement checker - run: make dump_requirement_checker - - - name: Check for changes - run: | - if [ $(git status --porcelain | wc -l) -eq "0" ]; then - echo "🟢 No change detected." - echo "requirement_checker_changed=false" >> $GITHUB_ENV - else - echo "requirement_checker_changed=true" >> $GITHUB_ENV - fi - - - name: Create Pull Request - if: env.requirement_checker_changed == 'true' - uses: peter-evans/create-pull-request@v4 - with: - token: ${{ secrets.GITHUB_TOKEN }} - branch-suffix: random - delete-branch: true - title: "build: Update the RequirementChecker" - committer: "box-bot " - commit-message: "Update the RequirementChecker" diff --git a/.github/workflows/security.yaml b/.github/workflows/security.yaml deleted file mode 100644 index bacf10545..000000000 --- a/.github/workflows/security.yaml +++ /dev/null @@ -1,39 +0,0 @@ -name: Security - -on: - push: - branches: [ main ] - pull_request: ~ - schedule: - # Do not make it the first of the month and/or midnight since it is a very busy time - - cron: "* 10 5 * *" - release: - types: [ created ] - -# See https://stackoverflow.com/a/72408109 -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -env: - TERM: xterm - -jobs: - security: - runs-on: ubuntu-latest - name: Audit Dependencies - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Cache the vulnerability database - uses: actions/cache@v3 - id: cache-db - with: - path: ~/.symfony/cache - key: db - - - name: Checks dependencies for known vulnerabilities - uses: symfonycorp/security-checker-action@v4 diff --git a/.github/workflows/unit-tests.yaml b/.github/workflows/unit-tests.yaml deleted file mode 100644 index d063a3ae0..000000000 --- a/.github/workflows/unit-tests.yaml +++ /dev/null @@ -1,165 +0,0 @@ -name: Unit Tests - -on: - push: - branches: [ main ] - pull_request: ~ - schedule: - # Do not make it the first of the month and/or midnight since it is a very busy time - - cron: "* 10 5 * *" - release: - types: [ created ] - -# See https://stackoverflow.com/a/72408109 -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -env: - TERM: xterm - -jobs: - unit-tests: - runs-on: ubuntu-latest - name: Unit-Tests (PHP ${{ matrix.php.version }}, ${{ matrix.php.dependency }}, ${{ matrix.tools }}) - PHAR ${{ matrix.phar-readonly && 'readonly' || 'writeable' }}${{ matrix.label }} - strategy: - fail-fast: false - matrix: - php: - - version: '8.1' - dependency: locked - composer-options: ~ - - version: '8.1' - dependency: lowest - composer-options: ~ - - version: '8.1' - dependency: highest - composer-options: ~ - - version: '8.2' - dependency: highest - composer-options: ~ - - version: '8.3' - dependency: highest - composer-options: --ignore-platform-req=php+ - tools: - - 'composer:2.2' - - 'composer:2.3' - - 'composer:2.4' - - 'composer' - phar-readonly: [ true, false ] - php-extra-extensions: [ '' ] - label: [ '' ] - include: - - label: '; bz2 disabled' - php: - version: '8.1' - dependency: locked - composer-options: '' - tools: composer - phar-readonly: false - php-extra-extensions: ', :bz2' - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php.version }} - ini-values: ${{ matrix.phar-readonly && 'phar.readonly=1' || 'phar.readonly=0' }}, display_errors=On, error_reporting=-1 - tools: ${{ matrix.tools }} - coverage: none - extensions: ctype, iconv, xml${{ matrix.php-extra-extensions }} - - - name: Remove the configured platform on non-locked dependencies - if: ${{ matrix.php.dependency != 'locked' }} - run: composer config platform.php --unset - - - name: Install Composer dependencies - uses: ramsey/composer-install@v2 - with: - dependency-versions: ${{ matrix.php.dependency }} - composer-options: ${{ matrix.php.composer-options }} - - - name: Ensure that the make target is up to date - run: make _vendor_install - - - run: make phpunit - - infection: - runs-on: ubuntu-latest - name: Infection (PHP ${{ matrix.php }}) - strategy: - fail-fast: false - matrix: - php: [ '8.1' ] - if: github.event_name == 'pull_request' || github.event_name == 'push' - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - # The phar.readonly value is adjusted in the Makefile command for - # better portability. - ini-values: phar.readonly=0, display_errors=On, error_reporting=-1 - tools: composer - coverage: pcov - extensions: ctype, iconv, xml - - - name: Configure the base ref (pull request) - if: github.event_name == 'pull_request' - run: echo "INFECTION_BASE_REF=$GITHUB_BASE_REF" >> $GITHUB_ENV - - - name: Configure the base ref (push/release event) - if: github.event_name == 'push' - run: echo "INFECTION_BASE_REF=${{ github.event.before }}" >> $GITHUB_ENV - - # Do this before using the Makefile just to avoid accidentally resolving the deferred variables using - # INFECTION_FLAGS. - - name: Configure Infection for the CI - run: | - git fetch origin $INFECTION_BASE_REF - echo "INFECTION_FLAGS=--git-diff-lines --git-diff-base=origin/$INFECTION_BASE_REF --ignore-msi-with-no-mutations --logger-github" >> "$GITHUB_ENV" - - - name: Install Composer dependencies - uses: ramsey/composer-install@v2 - - - name: Ensure that the make target is up to date - run: make _vendor_install - - - name: Install Infection - uses: ramsey/composer-install@v2 - - - name: Ensure that the Infection make target is up to date - run: make infection_install - - - name: Run tests with coverage - run: make phpunit_coverage_infection --debug - - - run: make _infection_ci --debug - - # This is a "trick", a meta task which does not change, and we can use in - # the protected branch rules as opposed to the tests one above which - # may change regularly. - validate-tests: - name: Unit tests status - runs-on: ubuntu-latest - needs: - - unit-tests - - infection - if: always() - steps: - - name: Successful run - if: ${{ !(contains(needs.*.result, 'failure')) }} - run: exit 0 - - - name: Failing run - if: ${{ contains(needs.*.result, 'failure') }} - run: exit 1 From 56abc9960c286dc950d612f7d7932f40097171af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= Date: Thu, 19 Oct 2023 00:51:56 +0200 Subject: [PATCH 03/22] test --- .github/workflows/phar-debug.yaml | 12 +++++++++--- composer-test.php | 12 ++++++++++++ .../Command/Composer/ComposerCheckVersion.php | 8 -------- 3 files changed, 21 insertions(+), 11 deletions(-) create mode 100755 composer-test.php diff --git a/.github/workflows/phar-debug.yaml b/.github/workflows/phar-debug.yaml index 365a1b7bb..b6f8d3fbf 100644 --- a/.github/workflows/phar-debug.yaml +++ b/.github/workflows/phar-debug.yaml @@ -27,8 +27,14 @@ jobs: - name: Install dependencies run: composer install --prefer-dist --no-progress - - name: Dump env + - name: regular check run: bin/box composer:check-version - - name: Dump env - run: php bin/box composer:check-version \ No newline at end of file + - name: PHP + regular check + run: php bin/box composer:check-version + + - name: Test script + run: bin/box composer:check-version --composer-bin=composer-test.php + + - name: PHP + Test script + run: php bin/box composer:check-version --composer-bin=composer-test.php \ No newline at end of file diff --git a/composer-test.php b/composer-test.php new file mode 100755 index 000000000..f8ba7ab39 --- /dev/null +++ b/composer-test.php @@ -0,0 +1,12 @@ +#!/usr/bin/env php + get_declared_classes(), + 'phpversion' => phpversion(), + 'get_loaded_extensions' => get_loaded_extensions(), + ]); +} + +echo 'Composer version 2.6.3 2023-09-15 09:38:21'; diff --git a/src/Console/Command/Composer/ComposerCheckVersion.php b/src/Console/Command/Composer/ComposerCheckVersion.php index 878d4defe..27b956dd4 100644 --- a/src/Console/Command/Composer/ComposerCheckVersion.php +++ b/src/Console/Command/Composer/ComposerCheckVersion.php @@ -47,14 +47,6 @@ protected function orchestrate(ComposerOrchestrator $composerOrchestrator, IO $i check_php_settings($io); $composerOrchestrator->checkVersion(); - if (!class_exists('Phar', false)) { - dd([ - 'get_declared_classes' => get_declared_classes(), - 'phpversion' => phpversion(), - 'get_loaded_extensions' => get_loaded_extensions(), - ]); - } - return ExitCode::SUCCESS; } } From acbded36aca7a0d562edac58c94f9b418aeabbae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= Date: Thu, 19 Oct 2023 00:53:54 +0200 Subject: [PATCH 04/22] test with PHAR --- .github/workflows/phar-debug.yaml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/phar-debug.yaml b/.github/workflows/phar-debug.yaml index b6f8d3fbf..46adcedc5 100644 --- a/.github/workflows/phar-debug.yaml +++ b/.github/workflows/phar-debug.yaml @@ -37,4 +37,13 @@ jobs: run: bin/box composer:check-version --composer-bin=composer-test.php - name: PHP + Test script - run: php bin/box composer:check-version --composer-bin=composer-test.php \ No newline at end of file + run: php bin/box composer:check-version --composer-bin=composer-test.php + + - name: Build PHAR + run: make bin/box.phar + + - name: PHARBox + Test script + run: ./bin/box.phar composer:check-version --composer-bin=composer-test.php + + - name: PHARBox + PHP + Test script + run: php bin/box.phar composer:check-version --composer-bin=composer-test.php \ No newline at end of file From 0e7d1ab4e957eadece51b661a67610f5a0831c14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= Date: Fri, 20 Oct 2023 19:35:14 +0200 Subject: [PATCH 05/22] try stuff --- .env | 15 +++++ .env.test | 6 ++ .github/workflows/phar-debug.yaml | 12 ++-- .gitignore | 10 +++ bin/console | 1 + bin/phpunit | 19 ++++++ composer.json | 12 +++- composer.lock | 67 ++++++++++++++++++- config/bundles.php | 5 ++ fixtures/build/dir018/new-bin/console | 4 +- src/Console/Application.php | 1 + .../Command/Composer/ComposerCheckVersion.php | 1 + .../Composer/ComposerDumpAutoloader.php | 58 ++++++++++++++++ symfony.lock | 58 ++++++++++++++++ 14 files changed, 258 insertions(+), 11 deletions(-) create mode 100644 .env create mode 100644 .env.test create mode 120000 bin/console create mode 100755 bin/phpunit create mode 100644 config/bundles.php create mode 100644 src/Console/Command/Composer/ComposerDumpAutoloader.php create mode 100644 symfony.lock diff --git a/.env b/.env new file mode 100644 index 000000000..caf3356ce --- /dev/null +++ b/.env @@ -0,0 +1,15 @@ +# In all environments, the following files are loaded if they exist, +# the latter taking precedence over the former: +# +# * .env contains default values for the environment variables needed by the app +# * .env.local uncommitted file with local overrides +# * .env.$APP_ENV committed environment-specific defaults +# * .env.$APP_ENV.local uncommitted environment-specific overrides +# +# Real environment variables win over .env files. +# +# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES. +# https://symfony.com/doc/current/configuration/secrets.html +# +# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2). +# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration diff --git a/.env.test b/.env.test new file mode 100644 index 000000000..9e7162f0b --- /dev/null +++ b/.env.test @@ -0,0 +1,6 @@ +# define your env variables for the test env here +KERNEL_CLASS='App\Kernel' +APP_SECRET='$ecretf0rt3st' +SYMFONY_DEPRECATIONS_HELPER=999999 +PANTHER_APP_ENV=panther +PANTHER_ERROR_SCREENSHOT_DIR=./var/error-screenshots diff --git a/.github/workflows/phar-debug.yaml b/.github/workflows/phar-debug.yaml index 46adcedc5..e814ff93b 100644 --- a/.github/workflows/phar-debug.yaml +++ b/.github/workflows/phar-debug.yaml @@ -28,22 +28,22 @@ jobs: run: composer install --prefer-dist --no-progress - name: regular check - run: bin/box composer:check-version + run: bin/box composer:dump-autoload - name: PHP + regular check - run: php bin/box composer:check-version + run: php bin/box composer:dump-autoload - name: Test script - run: bin/box composer:check-version --composer-bin=composer-test.php + run: bin/box composer:dump-autoload --composer-bin=composer-test.php - name: PHP + Test script - run: php bin/box composer:check-version --composer-bin=composer-test.php + run: php bin/box composer:dump-autoload --composer-bin=composer-test.php - name: Build PHAR run: make bin/box.phar - name: PHARBox + Test script - run: ./bin/box.phar composer:check-version --composer-bin=composer-test.php + run: ./bin/box.phar composer:dump-autoload --composer-bin=composer-test.php - name: PHARBox + PHP + Test script - run: php bin/box.phar composer:check-version --composer-bin=composer-test.php \ No newline at end of file + run: php bin/box.phar composer:dump-autoload --composer-bin=composer-test.php \ No newline at end of file diff --git a/.gitignore b/.gitignore index 3b411680c..3b49771b5 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,13 @@ /vendor-bin/*/composer.lock /vendor-bin/*/vendor/ /vendor/ + +###> phpunit/phpunit ### +/phpunit.xml +.phpunit.result.cache +###< phpunit/phpunit ### + +###> symfony/phpunit-bridge ### +.phpunit.result.cache +/phpunit.xml +###< symfony/phpunit-bridge ### diff --git a/bin/console b/bin/console new file mode 120000 index 000000000..f1014d6a1 --- /dev/null +++ b/bin/console @@ -0,0 +1 @@ +../fixtures/build/dir018/new-bin/console \ No newline at end of file diff --git a/bin/phpunit b/bin/phpunit new file mode 100755 index 000000000..f26f2c727 --- /dev/null +++ b/bin/phpunit @@ -0,0 +1,19 @@ +#!/usr/bin/env php +=8.0" + }, + "require-dev": { + "composer/composer": "^2.1", + "symfony/dotenv": "^5.4|^6.0", + "symfony/filesystem": "^5.4|^6.0", + "symfony/phpunit-bridge": "^5.4|^6.0", + "symfony/process": "^5.4|^6.0" + }, + "type": "composer-plugin", + "extra": { + "class": "Symfony\\Flex\\Flex" + }, + "autoload": { + "psr-4": { + "Symfony\\Flex\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien.potencier@gmail.com" + } + ], + "description": "Composer plugin for Symfony", + "support": { + "issues": "https://github.com/symfony/flex/issues", + "source": "https://github.com/symfony/flex/tree/v2.3.3" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-08-04T09:02:35+00:00" + }, { "name": "symfony/phpunit-bridge", "version": "v6.3.2", diff --git a/config/bundles.php b/config/bundles.php new file mode 100644 index 000000000..cbdb15d53 --- /dev/null +++ b/config/bundles.php @@ -0,0 +1,5 @@ + ['all' => true], +]; diff --git a/fixtures/build/dir018/new-bin/console b/fixtures/build/dir018/new-bin/console index f97966cf0..c933dc535 100755 --- a/fixtures/build/dir018/new-bin/console +++ b/fixtures/build/dir018/new-bin/console @@ -4,15 +4,13 @@ use App\Kernel; use Symfony\Bundle\FrameworkBundle\Console\Application; -$_SERVER['APP_SCRIPT_FILENAME'] = __FILE__; - if (!is_file(dirname(__DIR__).'/vendor/autoload_runtime.php')) { throw new LogicException('Symfony Runtime is missing. Try running "composer require symfony/runtime".'); } require_once dirname(__DIR__).'/vendor/autoload_runtime.php'; -return static function (array $context) { +return function (array $context) { $kernel = new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']); return new Application($kernel); diff --git a/src/Console/Application.php b/src/Console/Application.php index 47d6e209b..c8b346b14 100644 --- a/src/Console/Application.php +++ b/src/Console/Application.php @@ -80,6 +80,7 @@ public function getCommands(): array return [ new Command\Composer\ComposerCheckVersion(), new Command\Composer\ComposerVendorDir(), + new Command\Composer\ComposerDumpAutoloader(), new Command\Compile($this->getHeader()), new Command\Diff(), new Command\Info(), diff --git a/src/Console/Command/Composer/ComposerCheckVersion.php b/src/Console/Command/Composer/ComposerCheckVersion.php index 27b956dd4..7e229cf1a 100644 --- a/src/Console/Command/Composer/ComposerCheckVersion.php +++ b/src/Console/Command/Composer/ComposerCheckVersion.php @@ -45,6 +45,7 @@ public function getConfiguration(): Configuration protected function orchestrate(ComposerOrchestrator $composerOrchestrator, IO $io): int { check_php_settings($io); + $composerOrchestrator->checkVersion(); return ExitCode::SUCCESS; diff --git a/src/Console/Command/Composer/ComposerDumpAutoloader.php b/src/Console/Command/Composer/ComposerDumpAutoloader.php new file mode 100644 index 000000000..640fb5d7e --- /dev/null +++ b/src/Console/Command/Composer/ComposerDumpAutoloader.php @@ -0,0 +1,58 @@ + + * Théo Fidry + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace KevinGH\Box\Console\Command\Composer; + +use Fidry\Console\Command\Configuration; +use Fidry\Console\ExitCode; +use Fidry\Console\Input\IO; +use Humbug\PhpScoper\Symbol\SymbolsRegistry; +use KevinGH\Box\Composer\ComposerOrchestrator; +use function ini_get; +use function KevinGH\Box\check_php_settings; + +/** + * @private + */ +final class ComposerDumpAutoloader extends ComposerCommand +{ + public function getConfiguration(): Configuration + { + $parentConfig = parent::getConfiguration(); + + return new Configuration( + 'composer:dump-autoload', + '🎵 Dumps the autoloader with Composer.', + <<<'HELP' + The %command.name% command will look for the Composer binary (in the system if not configured + in the configuration file) and dump the autoloader. + HELP, + $parentConfig->getArguments(), + $parentConfig->getOptions(), + ); + } + + protected function orchestrate(ComposerOrchestrator $composerOrchestrator, IO $io): int + { + check_php_settings($io); + + $composerOrchestrator->dumpAutoload( + new SymbolsRegistry(), + '', + false, + ); + + return ExitCode::SUCCESS; + } +} diff --git a/symfony.lock b/symfony.lock new file mode 100644 index 000000000..e093db081 --- /dev/null +++ b/symfony.lock @@ -0,0 +1,58 @@ +{ + "fidry/console": { + "version": "0.5.5" + }, + "phpunit/phpunit": { + "version": "9.6", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "9.6", + "ref": "7364a21d87e658eb363c5020c072ecfdc12e2326" + }, + "files": [ + ".env.test", + "phpunit.xml.dist", + "tests/bootstrap.php" + ] + }, + "symfony/console": { + "version": "6.3", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "5.3", + "ref": "da0c8be8157600ad34f10ff0c9cc91232522e047" + }, + "files": [ + "bin/console" + ] + }, + "symfony/flex": { + "version": "2.3", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "1.0", + "ref": "146251ae39e06a95be0fe3d13c807bcf3938b172" + }, + "files": [ + ".env" + ] + }, + "symfony/phpunit-bridge": { + "version": "6.3", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "6.3", + "ref": "01dfaa98c58f7a7b5a9b30e6edb7074af7ed9819" + }, + "files": [ + ".env.test", + "bin/phpunit", + "phpunit.xml.dist", + "tests/bootstrap.php" + ] + } +} From 0f923c617c12c65a4721832cf331183fe9cbfe39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= Date: Fri, 20 Oct 2023 19:36:57 +0200 Subject: [PATCH 06/22] add runtime --- composer.json | 4 ++- composer.lock | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 83 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index e4a6068ba..83df81d4f 100644 --- a/composer.json +++ b/composer.json @@ -41,6 +41,7 @@ "symfony/filesystem": "^6.1.5", "symfony/finder": "^6.1.3", "symfony/process": "^6.1.3", + "symfony/runtime": "^6.3", "symfony/var-dumper": "^6.1.6", "webmozart/assert": "^1.11" }, @@ -95,7 +96,8 @@ "bamarni/composer-bin-plugin": true, "composer/package-versions-deprecated": false, "ergebnis/composer-normalize": true, - "symfony/flex": true + "symfony/flex": true, + "symfony/runtime": true }, "platform": { "php": "8.1" diff --git a/composer.lock b/composer.lock index 83c64ae43..4a8abc923 100644 --- a/composer.lock +++ b/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": "c14bf07a84d4717df5a16637bf44f45d", + "content-hash": "299509d300f7e6e0874dacc5b80c6ab2", "packages": [ { "name": "amphp/amp", @@ -2659,6 +2659,85 @@ ], "time": "2023-08-07T10:39:22+00:00" }, + { + "name": "symfony/runtime", + "version": "v6.3.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/runtime.git", + "reference": "d5c09493647a0c1a16e6c8da308098e840d1164f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/runtime/zipball/d5c09493647a0c1a16e6c8da308098e840d1164f", + "reference": "d5c09493647a0c1a16e6c8da308098e840d1164f", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0|^2.0", + "php": ">=8.1" + }, + "conflict": { + "symfony/dotenv": "<5.4" + }, + "require-dev": { + "composer/composer": "^1.0.2|^2.0", + "symfony/console": "^5.4.9|^6.0.9", + "symfony/dotenv": "^5.4|^6.0", + "symfony/http-foundation": "^5.4|^6.0", + "symfony/http-kernel": "^5.4|^6.0" + }, + "type": "composer-plugin", + "extra": { + "class": "Symfony\\Component\\Runtime\\Internal\\ComposerPlugin" + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Runtime\\": "", + "Symfony\\Runtime\\Symfony\\Component\\": "Internal/" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Enables decoupling PHP applications from global state", + "homepage": "https://symfony.com", + "keywords": [ + "runtime" + ], + "support": { + "source": "https://github.com/symfony/runtime/tree/v6.3.2" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-07-16T17:05:46+00:00" + }, { "name": "symfony/service-contracts", "version": "v3.3.0", From f9d06e4d9c3c82ee13c1cc9591bef3569d6a06e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= Date: Fri, 20 Oct 2023 19:38:22 +0200 Subject: [PATCH 07/22] install fixture first --- .github/workflows/phar-debug.yaml | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/.github/workflows/phar-debug.yaml b/.github/workflows/phar-debug.yaml index e814ff93b..e6bcb2dfc 100644 --- a/.github/workflows/phar-debug.yaml +++ b/.github/workflows/phar-debug.yaml @@ -16,14 +16,9 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Cache Composer packages - id: composer-cache - uses: actions/cache@v3 - with: - path: vendor - key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} - restore-keys: | - ${{ runner.os }}-php- + - name: Install dependencies + run: composer install --prefer-dist --no-progress --working-dir=fixtures/build/dir018 + - name: Install dependencies run: composer install --prefer-dist --no-progress From 3040b3a08de09d9aceb475dc8889bb3a4d6f45ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= Date: Fri, 20 Oct 2023 19:44:17 +0200 Subject: [PATCH 08/22] test --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 83df81d4f..d8e9eef05 100644 --- a/composer.json +++ b/composer.json @@ -107,7 +107,7 @@ }, "scripts": { "auto-scripts": { - "cache:clear": "symfony-cmd" + "cache:clear": "bin/box composer:check-version" }, "post-autoload-dump": [ "@auto-scripts" From 9b1d528acd2349d271536a7ecb9e44f245fc4b97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= Date: Fri, 20 Oct 2023 19:51:10 +0200 Subject: [PATCH 09/22] try --- composer.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index d8e9eef05..49bc6077c 100644 --- a/composer.json +++ b/composer.json @@ -107,9 +107,14 @@ }, "scripts": { "auto-scripts": { - "cache:clear": "bin/box composer:check-version" + "./bin/box composer:check-version": "script", + "bin/box composer:check-version": "php-script", + "list --version": "symfony-cmd", + "about": "symfony-cmd", + "cache:clear": "symfony-cmd" }, "post-autoload-dump": [ + "@php bin/box composer:check-version", "@auto-scripts" ] }, From 19a881fc82d194a4ee9eb3c5237d8fda7240c244 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= Date: Fri, 20 Oct 2023 19:53:01 +0200 Subject: [PATCH 10/22] no scripts --- .github/workflows/phar-debug.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/phar-debug.yaml b/.github/workflows/phar-debug.yaml index e6bcb2dfc..3800203e4 100644 --- a/.github/workflows/phar-debug.yaml +++ b/.github/workflows/phar-debug.yaml @@ -17,10 +17,10 @@ jobs: - uses: actions/checkout@v3 - name: Install dependencies - run: composer install --prefer-dist --no-progress --working-dir=fixtures/build/dir018 + run: composer install --prefer-dist --no-progress --working-dir=fixtures/build/dir018 --no-scripts - name: Install dependencies - run: composer install --prefer-dist --no-progress + run: composer install --prefer-dist --no-progress --no-scripts - name: regular check run: bin/box composer:dump-autoload From 715701eff120edad39bdc83bc50904f8198bb254 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= Date: Fri, 20 Oct 2023 20:47:07 +0200 Subject: [PATCH 11/22] debug --- .github/workflows/phar-debug.yaml | 2 +- composer.json | 6 +++--- src/Console/Command/Composer/ComposerCheckVersion.php | 7 +++++++ src/Console/Command/Composer/ComposerDumpAutoloader.php | 5 +++++ src/Console/Php/PhpSettingsHandler.php | 1 + 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/.github/workflows/phar-debug.yaml b/.github/workflows/phar-debug.yaml index 3800203e4..5f4b8eb6b 100644 --- a/.github/workflows/phar-debug.yaml +++ b/.github/workflows/phar-debug.yaml @@ -23,7 +23,7 @@ jobs: run: composer install --prefer-dist --no-progress --no-scripts - name: regular check - run: bin/box composer:dump-autoload + run: bin/box composer:dump-autoload -vvv --composer-bin=tests/Console/Command/Composer/compatible-composer.phar - name: PHP + regular check run: php bin/box composer:dump-autoload diff --git a/composer.json b/composer.json index 49bc6077c..cab85b4e5 100644 --- a/composer.json +++ b/composer.json @@ -107,14 +107,14 @@ }, "scripts": { "auto-scripts": { - "./bin/box composer:check-version": "script", - "bin/box composer:check-version": "php-script", + "./bin/box composer:check-version --composer-bin=tests/Console/Command/Composer/compatible-composer.phar": "script", + "bin/box composer:check-version --composer-bin=tests/Console/Command/Composer/compatible-composer.phar": "php-script", "list --version": "symfony-cmd", "about": "symfony-cmd", "cache:clear": "symfony-cmd" }, "post-autoload-dump": [ - "@php bin/box composer:check-version", + "@php bin/box composer:check-version --composer-bin=tests/Console/Command/Composer/compatible-composer.phar", "@auto-scripts" ] }, diff --git a/src/Console/Command/Composer/ComposerCheckVersion.php b/src/Console/Command/Composer/ComposerCheckVersion.php index 7e229cf1a..31aefdcc9 100644 --- a/src/Console/Command/Composer/ComposerCheckVersion.php +++ b/src/Console/Command/Composer/ComposerCheckVersion.php @@ -18,6 +18,8 @@ use Fidry\Console\ExitCode; use Fidry\Console\Input\IO; use KevinGH\Box\Composer\ComposerOrchestrator; +use KevinGH\Box\Console\Php\PhpSettingsHandler; +use function class_exists; use function ini_get; use function KevinGH\Box\check_php_settings; @@ -45,9 +47,14 @@ public function getConfiguration(): Configuration protected function orchestrate(ComposerOrchestrator $composerOrchestrator, IO $io): int { check_php_settings($io); + if (!class_exists('Phar')) { + die('no PHAR class'); + } $composerOrchestrator->checkVersion(); + + return ExitCode::SUCCESS; } } diff --git a/src/Console/Command/Composer/ComposerDumpAutoloader.php b/src/Console/Command/Composer/ComposerDumpAutoloader.php index 640fb5d7e..ff7905389 100644 --- a/src/Console/Command/Composer/ComposerDumpAutoloader.php +++ b/src/Console/Command/Composer/ComposerDumpAutoloader.php @@ -19,6 +19,8 @@ use Fidry\Console\Input\IO; use Humbug\PhpScoper\Symbol\SymbolsRegistry; use KevinGH\Box\Composer\ComposerOrchestrator; +use KevinGH\Box\Console\Php\PhpSettingsHandler; +use function dd; use function ini_get; use function KevinGH\Box\check_php_settings; @@ -46,6 +48,9 @@ public function getConfiguration(): Configuration protected function orchestrate(ComposerOrchestrator $composerOrchestrator, IO $io): int { check_php_settings($io); + if (!class_exists('Phar')) { + die('no PHAR class'); + } $composerOrchestrator->dumpAutoload( new SymbolsRegistry(), diff --git a/src/Console/Php/PhpSettingsHandler.php b/src/Console/Php/PhpSettingsHandler.php index c268c7444..d7ba6d7b8 100644 --- a/src/Console/Php/PhpSettingsHandler.php +++ b/src/Console/Php/PhpSettingsHandler.php @@ -19,6 +19,7 @@ use KevinGH\Box\Phar\PharPhpSettings; use Psr\Log\LoggerInterface; use Webmozart\Assert\Assert; +use function dd; use function getenv; use function ini_get; use function ini_set; From 5ec5a909d8eaacd6bbe9991760635d67992a762f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= Date: Fri, 20 Oct 2023 21:31:31 +0200 Subject: [PATCH 12/22] include iconv --- composer.json | 1 + composer.lock | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 85 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index cab85b4e5..fae1d561c 100644 --- a/composer.json +++ b/composer.json @@ -40,6 +40,7 @@ "symfony/console": "^6.1.7", "symfony/filesystem": "^6.1.5", "symfony/finder": "^6.1.3", + "symfony/polyfill-iconv": "^1.28", "symfony/process": "^6.1.3", "symfony/runtime": "^6.3", "symfony/var-dumper": "^6.1.6", diff --git a/composer.lock b/composer.lock index 4a8abc923..5861895c3 100644 --- a/composer.lock +++ b/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": "299509d300f7e6e0874dacc5b80c6ab2", + "content-hash": "a7d386dc4455733e996bb3bbcecf14a2", "packages": [ { "name": "amphp/amp", @@ -2350,6 +2350,89 @@ ], "time": "2023-01-26T09:26:14+00:00" }, + { + "name": "symfony/polyfill-iconv", + "version": "v1.28.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-iconv.git", + "reference": "6de50471469b8c9afc38164452ab2b6170ee71c1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-iconv/zipball/6de50471469b8c9afc38164452ab2b6170ee71c1", + "reference": "6de50471469b8c9afc38164452ab2b6170ee71c1", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "provide": { + "ext-iconv": "*" + }, + "suggest": { + "ext-iconv": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.28-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Iconv\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Iconv extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "iconv", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-iconv/tree/v1.28.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-01-26T09:26:14+00:00" + }, { "name": "symfony/polyfill-intl-grapheme", "version": "v1.28.0", From 92541c54932283de44cc072e5f78a0fd3b272c0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= Date: Fri, 20 Oct 2023 21:42:17 +0200 Subject: [PATCH 13/22] debug --- fixtures/build/dir018/new-bin/console | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fixtures/build/dir018/new-bin/console b/fixtures/build/dir018/new-bin/console index c933dc535..e6ad5236f 100755 --- a/fixtures/build/dir018/new-bin/console +++ b/fixtures/build/dir018/new-bin/console @@ -4,6 +4,10 @@ use App\Kernel; use Symfony\Bundle\FrameworkBundle\Console\Application; +if (!class_exists('Phar')) { + die('no PHAR class'); +} + if (!is_file(dirname(__DIR__).'/vendor/autoload_runtime.php')) { throw new LogicException('Symfony Runtime is missing. Try running "composer require symfony/runtime".'); } From c6c82f874f7f7bfd1bc10f3660681293140bb231 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= Date: Fri, 20 Oct 2023 21:44:21 +0200 Subject: [PATCH 14/22] retry --- fixtures/build/dir018/new-bin/console | 2 +- src/Console/Command/Composer/ComposerCheckVersion.php | 2 +- src/Console/Command/Composer/ComposerDumpAutoloader.php | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/fixtures/build/dir018/new-bin/console b/fixtures/build/dir018/new-bin/console index e6ad5236f..7832bf9a3 100755 --- a/fixtures/build/dir018/new-bin/console +++ b/fixtures/build/dir018/new-bin/console @@ -5,7 +5,7 @@ use App\Kernel; use Symfony\Bundle\FrameworkBundle\Console\Application; if (!class_exists('Phar')) { - die('no PHAR class'); + throw new \Error('no PHAR class'); } if (!is_file(dirname(__DIR__).'/vendor/autoload_runtime.php')) { diff --git a/src/Console/Command/Composer/ComposerCheckVersion.php b/src/Console/Command/Composer/ComposerCheckVersion.php index 31aefdcc9..16700c56f 100644 --- a/src/Console/Command/Composer/ComposerCheckVersion.php +++ b/src/Console/Command/Composer/ComposerCheckVersion.php @@ -48,7 +48,7 @@ protected function orchestrate(ComposerOrchestrator $composerOrchestrator, IO $i { check_php_settings($io); if (!class_exists('Phar')) { - die('no PHAR class'); + throw new \Error('no PHAR class'); } $composerOrchestrator->checkVersion(); diff --git a/src/Console/Command/Composer/ComposerDumpAutoloader.php b/src/Console/Command/Composer/ComposerDumpAutoloader.php index ff7905389..89d9cfbc9 100644 --- a/src/Console/Command/Composer/ComposerDumpAutoloader.php +++ b/src/Console/Command/Composer/ComposerDumpAutoloader.php @@ -58,6 +58,10 @@ protected function orchestrate(ComposerOrchestrator $composerOrchestrator, IO $i false, ); + if (!class_exists('Phar')) { + throw new \Error('no PHAR class'); + } + return ExitCode::SUCCESS; } } From a1c85b56931f89aa6ad8d27626898d8a44cfc8a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= Date: Fri, 20 Oct 2023 22:10:33 +0200 Subject: [PATCH 15/22] reduce scope --- composer.json | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index fae1d561c..8a40b637a 100644 --- a/composer.json +++ b/composer.json @@ -108,14 +108,11 @@ }, "scripts": { "auto-scripts": { - "./bin/box composer:check-version --composer-bin=tests/Console/Command/Composer/compatible-composer.phar": "script", - "bin/box composer:check-version --composer-bin=tests/Console/Command/Composer/compatible-composer.phar": "php-script", - "list --version": "symfony-cmd", - "about": "symfony-cmd", - "cache:clear": "symfony-cmd" + ".bin/console list -v": "script", + ".bin/console list -vv": "php-script", + "list --version": "symfony-cmd" }, "post-autoload-dump": [ - "@php bin/box composer:check-version --composer-bin=tests/Console/Command/Composer/compatible-composer.phar", "@auto-scripts" ] }, From 833a271379484f3d4d0feb20aeb73149c6ace89e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= Date: Fri, 20 Oct 2023 22:12:41 +0200 Subject: [PATCH 16/22] fix --- .github/workflows/phar-debug.yaml | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/.github/workflows/phar-debug.yaml b/.github/workflows/phar-debug.yaml index 5f4b8eb6b..8a6a870a5 100644 --- a/.github/workflows/phar-debug.yaml +++ b/.github/workflows/phar-debug.yaml @@ -23,22 +23,4 @@ jobs: run: composer install --prefer-dist --no-progress --no-scripts - name: regular check - run: bin/box composer:dump-autoload -vvv --composer-bin=tests/Console/Command/Composer/compatible-composer.phar - - - name: PHP + regular check - run: php bin/box composer:dump-autoload - - - name: Test script - run: bin/box composer:dump-autoload --composer-bin=composer-test.php - - - name: PHP + Test script - run: php bin/box composer:dump-autoload --composer-bin=composer-test.php - - - name: Build PHAR - run: make bin/box.phar - - - name: PHARBox + Test script - run: ./bin/box.phar composer:dump-autoload --composer-bin=composer-test.php - - - name: PHARBox + PHP + Test script - run: php bin/box.phar composer:dump-autoload --composer-bin=composer-test.php \ No newline at end of file + run: composer dump-autoload \ No newline at end of file From 156d1e40a53f7b72c728692f46b11a09b55a457a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= Date: Fri, 20 Oct 2023 22:13:48 +0200 Subject: [PATCH 17/22] retry --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 8a40b637a..4aad67e34 100644 --- a/composer.json +++ b/composer.json @@ -108,8 +108,8 @@ }, "scripts": { "auto-scripts": { - ".bin/console list -v": "script", - ".bin/console list -vv": "php-script", + "bin/console list -v": "script", + "bin/console list -vv": "php-script", "list --version": "symfony-cmd" }, "post-autoload-dump": [ From 6c9e838a463ce3e39aa0720f7ee40efc68b64fe8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= Date: Fri, 20 Oct 2023 22:14:57 +0200 Subject: [PATCH 18/22] box cmd --- .github/workflows/phar-debug.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/phar-debug.yaml b/.github/workflows/phar-debug.yaml index 8a6a870a5..131d3fdec 100644 --- a/.github/workflows/phar-debug.yaml +++ b/.github/workflows/phar-debug.yaml @@ -23,4 +23,4 @@ jobs: run: composer install --prefer-dist --no-progress --no-scripts - name: regular check - run: composer dump-autoload \ No newline at end of file + run: bin/box composer:dump-autoload -vvv \ No newline at end of file From 7b2be9d1152e21cbfa3d431748aff66b6243c02b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= Date: Fri, 20 Oct 2023 22:21:08 +0200 Subject: [PATCH 19/22] install php --- .github/workflows/phar-debug.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/phar-debug.yaml b/.github/workflows/phar-debug.yaml index 131d3fdec..b2887999f 100644 --- a/.github/workflows/phar-debug.yaml +++ b/.github/workflows/phar-debug.yaml @@ -16,6 +16,13 @@ jobs: steps: - uses: actions/checkout@v3 + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.2' + tools: composer + coverage: none + - name: Install dependencies run: composer install --prefer-dist --no-progress --working-dir=fixtures/build/dir018 --no-scripts From d654748be05ba4796c64594e965204085359b733 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= Date: Sat, 21 Oct 2023 00:01:26 +0200 Subject: [PATCH 20/22] try with persistent --- .github/workflows/phar-debug.yaml | 7 ------- composer.json | 1 + src/Composer/ComposerProcessFactory.php | 1 + src/Console/Command/Composer/ComposerDumpAutoloader.php | 7 +++++++ src/Console/Php/PhpSettingsHandler.php | 1 + 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/phar-debug.yaml b/.github/workflows/phar-debug.yaml index b2887999f..131d3fdec 100644 --- a/.github/workflows/phar-debug.yaml +++ b/.github/workflows/phar-debug.yaml @@ -16,13 +16,6 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.2' - tools: composer - coverage: none - - name: Install dependencies run: composer install --prefer-dist --no-progress --working-dir=fixtures/build/dir018 --no-scripts diff --git a/composer.json b/composer.json index 4aad67e34..ede838be7 100644 --- a/composer.json +++ b/composer.json @@ -109,6 +109,7 @@ "scripts": { "auto-scripts": { "bin/console list -v": "script", + "php bin/console list -v": "script", "bin/console list -vv": "php-script", "list --version": "symfony-cmd" }, diff --git a/src/Composer/ComposerProcessFactory.php b/src/Composer/ComposerProcessFactory.php index 074433a88..684d680d4 100644 --- a/src/Composer/ComposerProcessFactory.php +++ b/src/Composer/ComposerProcessFactory.php @@ -15,6 +15,7 @@ namespace KevinGH\Box\Composer; use Fidry\Console\Input\IO; +use KevinGH\Box\Console\Php\PhpSettingsHandler; use RuntimeException; use Symfony\Component\Process\ExecutableFinder; use Symfony\Component\Process\Process; diff --git a/src/Console/Command/Composer/ComposerDumpAutoloader.php b/src/Console/Command/Composer/ComposerDumpAutoloader.php index 89d9cfbc9..12125b2b9 100644 --- a/src/Console/Command/Composer/ComposerDumpAutoloader.php +++ b/src/Console/Command/Composer/ComposerDumpAutoloader.php @@ -48,6 +48,13 @@ public function getConfiguration(): Configuration protected function orchestrate(ComposerOrchestrator $composerOrchestrator, IO $io): int { check_php_settings($io); + + dd( + PHP_BINARY, + $args = array_slice($_SERVER['argv'], 1), + PhpSettingsHandler::getRestartSettings(), + ); + if (!class_exists('Phar')) { die('no PHAR class'); } diff --git a/src/Console/Php/PhpSettingsHandler.php b/src/Console/Php/PhpSettingsHandler.php index d7ba6d7b8..33d95f5e7 100644 --- a/src/Console/Php/PhpSettingsHandler.php +++ b/src/Console/Php/PhpSettingsHandler.php @@ -74,6 +74,7 @@ protected function restart(array $command): void { // Disable phar.readonly if set $this->disablePharReadonly(); + $this->setPersistent(); parent::restart($command); } From 85cb59384ff3162bfac65d6b039c9a5fbad9ed1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= Date: Sat, 21 Oct 2023 00:02:54 +0200 Subject: [PATCH 21/22] fix --- .../Command/Composer/ComposerDumpAutoloader.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Console/Command/Composer/ComposerDumpAutoloader.php b/src/Console/Command/Composer/ComposerDumpAutoloader.php index 12125b2b9..c6a3bae01 100644 --- a/src/Console/Command/Composer/ComposerDumpAutoloader.php +++ b/src/Console/Command/Composer/ComposerDumpAutoloader.php @@ -49,13 +49,13 @@ protected function orchestrate(ComposerOrchestrator $composerOrchestrator, IO $i { check_php_settings($io); - dd( - PHP_BINARY, - $args = array_slice($_SERVER['argv'], 1), - PhpSettingsHandler::getRestartSettings(), - ); - if (!class_exists('Phar')) { + dump( + PHP_BINARY, + $args = array_slice($_SERVER['argv'], 1), + PhpSettingsHandler::getRestartSettings(), + ); + die('no PHAR class'); } From 1d9adb02ba44e5bc3096f97e0155ffead6bff3fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= Date: Sat, 21 Oct 2023 00:05:37 +0200 Subject: [PATCH 22/22] try fix --- src/Composer/ComposerProcessFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Composer/ComposerProcessFactory.php b/src/Composer/ComposerProcessFactory.php index 684d680d4..5ac5be35b 100644 --- a/src/Composer/ComposerProcessFactory.php +++ b/src/Composer/ComposerProcessFactory.php @@ -125,7 +125,7 @@ private static function retrieveSubProcessVerbosity(IO $io): ?string private static function getDefaultEnvVars(): array { - $vars = []; + $vars = ['COMPOSER_ORIGINAL_INIS' => '']; if ('1' === (string) getenv(BOX_ALLOW_XDEBUG)) { $vars['COMPOSER_ALLOW_XDEBUG'] = '1';