Skip to content

Commit

Permalink
OXDEV-7728 Split codeception tests to groups in GHA
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolaIvanovski committed Mar 15, 2024
1 parent 4737525 commit 44fe9ee
Show file tree
Hide file tree
Showing 12 changed files with 212 additions and 80 deletions.
7 changes: 7 additions & 0 deletions .github/oxid-esales/graphql-storefront-address.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# {{ $order := "01" }}order: {{ print $order }}
# {{ $org := "oxid-esales" }}organisation: {{ print $org }}
# {{ $name := "graphql-storefront" }}name: {{ print $name }}
codeception:
title: '{{ print $order }}-{{ print $name }}'
configuration: '/var/www/vendor/{{ print $org }}/{{ print $name }}/tests/codeception.yml'
additional_options: '--bootstrap=/var/www/source/bootstrap.php -g address'
7 changes: 7 additions & 0 deletions .github/oxid-esales/graphql-storefront-basket.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# {{ $order := "02" }}order: {{ print $order }}
# {{ $org := "oxid-esales" }}organisation: {{ print $org }}
# {{ $name := "graphql-storefront" }}name: {{ print $name }}
codeception:
title: '{{ print $order }}-{{ print $name }}'
configuration: '/var/www/vendor/oxid-esales/graphql-storefront/tests/codeception.yml'
additional_options: '--bootstrap=/var/www/source/bootstrap.php -g basket'
7 changes: 7 additions & 0 deletions .github/oxid-esales/graphql-storefront-customer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# {{ $order := "03" }}order: {{ print $order }}
# {{ $org := "oxid-esales" }}organisation: {{ print $org }}
# {{ $name := "graphql-storefront" }}name: {{ print $name }}
codeception:
title: '{{ print $order }}-{{ print $name }}'
configuration: '/var/www/vendor/oxid-esales/graphql-storefront/tests/codeception.yml'
additional_options: '--bootstrap=/var/www/source/bootstrap.php -g customer'
7 changes: 7 additions & 0 deletions .github/oxid-esales/graphql-storefront-order.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# {{ $order := "04" }}order: {{ print $order }}
# {{ $org := "oxid-esales" }}organisation: {{ print $org }}
# {{ $name := "graphql-storefront" }}name: {{ print $name }}
codeception:
title: '{{ print $order }}-{{ print $name }}'
configuration: '/var/www/vendor/oxid-esales/graphql-storefront/tests/codeception.yml'
additional_options: '--bootstrap=/var/www/source/bootstrap.php -g order'
7 changes: 7 additions & 0 deletions .github/oxid-esales/graphql-storefront-other.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# {{ $order := "05" }}order: {{ print $order }}
# {{ $org := "oxid-esales" }}organisation: {{ print $org }}
# {{ $name := "graphql-storefront" }}name: {{ print $name }}
codeception:
title: '{{ print $order }}-{{ print $name }}'
configuration: '/var/www/vendor/oxid-esales/graphql-storefront/tests/codeception.yml'
additional_options: '--bootstrap=/var/www/source/bootstrap.php -g other'
7 changes: 7 additions & 0 deletions .github/oxid-esales/graphql-storefront-pricing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# {{ $order := "06" }}order: {{ print $order }}
# {{ $org := "oxid-esales" }}organisation: {{ print $org }}
# {{ $name := "graphql-storefront" }}name: {{ print $name }}
codeception:
title: '{{ print $order }}-{{ print $name }}'
configuration: '/var/www/vendor/oxid-esales/graphql-storefront/tests/codeception.yml'
additional_options: '--bootstrap=/var/www/source/bootstrap.php -g pricing'
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# {{ $ids := "oe_graphql_storefront" }}ids: {{ print $ids }}
prepare_shop:
matrix: &matrix
php: &matrix_php '["8.1", "8.2"]'
mysql: &matrix_mysql '["8.0"]'
specific: &specific_matrix
php: '["8.2"]'
mysql: '["8.0"]'
Expand All @@ -23,78 +21,71 @@ prepare_shop:
}
}
install_shop:
matrix: *matrix

# {{ $ids := "oe_graphql_storefront" }}ids: {{ print $ids }}
install_module:
matrix:
<<: *matrix
testplan: '["-"]'
testplan: &module_testplan
max_parallel: 1
cache:
prefix: &install_module_prefix 'moduleInstallation-ce-{{ .Github.SHA }}-{{ .Github.RunNumber }}-{{ .Github.RunAttempt }}'
prefix: &install_module_prefix 'moduleInstallation-ce-{{ .Github.SHA }}-{{ .Github.RunID }}'
ids: &ids '{{ print $ids }}'
composer:
update: false
activate: |
oe_graphql_base
oe_graphql_storefront
git:
module:
url: &git_module_url '{{ .Github.Repository }}'
ref: '{{ .Github.RefName }}'
package_name: &package_name 'oxid-esales/graphql-storefront'
path: *ids
custom_script_container: |
cd /var/www
./bin/oe-console oe:setup:demodata
phpunit:
matrix:
<<: *matrix
testplan: '["tests/github_actions/defaults/module_phpunit_unit.yml","tests/github_actions/defaults/module_phpunit_integration.yml"]'
testplan: '["~/defaults/module_phpunit_unit.yml","~/defaults/module_phpunit_integration.yml"]'
load_shop: *install_module_prefix

