From 231c6b2054a717f37b729c920182cfa8cb320127 Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Mon, 9 Dec 2024 00:52:26 +0900 Subject: [PATCH] =?UTF-8?q?php-cs-fixer=20fix=20--diff=20--dry-run=20--all?= =?UTF-8?q?ow-risky=3Dyes=20=E3=82=92=E5=AE=9F=E8=A1=8C=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit see https://github.com/EC-CUBE/ec-cube2/issues/1025 --- .github/workflows/main.yml | 14 ++++++-- .github/workflows/php-cs-fixer.yml | 53 ++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/php-cs-fixer.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e80a786676..8dbf6e157e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,13 +18,21 @@ jobs: with: event_name: ${{ github.event_name }} uses: ./.github/workflows/dockerbuild.yml - phpstan: + php-cs-fixer: with: ref_name: ${{ github.ref_name }} base_ref: ${{ github.base_ref }} event_name: ${{ github.event_name }} owner: ${{ github.repository_owner }} needs: [ dockerbuild ] + uses: ./.github/workflows/php-cs-fixer.yml + phpstan: + with: + ref_name: ${{ github.ref_name }} + base_ref: ${{ github.base_ref }} + event_name: ${{ github.event_name }} + owner: ${{ github.repository_owner }} + needs: [ php-cs-fixer ] uses: ./.github/workflows/phpstan.yml unit-tests: with: @@ -32,7 +40,7 @@ jobs: base_ref: ${{ github.base_ref }} event_name: ${{ github.event_name }} owner: ${{ github.repository_owner }} - needs: [ dockerbuild ] + needs: [ php-cs-fixer ] uses: ./.github/workflows/unit-tests.yml e2e-tests: with: @@ -40,7 +48,7 @@ jobs: base_ref: ${{ github.base_ref }} event_name: ${{ github.event_name }} owner: ${{ github.repository_owner }} - needs: [ dockerbuild ] + needs: [ php-cs-fixer ] uses: ./.github/workflows/e2e-tests.yml success: needs: diff --git a/.github/workflows/php-cs-fixer.yml b/.github/workflows/php-cs-fixer.yml new file mode 100644 index 0000000000..c0ec27ed8d --- /dev/null +++ b/.github/workflows/php-cs-fixer.yml @@ -0,0 +1,53 @@ +name: php-cs-fixer dry-run +run-name: php-cs-fixer + +on: + workflow_call: + inputs: + ref_name: + required: false + type: string + base_ref: + required: false + type: string + event_name: + required: true + type: string + owner: + required: true + type: string +jobs: + php-cs-fixer: + name: php-cs-fixer + runs-on: ubuntu-latest + steps: + - name: "Checkout" + uses: actions/checkout@v4 + + - name: Build docker image + uses: ./.github/actions/dockerbuild + with: + php-version: '8.4' + + - name: Setup environment + env: + REF_NAME: ${{ inputs.ref_name }} + BASE_REF: ${{ inputs.base_ref }} + EVENT_NAME: ${{ inputs.event_name }} + OWNER: ${{ inputs.owner }} + run: | + echo "COMPOSE_FILE=docker-compose.yml:docker-compose.pgsql.yml:docker-compose.dev.yml" >> $GITHUB_ENV + echo "IMAGE_NAME=${OWNER,,}/ec-cube2-php" >> $GITHUB_ENV + if [ $EVENT_NAME = "pull_request" ]; then + if [ -n $DOCKER_METADATA_OUTPUT_VERSION ]; then + echo "TAG=${DOCKER_METADATA_OUTPUT_VERSION}" >> $GITHUB_ENV + else + echo "TAG=8.3-apache-${BASE_REF}" >> $GITHUB_ENV + fi + else + echo "TAG=8.3-apache-${REF_NAME}" >> $GITHUB_ENV + fi + - run: | + docker compose up -d --wait + docker compose exec -T ec-cube composer install + - run: docker compose exec -T ec-cube php data/vendor/bin/php-cs-fixer fix --diff --dry-run --allow-risky=yes