Skip to content

Sonarcloud

Sonarcloud #263

Workflow file for this run

name: Sonarcloud
env:
PHP: '7.4'
on:
schedule:
- cron: '15 0 * * 6'
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-6.5.x --single-branch source
- name: Cache current installation
uses: actions/cache@v2
with:
path: |
./*
key: shopInstallation-${{ env.PHP }}-${{ github.sha }}
- name: Prepare container configuration
run: |
make setup
make addbasicservices
perl -pi\
-e "s#PHP_VERSION=.*#PHP_VERSION='${{ env.PHP }}'#g;"\
.env
perl -pi\
-e 's#display_errors =.*#display_errors = false#g;'\
-e 'print "xdebug.max_nesting_level=1000\nxdebug.mode=coverage\n\n";'\
-e 'print "error_reporting = E_ALL & ~E_DEPRECATED & ~E_NOTICE & ~E_WARNING\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 'print "SetEnvIf Authorization \"(.*)\" HTTP_AUTHORIZATION=\$1\n\n" if $. == 1'\
source/source/.htaccess
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;'\
source/source/config.inc.php
- name: Start containers
run: |
make up
sleep 2
- name: Checkout current module
uses: actions/checkout@v2
with:
path: source/test-module
- name: Install dependencies for module
run: docker-compose exec -T --workdir='/var/www/test-module' php composer update --no-interaction
- name: Require the module
run: |
docker-compose exec -T \
php composer config repositories.oxid-esales/grapqhl-storefront \
--json '{"type":"path", "url":"./test-module", "options": {"symlink": true}}'
docker-compose exec -T \
php composer require oxid-esales/graphql-storefront:* --no-update
- name: Install all dependencies and reset the 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
- name: Stop containers
run: |
docker-compose down
sleep 2
unit_tests:
needs: [ install_shop_with_module ]
runs-on: ubuntu-latest
steps:
- name: Load current installation from cache
uses: actions/cache@v2
with:
path: |
./*
key: shopInstallation-${{ env.PHP }}-${{ github.sha }}
restore-keys: |
shopInstallation-${{ env.PHP }}-${{ github.sha }}
- name: Start containers
run: |
make up
sleep 2
- name: Run tests
continue-on-error: true
run: |
docker-compose exec -T \
-e PARTIAL_MODULE_PATHS=oe/graphql-base,oe/graphql-storefront \
-e ACTIVATE_ALL_MODULES=1 \
-e RUN_TESTS_FOR_SHOP=0 \
-e RUN_TESTS_FOR_MODULES=0 \
-e XDEBUG_MODE=coverage \
-e STOREFRONT_COVERAGE=1 \
-e ADDITIONAL_TEST_PATHS='/var/www/vendor/oxid-esales/graphql-storefront/tests' \
php php vendor/bin/runtests --coverage-php=/var/www/unit.cov AllTestsUnit
- name: Upload log artifact
uses: actions/upload-artifact@v2
with:
name: TestsLog
path: source/unit.cov
codeception_tests:
strategy:
matrix:
group:
- 'address'
- 'basket'
- 'customer'
- 'order'
- 'other'
needs: [ install_shop_with_module ]
runs-on: ubuntu-latest
steps:
- name: Load current installation from cache
uses: actions/cache@v2
with:
path: |
./*
key: shopInstallation-${{ env.PHP }}-${{ github.sha }}
restore-keys: |
shopInstallation-${{ env.PHP }}-${{ github.sha }}
- name: Start containers
run: |
make up
sleep 2
- name: Install twig components
run: |
docker-compose exec -T \
php composer require oxid-esales/flow-theme:dev-master --no-interaction --no-update
docker-compose exec -T \
php composer require oxid-esales/twig-component:dev-b-7.0.x --no-interaction --no-update
docker-compose exec -T \
php composer require oxid-esales/twig-theme:dev-b-7.0.x --no-interaction --no-update
docker-compose exec -T \
php composer require oxid-esales/twig-admin-theme:dev-b-7.0.x --no-interaction --no-update
- name: Install codeception dependencies
run: |
docker-compose exec -T \
php composer config repositories.oxid-esales/oxideshop-demodata-ce \
--json '{"type":"git", "url":"https://github.com/OXID-eSales/oxideshop_demodata_ce"}'
docker-compose exec -T php composer require oxid-esales/oxideshop-demodata-ce:dev-master --no-update
docker-compose exec -T php composer require codeception/c3 --dev --no-update
docker-compose exec -T php composer require codeception/module-rest:* --dev --no-update
docker-compose exec -T php composer require codeception/module-phpbrowser:* --dev --no-update
docker-compose exec -T php composer config --no-plugins allow-plugins.codeception/c3 true
docker-compose exec -T php composer update
sed -i 's/<?php/<?php\n\nrequire(__DIR__ . "\/..\/c3.php");/' source/source/bootstrap.php
- name: Activate module
run: |
docker-compose exec -T php bin/oe-console oe:setup:demodata
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_storefront
- name: Run tests
continue-on-error: true
run: |
docker-compose exec -T \
-e SELENIUM_SERVER_HOST=selenium \
-e MODULE_IDS=oe_graphql_storefront \
-e XDEBUG_MODE=coverage \
php php vendor/bin/codecept run acceptance \
-c /var/www/vendor/oxid-esales/graphql-storefront/tests/codeception.yml -g ${{ matrix.group }} --coverage-phpunit
- name: Extract and prepare the coverage artifact
run: |
cp source/test-module/tests/Codeception/_output/coverage.serialized codeception.${{ matrix.group }}.cov
- name: Upload log artifact
uses: actions/upload-artifact@v2
with:
name: TestsLog
path: codeception.${{ matrix.group }}.cov
prepare_coverage_results:
needs: [ unit_tests, codeception_tests ]
runs-on: ubuntu-latest
steps:
- name: Load current installation from cache
uses: actions/cache@v2
with:
path: |
./*
key: shopInstallation-${{ env.PHP }}-${{ github.sha }}
restore-keys: |
shopInstallation-${{ env.PHP }}-${{ github.sha }}
- name: Download unit artifacts
uses: actions/download-artifact@v2
with:
name: TestsLog
path: ./source/covs/
- name: Collect and merge coverage reports
continue-on-error: true
run: |
ls -alh source/covs/
wget https://phar.phpunit.de/phpcov-7.0.2.phar
mv phpcov-7.0.2.phar source/phpcov.phar
docker-compose run -T php php phpcov.phar merge --clover covs/coverage.xml covs
sed -i 's+/var/www/test-module/+./+' source/covs/coverage.xml
- name: Upload log artifact
uses: actions/upload-artifact@v2
with:
name: TestsLogFixed
path: source/covs/coverage.xml
sonarcloud:
needs: [ prepare_coverage_results ]
runs-on: ubuntu-latest
steps:
- name: Checkout current module
uses: actions/checkout@v2
- name: Download fixed artifacts
uses: actions/download-artifact@v2
with:
name: TestsLogFixed
path: ./
- name: SonarCloud Scan
uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
args: >
-Dsonar.organization=oxid-esales
-Dsonar.projectKey=OXID-eSales_graphql-storefront-module
-Dsonar.sources=src
-Dsonar.tests=tests
-Dsonar.sourceEncoding=UTF-8
-Dsonar.php.coverage.reportPaths=coverage.xml
-Dsonar.cpd.php.minimumTokens=25
-Dsonar.cpd.php.minimumLines=5