runtest:
matrix:
testplan: 'skip'
load_shop: *install_module_prefix

codeception:
matrix:
<<: *matrix
testplan: '["-"]'
testplan: *module_testplan '
[
"~/graphql-storefront-address.yml",
"~/graphql-storefront-basket.yml",
"~/graphql-storefront-customer.yml",
"~/graphql-storefront-order.yml",
"~/graphql-storefront-pricing.yml",
"~/graphql-storefront-other.yml"
]'
load_shop: *install_module_prefix
title: codeception
container:
options: '-e SELENIUM_SERVER_HOST=selenium -e BROWSER_NAME=chrome -e -e THEME_ID=apex'
configuration: '/var/www/vendor/oxid-esales/graphql-storefront/tests/codeception.yml'
options: '-e SELENIUM_SERVER_HOST=selenium -e BROWSER_NAME=chrome -e ACTIVE_THEME=apex -e XDEBUG_MODE=coverage -e THEME_ID=apex'
suite: 'Acceptance'
custom_script: |
perl -pi -e 'print "SetEnvIf Authorization \"(.*)\" HTTP_AUTHORIZATION=\$1\n\n" if $. == 1' source/source/.htaccess
sed -i 's/<?php/<?php\n\nrequire(__DIR__ . "\/..\/c3.php");/' source/source/bootstrap.php
runtest:
phpcs_tests:
skip: true

styles:
matrix:
testplan: 'skip'
<<: *specific_matrix
testplan: '["-"]'
load_shop: *install_module_prefix
path: *ids
module_ids: *ids

sonarcloud:
matrix:
<<: *specific_matrix
testplan: '["-"]'
strip_path: '/var/www/dev-packages/{{ print $ids }}/'
project_key: 'OXID-eSales_graphql-storefront-module'
project_name: *package_name
project_name: 'oxid-esales/graphql-storefront'
parameters: |
-Dsonar.language=php
-Dsonar.scm.provider=git
-Dsonar.sources=src
-Dsonar.tests=tests
phpcs_tests:
skip: true

styles:
matrix:
<<: *specific_matrix
testplan: '["-"]'
load_shop: *install_module_prefix
path: *ids
module_ids: *ids

finish:
slack_title: 'Module graphql-storefront-module on {{ .Github.Repository }} by {{ .Github.Actor }}'
32 changes: 0 additions & 32 deletions .github/workflows/dispatch_dev_module.yml

This file was deleted.

122 changes: 122 additions & 0 deletions .github/workflows/dispatch_module.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
name: Manual trigger
# Matrix workflow using re-usable github actions

on:
workflow_dispatch:
inputs:
scenario:
type: choice
options:
- 7.1.x
- 8.0.x
- use custom testplan
default: '7.1.x'
description: 'Choose test scenario'
limit:
type: choice
options:
- 'no'
- 'PHP8.1/MySQL5.7'
- 'PHP8.1/MySQL8.0'
- 'PHP8.2/MySQL5.7'
- 'PHP8.2/MySQL8.0'
- 'PHP8.3/MySQL5.7'
- 'PHP8.3/MySQL8.0'
default: 'PHP8.1/MySQL5.7'
description: 'Limit to one PHP/MySQL combination'
custom_testplan:
type: string
required: true
description: 'URL/PATH of the testplan to run'
default: '~/defaults/7.1.x.yml,~/graphql-storefront.yml'
runs_on:
type: string
description: 'JSON string/array describing the runner'
required: true
default: '"ubuntu-latest"'
use_dev_version:
type: choice
options: ['no', 'v0']
description: 'Use the dev version of github actions'
default: 'no'

