Skip to content

Commit

Permalink
Add development workflow
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Fedurtsya <[email protected]>
  • Loading branch information
Sieg committed Nov 10, 2023
1 parent b452826 commit 86c49c5
Show file tree
Hide file tree
Showing 2 changed files with 374 additions and 0 deletions.
359 changes: 359 additions & 0 deletions workflows/development.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,359 @@
name: Development

on:
workflow_call:
inputs:
php:
required: true
type: string
mysql:
required: true
type: string
module_codecept_test_group:
type: string
default: 'oe_graphql_configuration_access'
report_sonarcloud:
type: boolean
default: false

workflow_dispatch:
inputs:
php:
description: 'PHP version'
required: true
default: '8.0'
type: choice
options:
- '8.0'
- '8.1'
mysql:
description: 'MySQL version'
required: true
default: '5.7.37'
type: choice
options:
- '5.7.37'
- '8.0'
module_codecept_test_group:
description: 'Module codeception test group'
required: true
default: 'oe_graphql_configuration_access'
type: string
report_sonarcloud:
description: 'Trigger sonarcloud analize?'
required: true
default: true
type: boolean

env:
PACKAGE_NAME: 'oxid-esales/graphql-configuration-access'
SONARCLOUD_ORGANIZATION: 'oxid-esales'
SONARCLOUD_PROJECT_KEY: 'OXID-eSales_graphql-configuration-access'

jobs:
install_shop_with_module:
runs-on: ubuntu-latest
steps:
- name: Clone testing environment
run: git clone https://github.com/OXID-eSales/docker-eshop-sdk.git .

- name: Clone the shop
run: git clone --depth 1 https://github.com/OXID-eSales/oxideshop_ce.git --branch b-7.0.x --single-branch source

