Skip to content

Commit

Permalink
EMA-150 (#65)
Browse files Browse the repository at this point in the history
Co-authored-by: Tamás Perencz <[email protected]>
Co-authored-by: szsanyi <[email protected]>
Co-authored-by: Sanyi <[email protected]>
Co-authored-by: bognar.tamas <[email protected]>
Co-authored-by: itegration-it <[email protected]>
  • Loading branch information
6 people authored Aug 5, 2024
1 parent fa05570 commit 1f73508
Show file tree
Hide file tree
Showing 12 changed files with 9,091 additions and 28 deletions.
76 changes: 68 additions & 8 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,21 @@ jobs:
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch

- name: Checkout code
shell: bash
run: |
sudo apt-get update
sudo apt-get install git -y
git clone --branch ${{ steps.extract_branch.outputs.branch }} https://github.com/emartech/magento2-extension.git
- name: Login to GitLab
uses: docker/login-action@v3
with:
registry: ${{ vars.REGISTRY_URL }}
username: ${{ secrets.GITLAB_USER }}
password: ${{ secrets.GITLAB_TOKEN }}

- name: Install system tools
shell: bash
run: |
Expand All @@ -47,24 +50,52 @@ jobs:
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-compose-plugin -y
sudo apt-get install docker-compose-plugin docker-buildx-plugin -y
- name: Build mage_node image
shell: bash
run: |
cd magento2-extension/dev
docker build -f testv2/tools/docker/Dockerfile-mage-node --build-arg NPM_TOKEN=$NPM_TOKEN -t "mage_node" .
retries=3
count=0
until [ $count -ge $retries ]
do
DOCKER_BUILDKIT=1 docker build -f testv2/tools/docker/Dockerfile-mage-node --build-arg NPM_TOKEN=$NPM_TOKEN -t "mage_node" . && break
count=$((count+1))
echo "Retrying build mage_node image ($count/$retries)..."
sleep 30
done
if [ $count -ge $retries ]; then
echo "mage_node image building failed after $retries attempts."
exit 1
fi
env:
NPM_TOKEN: ${{ secrets.GITLAB_TOKEN }}
- name: Run unittest

- name: Run unit test
shell: bash
run: |
cd magento2-extension
bash dev/testv2/tools/scripts/run-unit.sh
retries=3
count=0
until [ $count -ge $retries ]
do
bash dev/testv2/tools/scripts/run-unit.sh && break
count=$((count+1))
echo "Retrying unit tests ($count/$retries)..."
sleep 30
done
if [ $count -ge $retries ]; then
echo "unit tests failed after $retries attempts."
exit 1
fi
env:
VERSION: ${{ matrix.magento-versions }}
NPM_TOKEN: ${{ secrets.GITLAB_TOKEN }}

e2e-tests:
runs-on: github-actions-runner-emarsys
# needs: unit-tests
permissions:
contents: "read"
strategy:
Expand All @@ -78,18 +109,21 @@ jobs:
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch

- name: Checkout code
shell: bash
run: |
sudo apt-get update
sudo apt-get install git -y
git clone --branch ${{ steps.extract_branch.outputs.branch }} https://github.com/emartech/magento2-extension.git
- name: Login to GitLab
uses: docker/login-action@v3
with:
registry: ${{ vars.REGISTRY_URL }}
username: ${{ secrets.GITLAB_USER }}
password: ${{ secrets.GITLAB_TOKEN }}

- name: Install system tools
shell: bash
run: |
Expand All @@ -103,19 +137,45 @@ jobs:
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-compose-plugin -y
sudo apt-get install docker-compose-plugin docker-buildx-plugin -y
- name: Build mage_node image
shell: bash
run: |
cd magento2-extension/dev
docker build -f testv2/tools/docker/Dockerfile-mage-node --build-arg NPM_TOKEN=$NPM_TOKEN -t "mage_node" .
retries=3
count=0
until [ $count -ge $retries ]
do
DOCKER_BUILDKIT=1 docker build -f testv2/tools/docker/Dockerfile-mage-node --build-arg NPM_TOKEN=$NPM_TOKEN -t "mage_node" . && break
count=$((count+1))
echo "Retrying build mage_node image ($count/$retries)..."
sleep 30
done
if [ $count -ge $retries ]; then
echo "mage_node image building failed after $retries attempts."
exit 1
fi
env:
NPM_TOKEN: ${{ secrets.GITLAB_TOKEN }}
- name: Run e2stest

- name: Run e2e test
shell: bash
run: |
cd magento2-extension
bash dev/testv2/tools/scripts/run-e2e.sh
retries=3
count=0
until [ $count -ge $retries ]
do
bash dev/testv2/tools/scripts/run-e2e.sh && break
count=$((count+1))
echo "Retrying e2e tests ($count/$retries)..."
sleep 30
done
if [ $count -ge $retries ]; then
echo "e2e tests failed after $retries attempts."
exit 1
fi
env:
VERSION: ${{ matrix.magento-versions }}
NPM_TOKEN: ${{ secrets.GITLAB_TOKEN }}
3 changes: 3 additions & 0 deletions Model/Api/OrdersApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Emartech\Emarsys\Api\Data\OrdersApiResponseInterfaceFactory;
use Emartech\Emarsys\Api\OrdersApiInterface;
use Magento\Framework\Webapi\Exception as WebApiException;
use Magento\Sales\Model\Order;
use Magento\Sales\Model\ResourceModel\Order\Collection as OrderCollection;
use Magento\Sales\Model\ResourceModel\Order\CollectionFactory as OrderCollectionFactory;

Expand Down Expand Up @@ -144,7 +145,9 @@ private function handleItems(): array
{
$returnArray = [];

/** @var Order $order */
foreach ($this->orderCollection as $order) {
$order->setStoreName(str_replace(PHP_EOL, ' ', $order->getStoreName()));
$returnArray[] = $order;
}

Expand Down
3 changes: 2 additions & 1 deletion dev/.dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
test/node_modules
test/node_modules
testv2/tools
3 changes: 3 additions & 0 deletions dev/testv2/cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ module.exports = defineConfig({
requestTimeout: 120000,
defaultCommandTimeout: 120000,
pageLoadTimeout: 120000,
experimentalMemoryManagement: true,
experimentalModifyObstructiveThirdPartyCode: true,
modifyObstructiveCode: true,
blockHosts: ['*snippet.url.com', '*scarabresearch.com'],
env: {
snippetUrl: 'http://snippet.url.com/main.js'
Expand Down
Loading

0 comments on commit 1f73508

Please sign in to comment.