jobs:
build_testplan:
runs-on: ${{ fromJson(inputs.runs_on) }}
outputs:
testplan: '${{ steps.build.outputs.testplan }}'
steps:
- name: 'Build testplan'
id: build
run: |
# Build testplan
# shellcheck disable=SC2088 # Tilde expansion happens in the workflow and not by bash
case '${{inputs.limit}}' in
"no") LIMIT='';;
"PHP8.1/MySQL5.7") LIMIT='~/defaults/php8.1_mysql5.7_only.yml,' ;;
"PHP8.1/MySQL8.0") LIMIT='~/defaults/php8.1_mysql8.0_only.yml,' ;;
"PHP8.2/MySQL5.7") LIMIT='~/defaults/php8.2_mysql5.7_only.yml,' ;;
"PHP8.2/MySQL8.0") LIMIT='~/defaults/php8.2_mysql8.0_only.yml,' ;;
"PHP8.3/MySQL5.7") LIMIT='~/defaults/php8.3_mysql5.7_only.yml,' ;;
"PHP8.3/MySQL8.0") LIMIT='~/defaults/php8.3_mysql8.0_only.yml,' ;;
*) echo "Illegal choice, fix the workflow"
exit 1
;;
esac
case '${{ inputs.scenario}}' in
"7.1.x")
# shellcheck disable=SC2088 # Tilde expansion happens in the workflow and not by bash
TESTPLAN="~/defaults/7.1.x.yml,${LIMIT}~/graphql-storefront.yml"
;;
"8.0.x")
# shellcheck disable=SC2088 # Tilde expansion happens in the workflow and not by bash
TESTPLAN="${LIMIT}~/graphql-storefront.yml"
;;
"use custom testplan")
# shellcheck disable=SC2088 # Tilde expansion happens in the workflow and not by bash
TESTPLAN="${{ inputs.custom_testplan }}"
;;
*)
echo "Illegal choice, fix the workflow"
exit 1
;;
esac
echo "testplan=${TESTPLAN}" | tee -a "${GITHUB_OUTPUT}"
dispatch_stable:
if: ${{ inputs.use_dev_version == 'no' }}
needs: build_testplan
uses: oxid-eSales/github-actions/.github/workflows/call-universal_test_workflow.yml@v4
with:
testplan: ${{ needs.build_testplan.outputs.testplan }}
runs_on: ${{ inputs.runs_on }}
defaults: 'v4'
plan_folder: '.github/oxid-esales'
secrets:
DOCKER_HUB_USER: ${{ secrets.DOCKER_HUB_USER }}
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }}
CACHE_ENDPOINT: ${{ secrets.CACHE_ENDPOINT }}
CACHE_ACCESS_KEY: ${{ secrets.CACHE_ACCESS_KEY }}
CACHE_SECRET_KEY: ${{ secrets.CACHE_SECRET_KEY }}
enterprise_github_token: ${{ secrets.enterprise_github_token }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

dispatch_v0:
if: ${{ inputs.use_dev_version == 'v0' }}
needs: build_testplan
uses: oxid-eSales/github-actions/.github/workflows/call-universal_test_workflow.yml@v0
with:
testplan: ${{ needs.build_testplan.outputs.testplan }}
runs_on: ${{ inputs.runs_on }}
defaults: 'v0'
plan_folder: '.github/oxid-esales'
secrets:
DOCKER_HUB_USER: ${{ secrets.DOCKER_HUB_USER }}
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }}
CACHE_ENDPOINT: ${{ secrets.CACHE_ENDPOINT }}
CACHE_ACCESS_KEY: ${{ secrets.CACHE_ACCESS_KEY }}
CACHE_SECRET_KEY: ${{ secrets.CACHE_SECRET_KEY }}
enterprise_github_token: ${{ secrets.enterprise_github_token }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
name: Automatically triggered on push
name: Auto trigger on Push to 7.1.x*

on:
push:
branches:
- 'b-7.1.x*'
- 'b-7.1.x**'

jobs:
call_matrix:
uses: OXID-eSales/github-actions/.github/workflows/call-universal_test_workflow.yml@v3
push_module:
uses: oxid-eSales/github-actions/.github/workflows/call-universal_test_workflow.yml@v4
with:
testplan: 'tests/github_actions/defaults/7.1.x.yml,tests/github_actions/graphql-storefront.yml'
testplan: '~/defaults/7.1.x.yml,~/graphql-storefront.yml'
runs_on: '"ubuntu-latest"'
defaults: 'v3'
defaults: 'v4'
plan_folder: '.github/oxid-esales'
secrets:
DOCKER_HUB_USER: ${{ secrets.DOCKER_HUB_USER }}
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }}
Expand Down
8 changes: 8 additions & 0 deletions tests/Codeception/Acceptance/Customer/CustomerCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,14 @@ public function testCustomerBirthdateUpdate(AcceptanceTester $I): void
*/
public function testBaskets(AcceptanceTester $I): void
{
//Remove leftover basket from previous tests
$I->deleteFromDatabase(
'oxuserbaskets',
[
'OXTITLE' => 'savedbasket',
]
);

$I->login(self::USERNAME, self::PASSWORD);

$I->sendGQLQuery(
Expand Down
4 changes: 2 additions & 2 deletions tests/Codeception/Acceptance/Order/CustomerOrderFilesCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ public function testCustomerOrderFiles(AcceptanceTester $I): void
];

$I->assertMatchesRegularExpression(
'/https?:\/\/.*\..*sorderfileid=' . $expectedFiles[0]['id'] . '/',
'/https?:\/.*\/?.*sorderfileid=' . $expectedFiles[0]['id'] . '/',
$customerFiles[0]['url']
);
$I->assertMatchesRegularExpression(
'/https?:\/\/.*\..*sorderfileid=' . $expectedFiles[0]['id'] . '/',
'/https?:\/.*\/?.*sorderfileid=' . $expectedFiles[0]['id'] . '/',
$orderFiles[0]['url']
);
unset($customerFiles[0]['url'], $orderFiles[0]['url']);
Expand Down

0 comments on commit 44fe9ee

Please sign in to comment.