- name: Cache current installation
uses: actions/cache@v3
with:
path: |
./*
key: installation-${{ github.sha }}-${{ join(inputs.*, '-') }}-${{ github.run_number }}-${{ github.run_attempt }}

- name: Prepare container configuration
run: |
make setup
make addbasicservices
perl -pi\
-e 's#PHP_VERSION=.*#PHP_VERSION=${{ inputs.php }}#g;'\
-e "s#MYSQL_VERSION=.*#MYSQL_VERSION=${{ inputs.mysql }}#g;"\
.env
perl -pi\
-e 's#display_errors =.*#display_errors = false#g;'\
-e 's#error_reporting = .*#error_reporting = E_ALL ^ E_WARNING ^ E_DEPRECATED#g;'\
-e 'print "xdebug.max_nesting_level=1000\nxdebug.mode=coverage\n\n"'\
containers/php/custom.ini
perl -pi\
-e 's#/var/www/#/var/www/source/#g;'\
containers/httpd/project.conf
- name: Prepare shop configuration
run: |
cp source/source/config.inc.php.dist source/source/config.inc.php
perl -pi\
-e 's#<dbHost>#mysql#g;'\
-e 's#<dbUser>#root#g;'\
-e 's#<dbName>#example#g;'\
-e 's#<dbPwd>#root#g;'\
-e 's#<dbPort>#3306#g;'\
-e 's#<sShopURL>#http://localhost.local/#g;'\
-e 's#<sShopDir>#/var/www/source/#g;'\
-e 's#<sCompileDir>#/var/www/source/tmp/#g;'\
-e 's#iDebug = 0;#iDebug = -1;#g;'\
source/source/config.inc.php
- name: Checkout current module
uses: actions/checkout@v4
with:
path: source/test-module

- name: Start containers
run: |
make up
sleep 2
- name: Install module
run: |
docker-compose exec -T \
php composer config repositories.${{ env.PACKAGE_NAME }} \
--json '{"type":"path", "url":"./test-module", "options": {"symlink": true}}'
docker-compose exec -T \
php composer require ${{ env.PACKAGE_NAME }}:* --no-interaction --no-update
- name: Install dependencies and reset shop
run: |
docker-compose exec -T php composer update --no-interaction
docker-compose exec -T php bin/oe-console oe:database:reset \
--db-host=mysql --db-port=3306 --db-name=example --db-user=root --db-password=root --force
docker-compose exec -T php bin/oe-console oe:module:activate oe_graphql_base
docker-compose exec -T php bin/oe-console oe:module:activate oe_graphql_configuration_access
- name: Stop containers
run: |
make down
sleep 2
- name: Show docker log
if: always()
run: |
docker-compose logs
- name: Upload configuration artifacts
if: always()
uses: actions/upload-artifact@v3
with:
name: Configs-${{ inputs.php }}-${{ inputs.mysql }}-${{ inputs.template_engine }}
path: |
docker-compose.yml
source/composer.json
source/composer.lock
source/source/config.inc.php
styles:
needs: [ install_shop_with_module ]
runs-on: ubuntu-latest
steps:
- name: Load current installation from cache
uses: actions/cache@v3
with:
fail-on-cache-miss: true
path: |
./*
key: installation-${{ github.sha }}-${{ join(inputs.*, '-') }}-${{ github.run_number }}-${{ github.run_attempt }}
restore-keys: |
installation-${{ github.sha }}-${{ join(inputs.*, '-') }}-${{ github.run_number }}-${{ github.run_attempt }}
installation-${{ github.sha }}-${{ join(inputs.*, '-') }}-${{ github.run_number }}
- name: Start containers
run: |
make up
sleep 2
- name: Install module dependencies
run: |
docker-compose exec -T \
--workdir=/var/www/test-module \
php composer install
- name: Run phpstan
id: phpstan
if: always()
run: |
docker-compose exec -Tw /var/www/test-module \
php bash -c "composer phpstan-report; composer phpstan"
- name: Run phpmd
id: phpmd
if: always()
continue-on-error: true
run: |
docker-compose exec -Tw /var/www/test-module \
php bash -c "composer phpmd-report; composer phpmd"
- name: Run phpcs
if: always()
run: |
docker-compose exec -T \
--workdir=/var/www/test-module \
php composer phpcs
- name: Stop containers
if: always()
run: |
make down
sleep 2
- name: Upload log artifact
if: always()
uses: actions/upload-artifact@v3
with:
name: StylesLog-${{ inputs.php }}
path: |
source/test-module/tests/reports/phpstan.report.json
source/test-module/tests/reports/phpmd.report.json
unit_integration_tests:
needs: [ install_shop_with_module ]
runs-on: ubuntu-latest
steps:
- name: Load current installation from cache
uses: actions/cache@v3
with:
fail-on-cache-miss: true
path: |
./*
key: installation-${{ github.sha }}-${{ join(inputs.*, '-') }}-${{ github.run_number }}-${{ github.run_attempt }}
restore-keys: |
installation-${{ github.sha }}-${{ join(inputs.*, '-') }}-${{ github.run_number }}-${{ github.run_attempt }}
installation-${{ github.sha }}-${{ join(inputs.*, '-') }}-${{ github.run_number }}
- name: Start containers
run: |
make up
sleep 2
- name: Run tests
run: |
docker-compose exec -T \
-e XDEBUG_MODE=coverage \
php php vendor/bin/phpunit \
-c /var/www/vendor/${{ env.PACKAGE_NAME }}/tests/phpunit.xml \
--bootstrap=/var/www/source/bootstrap.php \
--coverage-text \
--coverage-clover=/var/www/coverage.xml
- name: Cleanup coverage report
run: |
perl -pi -e 's#/var/www/test-module/#./#g;' /source/coverage.xml
- name: Upload log artifact
if: always()
uses: actions/upload-artifact@v3
with:
name: ModuleIntegrationTestsLog-${{ inputs.php }}-${{ inputs.mysql }}-${{ inputs.template_engine }}
path: |
source/coverage.xml
source/source/log/oxideshop.log
data/php/logs/error_log.txt
- name: Stop containers
if: always()
run: |
make down
sleep 2
codeception_twig:
needs: [ install_shop_with_module ]
if: ${{ inputs.template_engine == 'both' || inputs.template_engine == 'twig' }}
runs-on: ubuntu-latest
steps:
- name: Load current installation from cache
uses: actions/cache@v3
with:
fail-on-cache-miss: true
path: |
./*
key: installation-${{ github.sha }}-${{ join(inputs.*, '-') }}-${{ github.run_number }}-${{ github.run_attempt }}
restore-keys: |
installation-${{ github.sha }}-${{ join(inputs.*, '-') }}-${{ github.run_number }}-${{ github.run_attempt }}
installation-${{ github.sha }}-${{ join(inputs.*, '-') }}-${{ github.run_number }}
- name: Start containers
run: |
make file=services/selenium-chrome.yml addservice
make up
sleep 2
- name: Install twig template engine and twig theme
run: |
docker-compose exec -T php composer require oxid-esales/twig-component:dev-b-7.0.x --no-update
docker-compose exec -T php composer require oxid-esales/twig-admin-theme:dev-b-7.0.x --no-update
docker-compose exec -T php composer require oxid-esales/apex-theme:dev-b-7.0.x --no-update
docker-compose exec -T php composer update --no-interaction
- name: Run tests
run: |
docker-compose exec -T \
-e THEME_ID=apex \
-e MODULE_IDS=oe_graphql_base,oe_graphql_configuration_access \
php vendor/bin/codecept run acceptance \
-c /var/www/vendor/${{ env.PACKAGE_NAME }}/tests/codeception.yml -g ${{ inputs.module_codecept_test_group }}
- name: Upload log artifact
if: always()
uses: actions/upload-artifact@v3
with:
name: ModuleCodeceptionTestsLog-${{ inputs.php }}-${{ inputs.mysql }}-${{ inputs.template_engine }}
path: |
docker-compose.yml
source/composer.json
source/composer.lock
source/source/config.inc.php
source/source/log/oxideshop.log
data/php/logs/error_log.txt
source/tests/Codeception/_output
- name: Stop containers
if: always()
run: |
make down
sleep 2
sonarcloud:
needs: [ prepare_coverage_results ]
if: ${{ always() && inputs.report_sonarcloud }}
runs-on: ubuntu-latest
steps:
- name: Checkout current module
uses: actions/checkout@v4

- name: Download TestsLog artifacts
continue-on-error: true
uses: actions/download-artifact@v3
with:
name: ModuleIntegrationTestsLog-${{ inputs.php }}-${{ inputs.mysql }}-${{ inputs.template_engine }}
path: ./tests/

- name: Debug
run: |
ls -alh
cd tests
ls -alh
cd source
ls -alh
- name: SonarCloud Scan
uses: sonarsource/sonarcloud-github-action@master
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: >
-Dsonar.organization=${{ env.SONARCLOUD_ORGANIZATION }}
-Dsonar.projectKey=${{ env.SONARCLOUD_PROJECT_KEY }}
-Dsonar.sources=src
-Dsonar.tests=tests
-Dsonar.sourceEncoding=UTF-8
-Dsonar.php.coverage.reportPaths=tests/coverage.xml
-Dsonar.cpd.php.minimumTokens=25
-Dsonar.cpd.php.minimumLines=5
15 changes: 15 additions & 0 deletions workflows/trigger.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Trigger

on:
pull_request:
push:

jobs:
p80m57both:
name: 'Php-8.0-Mysql-5.7'
uses: ./.github/workflows/development.yml
secrets: inherit
with:
php: '8.0'
mysql: '5.7.37'
report_sonarcloud: true

0 comments on commit 86c49c5

Please sign in to comment.