Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nx work new #11

Open
wants to merge 14 commits into
base: nx-work
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 116 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
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:
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: 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 [email protected]
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 }}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class CanViewNotification implements VisibilityConditionInterface
private static $cachePrefix = 'admin-usage-notification-popup';

/**
* aaaaaa
* @var Logger
*/
private $viewerLogger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
8 changes: 4 additions & 4 deletions app/code/Magento/Directory/Test/Unit/Model/CurrencyTest.php
Copy link
Owner Author

@adamzero1 adamzero1 Apr 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding right to left mark's, which PHPs \NumberFormatter is automatically adding in response.
([U+200F])

Given the involved files haven't been modified in a long time:

  • app/code/Magento/Directory/Model/Currency.php 9 months
  • app/code/Magento/Directory/Test/Unit/Model/CurrencyTest.php 6 Months
  • lib/internal/Magento/Framework/NumberFormatter.php 2 years

I can only guess this is PHP version thing or, has always been here?
magento@91816f7
Even though the comment is incorrect, this commit must of been the start. (n.b reverting this doesn't fix the issue)

Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand All @@ -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'],
Expand Down
55 changes: 55 additions & 0 deletions dev/tests/unit/phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
colors="true"
columns="max"
beStrictAboutTestsThatDoNotTestAnything="false"
bootstrap="./framework/bootstrap.php">
<coverage>
<include>
<directory suffix=".php">../../../app/code/*</directory>
<directory suffix=".php">../../../lib/internal/Magento</directory>
<directory suffix=".php">../../../setup/src/*</directory>
</include>
<exclude>
<directory>../../../app/code/*/*/Test</directory>
<directory>../../../lib/internal/*/*/Test</directory>
<directory>../../../lib/internal/*/*/*/Test</directory>
<directory>../../../setup/src/*/*/Test</directory>
</exclude>
</coverage>
<testsuites>
<testsuite name="Magento_Unit_Tests_App_Code">
<directory>../../../app/code/*/*/Test/Unit</directory>
<directory>../../../vendor/magento/module-*/Test/Unit</directory>
<exclude>../../../app/code/Magento/Indexer/Test/Unit</exclude>
</testsuite>
<testsuite name="Magento_Unit_Tests_App_Code_Indexer">
<directory>../../../app/code/*/Indexer/Test/Unit</directory>
</testsuite>
<testsuite name="Magento_Unit_Tests_Other">
<directory>../../../lib/internal/*/*/Test/Unit</directory>
<directory>../../../lib/internal/*/*/*/Test/Unit</directory>
<directory>../../../setup/src/*/*/Test/Unit</directory>
<directory>../../../vendor/*/module-*/Test/Unit</directory>
<directory>../../../vendor/*/framework/Test/Unit</directory>
<directory>../../../vendor/*/framework/*/Test/Unit</directory>
<directory>../../tests/unit/*/Test/Unit</directory>
</testsuite>
</testsuites>
<php>
<includePath>.</includePath>
<ini name="memory_limit" value="-1"/>
<ini name="date.timezone" value="America/Los_Angeles"/>
<ini name="xdebug.max_nesting_level" value="200"/>
</php>
<listeners>
<listener class="Magento\Framework\TestFramework\Unit\Listener\ReplaceObjectManager"/>
</listeners>
</phpunit>