From 15fa1852a6a1118d8743b01dcc057bcd36fb129b Mon Sep 17 00:00:00 2001 From: Damien Retzinger Date: Sun, 14 Dec 2025 12:14:45 -0500 Subject: [PATCH 1/6] feat(unit-test): add modes --- .github/workflows/_internal-unit.yaml | 3 ++ unit-test/action.yml | 75 ++++++++++++++++++++++++--- 2 files changed, 72 insertions(+), 6 deletions(-) diff --git a/.github/workflows/_internal-unit.yaml b/.github/workflows/_internal-unit.yaml index 8fc18ef..456b8d2 100644 --- a/.github/workflows/_internal-unit.yaml +++ b/.github/workflows/_internal-unit.yaml @@ -26,6 +26,8 @@ jobs: - 8.2 - 8.3 - 8.4 + mode: + - standalone runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 @@ -33,3 +35,4 @@ jobs: with: source_folder: _test/demo-package php_version: ${{ matrix.php_version }} + mode: ${{ matrix.mode }} diff --git a/unit-test/action.yml b/unit-test/action.yml index ffef656..cb95aac 100644 --- a/unit-test/action.yml +++ b/unit-test/action.yml @@ -2,11 +2,16 @@ name: "Unit Test" author: "Graycore" description: "A Github Action that runs the Unit Tests of a Magento Package" inputs: - php_version: + php_version: required: true default: "8.4" description: "PHP Version to use" + mode: + required: false + default: "standalone" + description: "Test mode: 'standalone' (existing behavior), 'extension' (uses setup-magento with extension mode), or 'store' (uses setup-magento with store mode)" + source_folder: required: true default: . @@ -21,30 +26,88 @@ inputs: required: false description: "Composer Authentication Credentials" + magento_version: + required: false + default: "magento/project-community-edition:2.4.8-p3" + description: "Magento version to install (extension/store modes only)" + + magento_repository: + required: false + default: "https://mirror.mage-os.org/" + description: "Composer repository URL for Magento packages (extension/store modes only)" + runs: using: "composite" - steps: + steps: + # Standalone mode: just set up PHP - name: Set PHP Version + if: inputs.mode == 'standalone' uses: shivammathur/setup-php@v2 with: php-version: ${{ inputs.php_version }} + # Extension mode: use setup-magento to create a Magento instance + - name: Setup Magento (extension mode) + if: inputs.mode == 'extension' + id: setup-magento-extension + uses: graycoreio/github-actions-magento/setup-magento@main + with: + php-version: ${{ inputs.php_version }} + mode: extension + magento_version: ${{ inputs.magento_version }} + magento_repository: ${{ inputs.magento_repository }} + composer_auth: ${{ inputs.composer_auth }} + + - name: Add extension repository + if: inputs.mode == 'extension' + shell: bash + working-directory: ${{ steps.setup-magento-extension.outputs.path }} + run: composer config repositories.local path ${{ github.workspace }}/${{ inputs.source_folder }} + + # Store mode: use setup-magento with existing project + - name: Setup Magento (store mode) + if: inputs.mode == 'store' + id: setup-magento-store + uses: graycoreio/github-actions-magento/setup-magento@main + with: + php-version: ${{ inputs.php_version }} + mode: store + working-directory: ${{ inputs.source_folder }} + magento_repository: ${{ inputs.magento_repository }} + composer_auth: ${{ inputs.composer_auth }} + + # Compute working directory based on mode + - name: Compute working directory + id: compute-workdir + shell: bash + run: | + if [ "${{ inputs.mode }}" = "extension" ]; then + echo "workdir=${{ steps.setup-magento-extension.outputs.path }}" >> $GITHUB_OUTPUT + elif [ "${{ inputs.mode }}" = "store" ]; then + echo "workdir=${{ steps.setup-magento-store.outputs.path }}" >> $GITHUB_OUTPUT + else + echo "workdir=${{ inputs.source_folder }}" >> $GITHUB_OUTPUT + fi + - name: Get Composer Cache Directory shell: bash - working-directory: ${{ inputs.source_folder }} + if: inputs.mode == 'standalone' + working-directory: ${{ steps.compute-workdir.outputs.workdir }} id: composer-cache run: | echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - name: "Cache Composer Packages" + if: inputs.mode == 'standalone' uses: actions/cache@v5 with: key: "composer | v4 | ${{ hashFiles('composer.lock') }} | ${{ runner.os }} | ${{ inputs.php_version }}" path: ${{ steps.composer-cache.outputs.dir }} - run: composer install - name: Require and attempt install - working-directory: ${{ inputs.source_folder }} + if: inputs.mode == 'standalone' + name: Composer install + working-directory: ${{ steps.compute-workdir.outputs.workdir }} shell: bash env: COMPOSER_CACHE_DIR: ${{ steps.composer-cache.outputs.dir }} @@ -52,7 +115,7 @@ runs: - run: ${{ inputs.test_command }} name: Run Unit Tests - working-directory: ${{ inputs.source_folder }} + working-directory: ${{ steps.compute-workdir.outputs.workdir }} shell: bash env: COMPOSER_CACHE_DIR: ${{ steps.composer-cache.outputs.dir }} From 7cec6191f4d5d59347f5e803d7589b08598b0243 Mon Sep 17 00:00:00 2001 From: Damien Retzinger Date: Sun, 14 Dec 2025 12:16:11 -0500 Subject: [PATCH 2/6] add fix repo anme --- unit-test/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/unit-test/action.yml b/unit-test/action.yml index cb95aac..df570be 100644 --- a/unit-test/action.yml +++ b/unit-test/action.yml @@ -50,7 +50,7 @@ runs: - name: Setup Magento (extension mode) if: inputs.mode == 'extension' id: setup-magento-extension - uses: graycoreio/github-actions-magento/setup-magento@main + uses: graycoreio/github-actions-magento2/setup-magento@main with: php-version: ${{ inputs.php_version }} mode: extension @@ -68,7 +68,7 @@ runs: - name: Setup Magento (store mode) if: inputs.mode == 'store' id: setup-magento-store - uses: graycoreio/github-actions-magento/setup-magento@main + uses: graycoreio/github-actions-magento2/setup-magento@main with: php-version: ${{ inputs.php_version }} mode: store From e7d8cf98ab6192bc55ba42bc1b22790bb79a54aa Mon Sep 17 00:00:00 2001 From: Damien Retzinger Date: Sun, 14 Dec 2025 12:17:14 -0500 Subject: [PATCH 3/6] test modes --- .github/workflows/_internal-unit.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/_internal-unit.yaml b/.github/workflows/_internal-unit.yaml index 456b8d2..c51a73f 100644 --- a/.github/workflows/_internal-unit.yaml +++ b/.github/workflows/_internal-unit.yaml @@ -28,6 +28,8 @@ jobs: - 8.4 mode: - standalone + - store + - extension runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 From 6d6dbaec3105ee23d2b9d82e1e015d6d37e25556 Mon Sep 17 00:00:00 2001 From: Damien Retzinger Date: Sun, 14 Dec 2025 12:23:32 -0500 Subject: [PATCH 4/6] install --- unit-test/action.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/unit-test/action.yml b/unit-test/action.yml index df570be..2aabc94 100644 --- a/unit-test/action.yml +++ b/unit-test/action.yml @@ -105,7 +105,6 @@ runs: path: ${{ steps.composer-cache.outputs.dir }} - run: composer install - if: inputs.mode == 'standalone' name: Composer install working-directory: ${{ steps.compute-workdir.outputs.workdir }} shell: bash From 1892c590a35bb25e53216be9deb9cb8a3ecc5fb0 Mon Sep 17 00:00:00 2001 From: Damien Retzinger Date: Sun, 14 Dec 2025 12:28:50 -0500 Subject: [PATCH 5/6] install --- .github/workflows/_internal-unit.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/_internal-unit.yaml b/.github/workflows/_internal-unit.yaml index c51a73f..2ab62cf 100644 --- a/.github/workflows/_internal-unit.yaml +++ b/.github/workflows/_internal-unit.yaml @@ -23,7 +23,6 @@ jobs: strategy: matrix: php_version: - - 8.2 - 8.3 - 8.4 mode: From c184b38d99608a8437255926ae8efcca7d259773 Mon Sep 17 00:00:00 2001 From: Damien Retzinger Date: Sun, 14 Dec 2025 12:32:39 -0500 Subject: [PATCH 6/6] test --- .github/workflows/_internal-setup-magento.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/_internal-setup-magento.yaml b/.github/workflows/_internal-setup-magento.yaml index a0e7513..3c319c0 100644 --- a/.github/workflows/_internal-setup-magento.yaml +++ b/.github/workflows/_internal-setup-magento.yaml @@ -100,7 +100,10 @@ jobs: mode: store working-directory: ${{ env.magento_folder }} composer_auth: ${{ secrets.COMPOSER_AUTH }} - + + - run: echo "Magento path:${{ steps.setup-magento.outputs.path }}" + name: Log Magento path + - uses: graycoreio/github-actions-magento2/cache-magento@main with: mode: 'store'