From dddc7aabd4a490822895ead28ef9588f6ba1423c Mon Sep 17 00:00:00 2001 From: adamzero1 Date: Sun, 9 Apr 2023 08:10:40 +0000 Subject: [PATCH 01/14] work --- ...andard.yml => coding-standard.yml.disable} | 0 ...yml => merge-upstream-changes.yml.disable} | 0 ...ecker.yml => semantic-checker.yml.disable} | 0 .github/workflows/unit-tests.yml | 115 ++++++++++++++++++ 4 files changed, 115 insertions(+) rename .github/workflows/{coding-standard.yml => coding-standard.yml.disable} (100%) rename .github/workflows/{merge-upstream-changes.yml => merge-upstream-changes.yml.disable} (100%) rename .github/workflows/{semantic-checker.yml => semantic-checker.yml.disable} (100%) create mode 100644 .github/workflows/unit-tests.yml diff --git a/.github/workflows/coding-standard.yml b/.github/workflows/coding-standard.yml.disable similarity index 100% rename from .github/workflows/coding-standard.yml rename to .github/workflows/coding-standard.yml.disable diff --git a/.github/workflows/merge-upstream-changes.yml b/.github/workflows/merge-upstream-changes.yml.disable similarity index 100% rename from .github/workflows/merge-upstream-changes.yml rename to .github/workflows/merge-upstream-changes.yml.disable diff --git a/.github/workflows/semantic-checker.yml b/.github/workflows/semantic-checker.yml.disable similarity index 100% rename from .github/workflows/semantic-checker.yml rename to .github/workflows/semantic-checker.yml.disable diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml new file mode 100644 index 0000000000000..7e0531c9c3b49 --- /dev/null +++ b/.github/workflows/unit-tests.yml @@ -0,0 +1,115 @@ +name: Unit Tests +run-name: ${{ github.actor }} is running Unit Tests +on: + pull_request: + branches: + - 2.4-develop + - nx-work + +permissions: + contents: write + +jobs: + unit-tests: + strategy: + matrix: + php_version: [8.1,8.2] + runs-on: ubuntu-latest + steps: + - name: Checkout PR commit + uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.sha }} + path: main + # Need to do this otherwise Nx cant determine diff + fetch-depth: 0 + + - name: Fetch base + working-directory: ./main + run: git fetch origin ${{ github.event.pull_request.base.ref }} + + - name: Install Composer + uses: php-actions/composer@v6 + with: + # Run the dummy help command after installing Composer (otherwise defaults to install) + command: help + + - name: Get Composer Cache Directory + id: composer-cache + working-directory: ./main + run: echo "composer_cache_dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - name: Install Composer Cache + uses: actions/cache@v3 + with: + path: ${{ steps.composer-cache.outputs.composer_cache_dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/main/composer.lock') }} + restore-keys: | + ${{ runner.os }}-composer- + - name: Install Composer Dependencies + working-directory: ./main + run: composer install + + - name: Checkout Nx Repo + uses: actions/checkout@v3 + with: + repository: adamzero1/nx-for-php + ref: docker-wrapper + path: nx + + - name: Install / setup Nx + working-directory: ./main + run: | + npm install -g nx@15.4.1 + NXDIR="../nx" + cp -r ${NXDIR}/nx ./ + cp ${NXDIR}/nx.json ./ + cp ${NXDIR}/package.json ./ + cp ${NXDIR}/package-lock.json ./ + cp ${NXDIR}/phpunit.mage-os.nx.xml ./phpunit.nx.xml + npm ci + npm run generate-workspace + - name: Print Affected + working-directory: ./main + run: | + AFFECTED_OUTPUT=/tmp/affect.json + nx print-affected --head=HEAD --base=remotes/origin/${{ github.event.pull_request.base.ref }} > ${AFFECTED_OUTPUT} + echo "Affected Projects: $(jq .projects ${AFFECTED_OUTPUT})" + + # Warden / Den stuff + - name: Checkout Den Repo + uses: actions/checkout@v3 + with: + repository: swiftotter/den + path: den + + - name: Init / Configure Den + working-directory: ./main + run: | + DEN=/home/runner/work/magento2/magento2/den/bin/den + ${DEN} env-init magento2 magento2 + sed -i 's/WARDEN_DB=.*/WARDEN_DB=0/g' .env + sed -i 's/WARDEN_TEST_DB=.*/WARDEN_TEST_DB=0/g' .env + sed -i 's/WARDEN_ELASTICSEARCH=.*/WARDEN_ELASTICSEARCH=0/g' .env + sed -i 's/WARDEN_OPENSEARCH=.*/WARDEN_OPENSEARCH=0/g' .env + sed -i 's/WARDEN_ELASTICHQ=.*/WARDEN_ELASTICHQ=0/g' .env + sed -i 's/WARDEN_VARNISH=.*/WARDEN_VARNISH=0/g' .env + sed -i 's/WARDEN_RABBITMQ=.*/WARDEN_RABBITMQ=0/g' .env + sed -i 's/WARDEN_REDIS=.*/WARDEN_REDIS=0/g' .env + sed -i 's/PHP_VERSION=.*/PHP_VERSION=${{ matrix.php_version }}/g' .env + ${DEN} env up + echo ${{secrets.DEPLOY_PASSWORD}} | sudo -S chmod -R a+rw . + # # Unit test command test + # - name: Run PHPUnit + # working-directory: ./main + # run: | + # DEN=/home/runner/work/magento2/magento2/den/bin/den + # ${DEN} env exec -T php-fpm ./vendor/bin/phpunit --help + # ${DEN} env exec -T php-fpm whoami + # ${DEN} env exec -T php-fpm ls -lath + + - name: Run PHPUnit Nx + working-directory: ./main + run: | + export DEN=/home/runner/work/magento2/magento2/den/bin/den + nx affected --target=test:test --head=HEAD --base=remotes/origin/${{ github.event.pull_request.base.ref }} \ No newline at end of file From 2c951e5a027dd6bd8f3ce52d61477c6d70617f18 Mon Sep 17 00:00:00 2001 From: adamzero1 Date: Sun, 9 Apr 2023 08:12:14 +0000 Subject: [PATCH 02/14] work --- .github/workflows/unit-tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 7e0531c9c3b49..c1492e0a28504 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -12,6 +12,7 @@ permissions: jobs: unit-tests: strategy: + fail-fast: false matrix: php_version: [8.1,8.2] runs-on: ubuntu-latest From 8fe2589b5aa8beecb752f525ed6a76ea48585cad Mon Sep 17 00:00:00 2001 From: adamzero1 Date: Sun, 9 Apr 2023 12:37:07 +0000 Subject: [PATCH 03/14] work --- .../AdminAnalytics/Model/Condition/CanViewNotification.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/AdminAnalytics/Model/Condition/CanViewNotification.php b/app/code/Magento/AdminAnalytics/Model/Condition/CanViewNotification.php index 222261d4abfb5..469540aee928a 100644 --- a/app/code/Magento/AdminAnalytics/Model/Condition/CanViewNotification.php +++ b/app/code/Magento/AdminAnalytics/Model/Condition/CanViewNotification.php @@ -31,6 +31,7 @@ class CanViewNotification implements VisibilityConditionInterface private static $cachePrefix = 'admin-usage-notification-popup'; /** + * aaaaaa * @var Logger */ private $viewerLogger; From 6a28e09bbd95ff48cce35a09753eec2dfa514148 Mon Sep 17 00:00:00 2001 From: adamzero1 Date: Sun, 9 Apr 2023 12:49:09 +0000 Subject: [PATCH 04/14] work --- .../AdminNotification/Controller/Adminhtml/Notification.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification.php b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification.php index cb50a9d0705bb..bcaeb204f63f6 100644 --- a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification.php +++ b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification.php @@ -14,7 +14,7 @@ abstract class Notification extends \Magento\Backend\App\AbstractAction { /** - * Authorization level of a basic admin session + * Authorization level of a basic admin session... */ const ADMIN_RESOURCE = 'Magento_AdminNotification::show_list'; } From ab8d3cbd478daa553fe8d9182d6e224a5aa1e0df Mon Sep 17 00:00:00 2001 From: adamzero1 Date: Sun, 9 Apr 2023 13:21:59 +0000 Subject: [PATCH 05/14] work --- dev/tests/unit/phpunit.xml | 55 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 dev/tests/unit/phpunit.xml diff --git a/dev/tests/unit/phpunit.xml b/dev/tests/unit/phpunit.xml new file mode 100644 index 0000000000000..7d3a838a58ffa --- /dev/null +++ b/dev/tests/unit/phpunit.xml @@ -0,0 +1,55 @@ + + + + + + ../../../app/code/* + ../../../lib/internal/Magento + ../../../setup/src/* + + + ../../../app/code/*/*/Test + ../../../lib/internal/*/*/Test + ../../../lib/internal/*/*/*/Test + ../../../setup/src/*/*/Test + + + + + ../../../app/code/*/*/Test/Unit + ../../../vendor/magento/module-*/Test/Unit + ../../../app/code/Magento/Indexer/Test/Unit + + + ../../../app/code/*/Indexer/Test/Unit + + + ../../../lib/internal/*/*/Test/Unit + ../../../lib/internal/*/*/*/Test/Unit + ../../../setup/src/*/*/Test/Unit + ../../../vendor/*/module-*/Test/Unit + ../../../vendor/*/framework/Test/Unit + ../../../vendor/*/framework/*/Test/Unit + ../../tests/unit/*/Test/Unit + + + + . + + + + + + + + From 4045fe799dbc95044087a5ed0c06f4997c1465f7 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 9 Apr 2023 15:00:55 +0000 Subject: [PATCH 06/14] fix: right to left mark --- .../Magento/Directory/Test/Unit/Model/CurrencyTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Directory/Test/Unit/Model/CurrencyTest.php b/app/code/Magento/Directory/Test/Unit/Model/CurrencyTest.php index a3a6b6826366f..c341ea8c059eb 100644 --- a/app/code/Magento/Directory/Test/Unit/Model/CurrencyTest.php +++ b/app/code/Magento/Directory/Test/Unit/Model/CurrencyTest.php @@ -205,8 +205,8 @@ public function getFormatTxtNumberFormatterDataProvider(): array ['en_US', 'USD', '9999', [], '$9,999.00'], ['en_US', 'EUR', '9999', [], '€9,999.00'], ['en_US', 'LBP', '9999', [], "LBP\u{00A0}9,999"], - ['ar_SA', 'USD', '9', [], "\u{0669}\u{066B}\u{0660}\u{0660}\u{00A0}US$"], - ['ar_SA', 'AED', '9', [], "\u{0669}\u{066B}\u{0660}\u{0660}\u{00A0}\u{062F}.\u{0625}.\u{200F}"], + ['ar_SA', 'USD', '9', [], "‏\u{0669}\u{066B}\u{0660}\u{0660}\u{00A0}US$"], + ['ar_SA', 'AED', '9', [], "‏\u{0669}\u{066B}\u{0660}\u{0660}\u{00A0}\u{062F}.\u{0625}.\u{200F}"], ['de_DE', 'USD', '9999', [], "9.999,00\u{00A0}$"], ['de_DE', 'EUR', '9999', [], "9.999,00\u{00A0}€"], ['en_US', 'USD', '9999', ['display' => CurrencyData::NO_SYMBOL, 'precision' => 2], '9,999.00'], @@ -218,14 +218,14 @@ public function getFormatTxtNumberFormatterDataProvider(): array 'USD', '9999', ['display' => CurrencyData::NO_SYMBOL], - "\u{0669}\u{066C}\u{0669}\u{0669}\u{0669}\u{066B}\u{0660}\u{0660}" + "‏\u{0669}\u{066C}\u{0669}\u{0669}\u{0669}\u{066B}\u{0660}\u{0660}" ], [ 'ar_SA', 'AED', '9999', ['display' => CurrencyData::NO_SYMBOL], - "\u{0669}\u{066C}\u{0669}\u{0669}\u{0669}\u{066B}\u{0660}\u{0660}" + "‏\u{0669}\u{066C}\u{0669}\u{0669}\u{0669}\u{066B}\u{0660}\u{0660}" ], ['en_US', 'USD', ' 9999', ['display' => CurrencyData::NO_SYMBOL], '9,999.00'], ['en_US', 'USD', '9999', ['precision' => 1], '$9,999.0'], From 83172fc3cffd5f818eb2f0bb207314fe02903f68 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 9 Apr 2023 15:27:33 +0000 Subject: [PATCH 07/14] fix: currency conversion --- .../Test/Unit/Model/CurrencyTest.php | 37 ++++++++++++++----- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/app/code/Magento/Directory/Test/Unit/Model/CurrencyTest.php b/app/code/Magento/Directory/Test/Unit/Model/CurrencyTest.php index c341ea8c059eb..e82505c21745b 100644 --- a/app/code/Magento/Directory/Test/Unit/Model/CurrencyTest.php +++ b/app/code/Magento/Directory/Test/Unit/Model/CurrencyTest.php @@ -128,7 +128,26 @@ function (array $args) { ); $this->currency->load($currency); - self::assertEquals($expected, $this->currency->getOutputFormat()); + $output = $this->currency->getOutputFormat(); + if($expected !== $output){ + file_put_contents('adam.log', 'Excepted: '.$expected.PHP_EOL, FILE_APPEND); + file_put_contents('adam.log', 'Output: '.$output.PHP_EOL, FILE_APPEND); + file_put_contents('adam.log', ''.PHP_EOL, FILE_APPEND); + } + self::assertEquals($expected, $output); + } + + protected function strigToBinary($string) + { + $characters = str_split($string); + + $binary = []; + foreach ($characters as $character) { + $data = unpack('H*', $character); + $binary[] = base_convert($data[1], 16, 2); + } + + return implode(' ', $binary); } /** @@ -143,11 +162,11 @@ public function getOutputFormatDataProvider(): array 'en_US:PLN' => ['en_US', 'PLN', "PLN\u{00A0}%s"], 'en_US:PKR' => ['en_US', 'PKR', "PKR\u{00A0}%s"], 'af_ZA:VND' => ['af_ZA', 'VND', "\u{20AB}%s"], - 'ar_DZ:EGP' => ['ar_DZ', 'EGP', "\u{062C}.\u{0645}.\u{200F}\u{00A0}%s"], - 'ar_SA:USD' => ['ar_SA', 'USD', "%s\u{00A0}US$"], - 'ar_SA:LBP' => ['ar_SA', 'LBP', "%s\u{00A0}\u{0644}.\u{0644}.\u{200F}"], + 'ar_DZ:EGP' => ['ar_DZ', 'EGP', "\u{200F}%s\u{00A0}\u{062C}.\u{0645}.\u{200F}"], + 'ar_SA:USD' => ['ar_SA', 'USD', "\u{200F}%s\u{00A0}US$"], + 'ar_SA:LBP' => ['ar_SA', 'LBP', "\u{200F}%s\u{00A0}\u{0644}.\u{0644}.\u{200F}"], 'fa_IR:USD' => ['fa_IR', 'USD', "\u{200E}$%s"], - 'ar_KW:USD' => ['ar_KW', 'USD', "%s\u{00A0}US$"], + 'ar_KW:USD' => ['ar_KW', 'USD', "\u{200F}%s\u{00A0}US$"], 'bn_BD:IQD' => ['bn_BD', 'IQD', "%s\u{00A0}IQD"], 'ca_ES:VND' => ['ca_ES', 'VND', "%s\u{00A0}\u{20AB}"], 'de_DE:USD' => ['de_DE', 'USD', "%s\u{00A0}$"], @@ -205,8 +224,8 @@ public function getFormatTxtNumberFormatterDataProvider(): array ['en_US', 'USD', '9999', [], '$9,999.00'], ['en_US', 'EUR', '9999', [], '€9,999.00'], ['en_US', 'LBP', '9999', [], "LBP\u{00A0}9,999"], - ['ar_SA', 'USD', '9', [], "‏\u{0669}\u{066B}\u{0660}\u{0660}\u{00A0}US$"], - ['ar_SA', 'AED', '9', [], "‏\u{0669}\u{066B}\u{0660}\u{0660}\u{00A0}\u{062F}.\u{0625}.\u{200F}"], + ['ar_SA', 'USD', '9', [], "\u{200F}\u{0669}\u{066B}\u{0660}\u{0660}\u{00A0}US$"], + ['ar_SA', 'AED', '9', [], "\u{200F}\u{0669}\u{066B}\u{0660}\u{0660}\u{00A0}\u{062F}.\u{0625}.\u{200F}"], ['de_DE', 'USD', '9999', [], "9.999,00\u{00A0}$"], ['de_DE', 'EUR', '9999', [], "9.999,00\u{00A0}€"], ['en_US', 'USD', '9999', ['display' => CurrencyData::NO_SYMBOL, 'precision' => 2], '9,999.00'], @@ -218,14 +237,14 @@ public function getFormatTxtNumberFormatterDataProvider(): array 'USD', '9999', ['display' => CurrencyData::NO_SYMBOL], - "‏\u{0669}\u{066C}\u{0669}\u{0669}\u{0669}\u{066B}\u{0660}\u{0660}" + "\u{200F}\u{0669}\u{066C}\u{0669}\u{0669}\u{0669}\u{066B}\u{0660}\u{0660}" ], [ 'ar_SA', 'AED', '9999', ['display' => CurrencyData::NO_SYMBOL], - "‏\u{0669}\u{066C}\u{0669}\u{0669}\u{0669}\u{066B}\u{0660}\u{0660}" + "\u{200F}\u{0669}\u{066C}\u{0669}\u{0669}\u{0669}\u{066B}\u{0660}\u{0660}" ], ['en_US', 'USD', ' 9999', ['display' => CurrencyData::NO_SYMBOL], '9,999.00'], ['en_US', 'USD', '9999', ['precision' => 1], '$9,999.0'], From 5f8feb7fd499bbfcd81fe78f2530548d584c7cc5 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 9 Apr 2023 15:28:45 +0000 Subject: [PATCH 08/14] removing debug --- .../Directory/Test/Unit/Model/CurrencyTest.php | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/app/code/Magento/Directory/Test/Unit/Model/CurrencyTest.php b/app/code/Magento/Directory/Test/Unit/Model/CurrencyTest.php index e82505c21745b..eb0752a225199 100644 --- a/app/code/Magento/Directory/Test/Unit/Model/CurrencyTest.php +++ b/app/code/Magento/Directory/Test/Unit/Model/CurrencyTest.php @@ -137,19 +137,6 @@ function (array $args) { self::assertEquals($expected, $output); } - protected function strigToBinary($string) - { - $characters = str_split($string); - - $binary = []; - foreach ($characters as $character) { - $data = unpack('H*', $character); - $binary[] = base_convert($data[1], 16, 2); - } - - return implode(' ', $binary); - } - /** * Return data sets for testGetOutputFormat() * From 86b7334152a91fd4d6f32f380b1efe550cf53f13 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 9 Apr 2023 15:30:30 +0000 Subject: [PATCH 09/14] removing debug --- .../Magento/Directory/Test/Unit/Model/CurrencyTest.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/app/code/Magento/Directory/Test/Unit/Model/CurrencyTest.php b/app/code/Magento/Directory/Test/Unit/Model/CurrencyTest.php index eb0752a225199..7fdafafe2d7fb 100644 --- a/app/code/Magento/Directory/Test/Unit/Model/CurrencyTest.php +++ b/app/code/Magento/Directory/Test/Unit/Model/CurrencyTest.php @@ -128,13 +128,7 @@ function (array $args) { ); $this->currency->load($currency); - $output = $this->currency->getOutputFormat(); - if($expected !== $output){ - file_put_contents('adam.log', 'Excepted: '.$expected.PHP_EOL, FILE_APPEND); - file_put_contents('adam.log', 'Output: '.$output.PHP_EOL, FILE_APPEND); - file_put_contents('adam.log', ''.PHP_EOL, FILE_APPEND); - } - self::assertEquals($expected, $output); + self::assertEquals($expected, $this->currency->getOutputFormat()); } /** From f20a4fcd377963214514f42481378ad96479de49 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 9 Apr 2023 15:37:17 +0000 Subject: [PATCH 10/14] work --- .../AdminNotification/Controller/Adminhtml/Notification.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification.php b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification.php index bcaeb204f63f6..cb50a9d0705bb 100644 --- a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification.php +++ b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification.php @@ -14,7 +14,7 @@ abstract class Notification extends \Magento\Backend\App\AbstractAction { /** - * Authorization level of a basic admin session... + * Authorization level of a basic admin session */ const ADMIN_RESOURCE = 'Magento_AdminNotification::show_list'; } From 242201d574a9cdf64380420ef1b09ccbf5abf6ff Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 9 Apr 2023 15:46:29 +0000 Subject: [PATCH 11/14] work --- .github/workflows/unit-tests.yml | 9 ++++-- dev/tests/unit/phpunit.xml | 55 -------------------------------- 2 files changed, 7 insertions(+), 57 deletions(-) delete mode 100644 dev/tests/unit/phpunit.xml diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index c1492e0a28504..2f0a73fa1acf8 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -67,7 +67,6 @@ jobs: cp ${NXDIR}/nx.json ./ cp ${NXDIR}/package.json ./ cp ${NXDIR}/package-lock.json ./ - cp ${NXDIR}/phpunit.mage-os.nx.xml ./phpunit.nx.xml npm ci npm run generate-workspace - name: Print Affected @@ -109,8 +108,14 @@ jobs: # ${DEN} env exec -T php-fpm whoami # ${DEN} env exec -T php-fpm ls -lath + - name: Configure PHPUnit + working-directory: ./main + run: | + cp dev/tests/unit/phpunit.xml.dist dev/tests/unit/phpunit.xml + sed -i '//,/<\/extensions>/d' dev/tests/unit/phpunit.xml + - name: Run PHPUnit Nx working-directory: ./main run: | export DEN=/home/runner/work/magento2/magento2/den/bin/den - nx affected --target=test:test --head=HEAD --base=remotes/origin/${{ github.event.pull_request.base.ref }} \ No newline at end of file + nx affected --target=test:unit --head=HEAD --base=remotes/origin/${{ github.event.pull_request.base.ref }} \ No newline at end of file diff --git a/dev/tests/unit/phpunit.xml b/dev/tests/unit/phpunit.xml deleted file mode 100644 index 7d3a838a58ffa..0000000000000 --- a/dev/tests/unit/phpunit.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - ../../../app/code/* - ../../../lib/internal/Magento - ../../../setup/src/* - - - ../../../app/code/*/*/Test - ../../../lib/internal/*/*/Test - ../../../lib/internal/*/*/*/Test - ../../../setup/src/*/*/Test - - - - - ../../../app/code/*/*/Test/Unit - ../../../vendor/magento/module-*/Test/Unit - ../../../app/code/Magento/Indexer/Test/Unit - - - ../../../app/code/*/Indexer/Test/Unit - - - ../../../lib/internal/*/*/Test/Unit - ../../../lib/internal/*/*/*/Test/Unit - ../../../setup/src/*/*/Test/Unit - ../../../vendor/*/module-*/Test/Unit - ../../../vendor/*/framework/Test/Unit - ../../../vendor/*/framework/*/Test/Unit - ../../tests/unit/*/Test/Unit - - - - . - - - - - - - - From d9355164e6ebde9eee6e20a6469b383396492d81 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 24 Apr 2023 16:46:26 +0100 Subject: [PATCH 12/14] aaaaa --- .github/workflows/unit-tests.yml | 214 +++++++++++++++++-------------- supported-services.json | 8 ++ 2 files changed, 123 insertions(+), 99 deletions(-) create mode 100644 supported-services.json diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 2f0a73fa1acf8..26865a33ca718 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -10,112 +10,128 @@ permissions: contents: write jobs: - unit-tests: - strategy: - fail-fast: false - matrix: - php_version: [8.1,8.2] - runs-on: ubuntu-latest - steps: - - name: Checkout PR commit - uses: actions/checkout@v3 - with: - ref: ${{ github.event.pull_request.head.sha }} - path: main - # Need to do this otherwise Nx cant determine diff - fetch-depth: 0 + run-unit-tests: + uses: adamzero1/mage-os-infrastructure/.github/workflows/unit-tests.yml@nx-unit-testing - - name: Fetch base - working-directory: ./main - run: git fetch origin ${{ github.event.pull_request.base.ref }} - - name: Install Composer - uses: php-actions/composer@v6 - with: - # Run the dummy help command after installing Composer (otherwise defaults to install) - command: help +# name: Unit Tests +# run-name: ${{ github.actor }} is running Unit Tests +# on: +# pull_request: +# branches: +# - 2.4-develop +# - nx-work - - name: Get Composer Cache Directory - id: composer-cache - working-directory: ./main - run: echo "composer_cache_dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT +# permissions: +# contents: write - - name: Install Composer Cache - uses: actions/cache@v3 - with: - path: ${{ steps.composer-cache.outputs.composer_cache_dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/main/composer.lock') }} - restore-keys: | - ${{ runner.os }}-composer- - - name: Install Composer Dependencies - working-directory: ./main - run: composer install +# jobs: +# unit-tests: +# strategy: +# fail-fast: false +# matrix: +# php_version: [8.1,8.2] +# runs-on: ubuntu-latest +# steps: +# - name: Checkout PR commit +# uses: actions/checkout@v3 +# with: +# ref: ${{ github.event.pull_request.head.sha }} +# path: main +# # Need to do this otherwise Nx cant determine diff +# fetch-depth: 0 - - name: Checkout Nx Repo - uses: actions/checkout@v3 - with: - repository: adamzero1/nx-for-php - ref: docker-wrapper - path: nx +# - name: Fetch base +# working-directory: ./main +# run: git fetch origin ${{ github.event.pull_request.base.ref }} - - name: Install / setup Nx - working-directory: ./main - run: | - npm install -g nx@15.4.1 - NXDIR="../nx" - cp -r ${NXDIR}/nx ./ - cp ${NXDIR}/nx.json ./ - cp ${NXDIR}/package.json ./ - cp ${NXDIR}/package-lock.json ./ - npm ci - npm run generate-workspace - - name: Print Affected - working-directory: ./main - run: | - AFFECTED_OUTPUT=/tmp/affect.json - nx print-affected --head=HEAD --base=remotes/origin/${{ github.event.pull_request.base.ref }} > ${AFFECTED_OUTPUT} - echo "Affected Projects: $(jq .projects ${AFFECTED_OUTPUT})" +# - name: Install Composer +# uses: php-actions/composer@v6 +# with: +# # Run the dummy help command after installing Composer (otherwise defaults to install) +# command: help + +# - name: Get Composer Cache Directory +# id: composer-cache +# working-directory: ./main +# run: echo "composer_cache_dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + +# - name: Install Composer Cache +# uses: actions/cache@v3 +# with: +# path: ${{ steps.composer-cache.outputs.composer_cache_dir }} +# key: ${{ runner.os }}-composer-${{ hashFiles('**/main/composer.lock') }} +# restore-keys: | +# ${{ runner.os }}-composer- +# - name: Install Composer Dependencies +# working-directory: ./main +# run: composer install + +# - name: Checkout Nx Repo +# uses: actions/checkout@v3 +# with: +# repository: adamzero1/nx-for-php +# ref: docker-wrapper +# path: nx + +# - name: Install / setup Nx +# working-directory: ./main +# run: | +# npm install -g nx@15.4.1 +# NXDIR="../nx" +# cp -r ${NXDIR}/nx ./ +# cp ${NXDIR}/nx.json ./ +# cp ${NXDIR}/package.json ./ +# cp ${NXDIR}/package-lock.json ./ +# npm ci +# npm run generate-workspace +# - name: Print Affected +# working-directory: ./main +# run: | +# AFFECTED_OUTPUT=/tmp/affect.json +# nx print-affected --head=HEAD --base=remotes/origin/${{ github.event.pull_request.base.ref }} > ${AFFECTED_OUTPUT} +# echo "Affected Projects: $(jq .projects ${AFFECTED_OUTPUT})" - # Warden / Den stuff - - name: Checkout Den Repo - uses: actions/checkout@v3 - with: - repository: swiftotter/den - path: den +# # Warden / Den stuff +# - name: Checkout Den Repo +# uses: actions/checkout@v3 +# with: +# repository: swiftotter/den +# path: den - - name: Init / Configure Den - working-directory: ./main - run: | - DEN=/home/runner/work/magento2/magento2/den/bin/den - ${DEN} env-init magento2 magento2 - sed -i 's/WARDEN_DB=.*/WARDEN_DB=0/g' .env - sed -i 's/WARDEN_TEST_DB=.*/WARDEN_TEST_DB=0/g' .env - sed -i 's/WARDEN_ELASTICSEARCH=.*/WARDEN_ELASTICSEARCH=0/g' .env - sed -i 's/WARDEN_OPENSEARCH=.*/WARDEN_OPENSEARCH=0/g' .env - sed -i 's/WARDEN_ELASTICHQ=.*/WARDEN_ELASTICHQ=0/g' .env - sed -i 's/WARDEN_VARNISH=.*/WARDEN_VARNISH=0/g' .env - sed -i 's/WARDEN_RABBITMQ=.*/WARDEN_RABBITMQ=0/g' .env - sed -i 's/WARDEN_REDIS=.*/WARDEN_REDIS=0/g' .env - sed -i 's/PHP_VERSION=.*/PHP_VERSION=${{ matrix.php_version }}/g' .env - ${DEN} env up - echo ${{secrets.DEPLOY_PASSWORD}} | sudo -S chmod -R a+rw . - # # Unit test command test - # - name: Run PHPUnit - # working-directory: ./main - # run: | - # DEN=/home/runner/work/magento2/magento2/den/bin/den - # ${DEN} env exec -T php-fpm ./vendor/bin/phpunit --help - # ${DEN} env exec -T php-fpm whoami - # ${DEN} env exec -T php-fpm ls -lath +# - name: Init / Configure Den +# working-directory: ./main +# run: | +# DEN=/home/runner/work/magento2/magento2/den/bin/den +# ${DEN} env-init magento2 magento2 +# sed -i 's/WARDEN_DB=.*/WARDEN_DB=0/g' .env +# sed -i 's/WARDEN_TEST_DB=.*/WARDEN_TEST_DB=0/g' .env +# sed -i 's/WARDEN_ELASTICSEARCH=.*/WARDEN_ELASTICSEARCH=0/g' .env +# sed -i 's/WARDEN_OPENSEARCH=.*/WARDEN_OPENSEARCH=0/g' .env +# sed -i 's/WARDEN_ELASTICHQ=.*/WARDEN_ELASTICHQ=0/g' .env +# sed -i 's/WARDEN_VARNISH=.*/WARDEN_VARNISH=0/g' .env +# sed -i 's/WARDEN_RABBITMQ=.*/WARDEN_RABBITMQ=0/g' .env +# sed -i 's/WARDEN_REDIS=.*/WARDEN_REDIS=0/g' .env +# sed -i 's/PHP_VERSION=.*/PHP_VERSION=${{ matrix.php_version }}/g' .env +# ${DEN} env up +# echo ${{secrets.DEPLOY_PASSWORD}} | sudo -S chmod -R a+rw . +# # # Unit test command test +# # - name: Run PHPUnit +# # working-directory: ./main +# # run: | +# # DEN=/home/runner/work/magento2/magento2/den/bin/den +# # ${DEN} env exec -T php-fpm ./vendor/bin/phpunit --help +# # ${DEN} env exec -T php-fpm whoami +# # ${DEN} env exec -T php-fpm ls -lath - - name: Configure PHPUnit - working-directory: ./main - run: | - cp dev/tests/unit/phpunit.xml.dist dev/tests/unit/phpunit.xml - sed -i '//,/<\/extensions>/d' dev/tests/unit/phpunit.xml +# - name: Configure PHPUnit +# working-directory: ./main +# run: | +# cp dev/tests/unit/phpunit.xml.dist dev/tests/unit/phpunit.xml +# sed -i '//,/<\/extensions>/d' dev/tests/unit/phpunit.xml - - name: Run PHPUnit Nx - working-directory: ./main - run: | - export DEN=/home/runner/work/magento2/magento2/den/bin/den - nx affected --target=test:unit --head=HEAD --base=remotes/origin/${{ github.event.pull_request.base.ref }} \ No newline at end of file +# - name: Run PHPUnit Nx +# working-directory: ./main +# run: | +# export DEN=/home/runner/work/magento2/magento2/den/bin/den +# nx affected --target=test:unit --head=HEAD --base=remotes/origin/${{ github.event.pull_request.base.ref }} \ No newline at end of file diff --git a/supported-services.json b/supported-services.json new file mode 100644 index 0000000000000..db11fc5c68800 --- /dev/null +++ b/supported-services.json @@ -0,0 +1,8 @@ +{ + "services": { + "php": [ + 8.1, + 8.2 + ] + } +} \ No newline at end of file From eb015ae2d215a4571daa0bf3e354f461c47b8397 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 24 Apr 2023 16:50:36 +0100 Subject: [PATCH 13/14] aaaa --- .github/workflows/unit-tests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 26865a33ca718..030ee518e8415 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -13,7 +13,6 @@ jobs: run-unit-tests: uses: adamzero1/mage-os-infrastructure/.github/workflows/unit-tests.yml@nx-unit-testing - # name: Unit Tests # run-name: ${{ github.actor }} is running Unit Tests # on: From 2b7b972f321148f42e8d3e1cdfefe89fb9890db7 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 8 May 2023 16:06:39 +0100 Subject: [PATCH 14/14] debug: testing workflow --- .github/workflows/unit-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 030ee518e8415..3fa7fc00eaf83 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -13,7 +13,7 @@ jobs: run-unit-tests: uses: adamzero1/mage-os-infrastructure/.github/workflows/unit-tests.yml@nx-unit-testing -# name: Unit Tests +# name: Unit Tests # run-name: ${{ github.actor }} is running Unit Tests # on: # pull_request: