From db0dd259a51b2d5d615e12443bf6ed21bffdcb8e Mon Sep 17 00:00:00 2001 From: Dominik Krebs Date: Thu, 4 May 2023 14:27:05 +0200 Subject: [PATCH] add ci test action --- .github/workflows/release.yml | 4 +- .github/workflows/test.yml | 63 +++++++++++++++++++ bin/init-mysql | 23 +++++++ bin/{release.sh => release} | 0 bin/setup-plugin | 11 ++++ bin/setup-shopware | 24 +++++++ .../{phpstan.neon => phpstan.neon.dist} | 6 +- 7 files changed, 126 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/test.yml create mode 100644 bin/init-mysql rename bin/{release.sh => release} (100%) create mode 100644 bin/setup-plugin create mode 100644 bin/setup-shopware rename src/Frontend/NetzkollektivEasyCredit/{phpstan.neon => phpstan.neon.dist} (84%) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 35193b6..68d9983 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,8 +14,8 @@ jobs: id: build-release run: | curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer - chmod +x ./bin/release.sh - ./bin/release.sh + chmod +x ./bin/release + ./bin/release echo "build $(ls dist/* | head -1)" echo "::set-output name=filepath::$(ls dist/* | head -1)" echo "::set-output name=filename::$(basename `ls dist/* | head -1`)" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..0c50d9a --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,63 @@ +name: Test + +on: + push: + branches: + - 'main' + - 'automate' + +jobs: + ci-current: + runs-on: ubuntu-latest + strategy: + max-parallel: 15 + fail-fast: false + matrix: + include: + - shopware-version: 'v5.7.17' + php-version: 8.2 + + name: Shopware ${{ matrix.shopware-version }} @ ${{ matrix.php-version }} + + container: + image: netzkollektivgmbh/docker-shopware:php-${{ matrix.php-version }} + env: + PLUGIN_DIR: /opt/shopware/engine/Shopware/Plugins/Local/Frontend/NetzkollektivEasyCredit + SW_DIR: /opt/shopware + + steps: + - name: Checkout + uses: actions/checkout@master + - name: Debug + run: | + php -v + php -m + composer -V + env + - name: Initialize + run: | + ls -lia $GITHUB_WORKSPACE/bin + chmod +x $GITHUB_WORKSPACE/bin/* + $GITHUB_WORKSPACE/bin/init-mysql + $GITHUB_WORKSPACE/bin/setup-shopware + + cd $SW_DIR + - name: Link plugin with shopware installation and install composer deps + run: | + composer config --working-dir=$GITHUB_WORKSPACE --no-plugins allow-plugins.phpstan/extension-installer true + composer update --working-dir=$GITHUB_WORKSPACE -n + + cp -r $GITHUB_WORKSPACE/src/Frontend/NetzkollektivEasyCredit $PLUGIN_DIR + - name: Install & activate Plugin + run: | + cd $SW_DIR + $GITHUB_WORKSPACE/bin/setup-plugin + + php bin/console sw:generate:attributes + php bin/console orm:generate:proxies + - name: Deactivate & uninstall Plugin + run: | + cd $SW_DIR + php bin/console sw:plugin:deactivate NetzkollektivEasyCredit + php bin/console sw:plugin:uninstall NetzkollektivEasyCredit + php bin/console sw:cache:clear diff --git a/bin/init-mysql b/bin/init-mysql new file mode 100644 index 0000000..9d6002d --- /dev/null +++ b/bin/init-mysql @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +set -eu + +apt-get -y update && apt-get -y install mariadb-server + +echo "Starting mysql server" +/usr/bin/mysqld_safe --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql >> /dev/null 2>&1 & + +while true; do + sleep 1 + + exit_code=0 + mysql -e ";" 2> /dev/null || exit_code=$? + if [ "${exit_code}" -eq "0" ]; then + echo "Started mysql server" + + echo "creating mysql user & database" + mysql -e "CREATE DATABASE shopware" + mysqladmin --user=root password 'root' + exit + fi +done diff --git a/bin/release.sh b/bin/release similarity index 100% rename from bin/release.sh rename to bin/release diff --git a/bin/setup-plugin b/bin/setup-plugin new file mode 100644 index 0000000..361d63b --- /dev/null +++ b/bin/setup-plugin @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +set -eu + +ln -s $GITHUB_WORKSPACE $PLUGIN_DIR +ls -lia $PLUGIN_DIR + +php bin/console sw:plugin:refresh +php bin/console sw:plugin:list +php bin/console sw:plugin:install NetzkollektivEasyCredit +php bin/console sw:plugin:activate NetzkollektivEasyCredit diff --git a/bin/setup-shopware b/bin/setup-shopware new file mode 100644 index 0000000..d2b223d --- /dev/null +++ b/bin/setup-shopware @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +set -eu + +git clone --depth=1 -b v5.7.17 https://github.com/shopware/shopware.git /opt/shopware +cd /opt/shopware + +echo " +DB_USER=root +DB_PASSWORD=root +DB_HOST=127.0.0.1 +DB_NAME=shopware +DB_PORT=3306 +SW_HOST=localhost +SW_BASE_PATH= +SELENIUM_HOST=selenium +ELASTICSEARCH_HOST=elasticsearch +" > .env +make init + +echo 'donwloading demo-data ...' +php bin/console sw:store:download SwagDemoDataDE +echo 'installing demo data ...' +php bin/console sw:plugin:install --activate SwagDemoDataDE diff --git a/src/Frontend/NetzkollektivEasyCredit/phpstan.neon b/src/Frontend/NetzkollektivEasyCredit/phpstan.neon.dist similarity index 84% rename from src/Frontend/NetzkollektivEasyCredit/phpstan.neon rename to src/Frontend/NetzkollektivEasyCredit/phpstan.neon.dist index 8299f8a..fc69aef 100644 --- a/src/Frontend/NetzkollektivEasyCredit/phpstan.neon +++ b/src/Frontend/NetzkollektivEasyCredit/phpstan.neon.dist @@ -5,11 +5,11 @@ parameters: - vendor - ../../../../../../vendor - ../../../../../../engine - - ../../../../../../var/cache/production_202211020949/doctrine - - ../../../../../../var/cache/production_202211020949/proxies + - ../../../../../../var/cache/production___REVISION__/doctrine + - ../../../../../../var/cache/production___REVISION__/proxies symfony: constant_hassers: false - container_xml_path: ../../../../../../var/cache/production_202211020949/container.xml + container_xml_path: ../../../../../../var/cache/production___REVISION__/container.xml doctrine: queryBuilderClass: Shopware\Components\Model\QueryBuilder repositoryClass: Shopware\Components\Model\ModelRepository