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 19, 2024
1 parent 4737525 commit fd4c8cd
Show file tree
Hide file tree
Showing 13 changed files with 259 additions and 82 deletions.
12 changes: 12 additions & 0 deletions .github/oxid-esales/graphql-storefront-address.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# {{ $order := "01" }}order: {{ print $order }}
# {{ $org := "oxid-esales" }}organisation: {{ print $org }}
# {{ $name := "graphql-storefront" }}name: {{ print $name }}
# {{ $group := "address" }}group: {{ print $group }}
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 {{ print $group }}'
output:
prefix: 'codeception_artifacts_{{ print $group }}'
logfile:
prefix: 'codeception-{{ print $group }}'
12 changes: 12 additions & 0 deletions .github/oxid-esales/graphql-storefront-basket.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# {{ $order := "02" }}order: {{ print $order }}
# {{ $org := "oxid-esales" }}organisation: {{ print $org }}
# {{ $name := "graphql-storefront" }}name: {{ print $name }}
# {{ $group := "basket" }}group: {{ print $group }}
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 {{ print $group }}'
output:
prefix: 'codeception_artifacts_{{ print $group }}'
logfile:
prefix: 'codeception-{{ print $group }}'
12 changes: 12 additions & 0 deletions .github/oxid-esales/graphql-storefront-customer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# {{ $order := "03" }}order: {{ print $order }}
# {{ $org := "oxid-esales" }}organisation: {{ print $org }}
# {{ $name := "graphql-storefront" }}name: {{ print $name }}
# {{ $group := "customer" }}group: {{ print $group }}
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 {{ print $group }}'
output:
prefix: 'codeception_artifacts_{{ print $group }}'
logfile:
prefix: 'codeception-{{ print $group }}'
12 changes: 12 additions & 0 deletions .github/oxid-esales/graphql-storefront-order.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# {{ $order := "04" }}order: {{ print $order }}
# {{ $org := "oxid-esales" }}organisation: {{ print $org }}
# {{ $name := "graphql-storefront" }}name: {{ print $name }}
# {{ $group := "order" }}group: {{ print $group }}
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 {{ print $group }}'
output:
prefix: 'codeception_artifacts_{{ print $group }}'
logfile:
prefix: 'codeception-{{ print $group }}'
12 changes: 12 additions & 0 deletions .github/oxid-esales/graphql-storefront-other.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# {{ $order := "05" }}order: {{ print $order }}
# {{ $org := "oxid-esales" }}organisation: {{ print $org }}
# {{ $name := "graphql-storefront" }}name: {{ print $name }}
# {{ $group := "other" }}group: {{ print $group }}
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 {{ print $group }}'
output:
prefix: 'codeception_artifacts_{{ print $group }}'
logfile:
prefix: 'codeception-{{ print $group }}'
12 changes: 12 additions & 0 deletions .github/oxid-esales/graphql-storefront-pricing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# {{ $order := "06" }}order: {{ print $order }}
# {{ $org := "oxid-esales" }}organisation: {{ print $org }}
# {{ $name := "graphql-storefront" }}name: {{ print $name }}
# {{ $group := "pricing" }}group: {{ print $group }}
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 {{ print $group }}'
output:
prefix: 'codeception_artifacts_{{ print $group }}'
logfile:
prefix: 'codeception-{{ print $group }}'
Original file line number Diff line number Diff line change
@@ -1,82 +1,98 @@
# {{ $ids := "oe_graphql_storefront" }}ids: {{ print $ids }}
# {{ $org := "oxid-esales" }}organisation: {{ print $org }}
# {{ $name := "graphql-storefront" }}name: {{ print $name }}
prepare_shop:
matrix: &matrix
php: &matrix_php '["8.1", "8.2"]'
mysql: &matrix_mysql '["8.0"]'
specific: &specific_matrix
php: '["8.2"]'
php: '["8.1"]'
mysql: '["8.0"]'
git:
shop_ref: '{{ .Data.global.git.default_ref }}'
composer_require_install: 'codeception/module-rest:^3.3 codeception/module-phpbrowser:^3.0 codeception/c3'
composer_require_options: '--dev'
composer_allow_plugins_repositories: 'codeception/c3:true'
custom_ini:
xdebug: 'xdebug.mode=debug,profile,coverage'
composer:
transform: |
{
"require-dev": {
"codeception/module-rest": "^3.3",
"codeception/module-phpbrowser": "^3.0",
"codeception/c3": "^2.9",
"oxid-esales/twig-component": "{{ .Data.global.composer.dev_ref }}",
"oxid-esales/twig-admin-theme": "{{ .Data.global.composer.dev_ref }}",
"oxid-esales/apex-theme": "{{ .Data.global.composer.dev_ref }}",
"oxid-esales/oxideshop-demodata-ce": "dev-master"
},
"config":{
"allow-plugins":{
"oxid-esales/oxideshop-composer-plugin": true,
"oxid-esales/oxideshop-unified-namespace-generator": true,
"codeception/c3": true
}
}
}
install_shop:
matrix: *matrix

# {{ $ids := "oe_graphql_storefront" }}ids: {{ print $ids }}
install_module:
matrix:
<<: *matrix
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 }}'
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'
package_name: &package_name '{{ print $org }}/{{ print $name }}'
path: *ids
custom_script_container: |
cd /var/www
./bin/oe-console oe:setup:demodata
activate: |
oe_graphql_base
{{ print $ids }}
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
custom_script_container:
bin/oe-console oe:setup:demodata

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: "{{ print $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
parameters: |
Expand All @@ -85,16 +101,5 @@ sonarcloud:
-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 }}
Loading

0 comments on commit fd4c8cd

Please sign in to comment.