diff --git a/common/sourceop-auto-update/.github/workflows/testprenvironment.yaml b/common/sourceop-auto-update/.github/workflows/testprenvironment.yaml index 06bf0f5a7..d4f8fec6a 100644 --- a/common/sourceop-auto-update/.github/workflows/testprenvironment.yaml +++ b/common/sourceop-auto-update/.github/workflows/testprenvironment.yaml @@ -7,7 +7,9 @@ on: pull_request: branches: - master + - main env: + # @todo I dont think this is needed anymore GITHUB_TOKEN: ${{ secrets.TEMPLATES_GITHUB_TOKEN }} jobs: test-pr-env: @@ -15,24 +17,22 @@ jobs: runs-on: ubuntu-latest if: ${{ github.repository_owner == 'platformsh-templates' }} steps: - - name: 'Wait for psh and get target url' + - name: 'Get Project ID' + id: 'get-proj-id' + uses: platformsh/gha-retrieve-projectid@main + with: + github_token: ${{ secrets.TEMPLATES_GITHUB_TOKEN }} + + - name: 'Get Production URL' + id: 'get-prod-url' + uses: platformsh/gha-retrieve-production-url@main + with: + platformsh_token: ${{ secrets.TEMPLATES_CLI_TOKEN }} + project_id: ${{ steps.get-proj-id.outputs.project_id }} + + - name: 'Run Pull Request Tests' id: get-target-url - uses: platformsh/gha-retrieve-psh-prenv-url@main + uses: platformsh/gha-template-pr-tests@main with: github-token: ${{ secrets.GITHUB_TOKEN }} - - name: 'Does Our App Work?' - id: test-environment - run: | - target_url=${{ steps.get-target-url.outputs.target_url }} - echo "::notice::The target url returned from our github action: ${target_url}" - #ok, so for whatever strange reason, our integration returns the http version of the PR environment, not https - #hence to parameter expansion replacement. - #we dont need the whole response (yet), just see if we get a 200 - response=$(curl -s -o /dev/null -I -w "%{http_code}" "${target_url//http:/https:}"); - if [[ "200" == "${response}" ]]; then - echo "::notice::Environment responded with http header 200" - else - echo "::error::Response from environment was something other than 200. Response returned was ${response}" - exit 1; - fi - + baseline-url: ${{ steps.get-prod-url.outputs.production_url }} diff --git a/project/magento.py b/project/magento.py index 89b2ad0da..2b2eacc76 100644 --- a/project/magento.py +++ b/project/magento.py @@ -1,121 +1,120 @@ import os from . import BaseProject -# from .remote import RemoteProject - # "repositories": { - # "Magento Repo Auth Required": { - # "type": "composer", - # "url": "https://repo.magento.com" - # }, - # "ECE-Tools": { - # "type": "git", - # "url": "https://github.com/magento/ece-tools.git" - # }, - # "Magento Cloud Components": { - # "type": "git", - # "url": "https://github.com/magento/magento-cloud-components.git" - # }, - # "Magento Cloud Patches": { - # "type": "git", - # "url": "https://github.com/magento/magento-cloud-patches.git" - # }, - # "Magento Quality Patches": { - # "type": "git", - # "url": "https://github.com/magento/quality-patches.git" - # } - # }, - # "extra": { - # "magento-force": "override" - # } +# from .remote import RemoteProject - # "config": { - # "preferred-install": "dist", - # "sort-packages": true, - # "allow-plugins": { - # "composer/installers": true, - # "laminas/laminas-dependency-plugin": true, - # "magento/composer-dependency-version-audit-plugin": true, - # "magento/inventory-composer-installer": true, - # "magento/magento-composer-installer": true - # } - # }, - # "require": { - # "magento/ece-tools": "^2002.1.6", - # "magento/magento-cloud-components": "^1.0.7", - # "magento/magento-cloud-patches": "^1.0.10", - # "magento/product-community-edition": "^2.4", - # "magento/quality-patches": "^1.0.22", - # "wolfsellers/module-enabledisabletfa": "^1.0" - # }, +# "repositories": { +# "Magento Repo Auth Required": { +# "type": "composer", +# "url": "https://repo.magento.com" +# }, +# "ECE-Tools": { +# "type": "git", +# "url": "https://github.com/magento/ece-tools.git" +# }, +# "Magento Cloud Components": { +# "type": "git", +# "url": "https://github.com/magento/magento-cloud-components.git" +# }, +# "Magento Cloud Patches": { +# "type": "git", +# "url": "https://github.com/magento/magento-cloud-patches.git" +# }, +# "Magento Quality Patches": { +# "type": "git", +# "url": "https://github.com/magento/quality-patches.git" +# } +# }, +# "extra": { +# "magento-force": "override" +# } + +# "config": { +# "preferred-install": "dist", +# "sort-packages": true, +# "allow-plugins": { +# "composer/installers": true, +# "laminas/laminas-dependency-plugin": true, +# "magento/composer-dependency-version-audit-plugin": true, +# "magento/inventory-composer-installer": true, +# "magento/magento-composer-installer": true +# } +# }, +# "require": { +# "magento/ece-tools": "^2002.1.6", +# "magento/magento-cloud-components": "^1.0.7", +# "magento/magento-cloud-patches": "^1.0.10", +# "magento/product-community-edition": "^2.4", +# "magento/quality-patches": "^1.0.22", +# "wolfsellers/module-enabledisabletfa": "^1.0" +# }, class Magento2ce(BaseProject): # updateCommands = { # 'composer.json': 'composer update -W --ignore-platform-req=ext-apcu --ignore-platform-req=ext-imagick', # } - def package_update_actions(self): - actions = super(Magento2ce, self).package_update_actions() - return [ - 'cd {0} && composer config -g allow-plugins.composer/installers true --no-plugins'.format( - self.builddir), - 'cd {0} && composer config allow-plugins.composer/installers true --no-plugins'.format( - self.builddir), - ] + actions + # def package_update_actions(self): + # actions = super(Magento2ce, self).package_update_actions() + # return [ + # 'cd {0} && composer config -g allow-plugins.composer/installers true --no-plugins'.format( + # self.builddir), + # 'cd {0} && composer config allow-plugins.composer/installers true --no-plugins'.format( + # self.builddir), + # ] + actions @property def update(self): - def magento_modify_composer(composer): """ This change makes the template loadable via Composer. """ - composer['name']= "platformsh/{0}".format(projectName) - composer['description']= "Magento 2 CE(Community Edition) for Platform.sh" - - composer['repositories'] = { - "Magento Repo Auth Required": { - "type": "composer", - "url": "https://repo.magento.com" - }, - "ECE-Tools": { - "type": "git", - "url": "https://github.com/magento/ece-tools.git" - }, - "Magento Cloud Components": { - "type": "git", - "url": "https://github.com/magento/magento-cloud-components.git" - }, - "Magento Cloud Patches": { - "type": "git", - "url": "https://github.com/magento/magento-cloud-patches.git" - }, - "Magento Quality Patches": { - "type": "git", - "url": "https://github.com/magento/quality-patches.git" - } - } + composer['name'] = "platformsh/{0}".format(projectName) + composer['description'] = "Magento 2 CE(Community Edition) for Platform.sh" + + # composer['repositories'] = { + # "Magento Repo Auth Required": { + # "type": "composer", + # "url": "https://repo.magento.com" + # }, + # "ECE-Tools": { + # "type": "git", + # "url": "https://github.com/magento/ece-tools.git" + # }, + # "Magento Cloud Components": { + # "type": "git", + # "url": "https://github.com/magento/magento-cloud-components.git" + # }, + # "Magento Cloud Patches": { + # "type": "git", + # "url": "https://github.com/magento/magento-cloud-patches.git" + # }, + # "Magento Quality Patches": { + # "type": "git", + # "url": "https://github.com/magento/quality-patches.git" + # } + # } return composer - - ROOTDIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) - TEMPLATEDIR = os.path.join(ROOTDIR, 'templates/magento2ce') - - # Quickstart project package name, used in the block below. + # ROOTDIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + # TEMPLATEDIR = os.path.join(ROOTDIR, 'templates/magento2ce') + # + # # Quickstart project package name, used in the block below. projectName = "magento2ce" return super(Magento2ce, self).update + [ - 'cd {0} && composer create-project --repository-url=https://repo.magento.com/ ' - 'magento/project-community-edition {1} --ignore-platform-req=ext-iconv --ignore-platform-req=ext-soap ' - '--ignore-platform-req=ext-pdo_mysql {2}'.format(TEMPLATEDIR, projectName, self.composer_defaults()), - - 'rm -rf {0}/*'.format(self.builddir), - 'cd {0} && git add . && git commit -m "Clear previous template."'.format(self.builddir), - - 'cd {0} && cp -r {1}/{2}/* .'.format(self.builddir, TEMPLATEDIR, projectName), - 'rm -rf {0}/{1}'.format(TEMPLATEDIR, projectName), + # 'cd {0} && composer create-project --repository-url=https://repo.magento.com/ ' + # 'magento/project-community-edition {1} --ignore-platform-req=ext-iconv --ignore-platform-req=ext-soap ' + # '--ignore-platform-req=ext-pdo_mysql {2}'.format(TEMPLATEDIR, projectName, self.composer_defaults()), + # + # 'rm -rf {0}/*'.format(self.builddir), + # 'cd {0} && git add . && git commit -m "Clear previous template."'.format(self.builddir), + # + # 'cd {0} && cp -r {1}/{2}/* .'.format(self.builddir, TEMPLATEDIR, projectName), + # 'rm -rf {0}/{1}'.format(TEMPLATEDIR, projectName), (self.modify_composer, [magento_modify_composer]) ] @@ -125,7 +124,7 @@ def platformify(self): '--ignore-platform-req=ext-pdo_mysql ' return super(Magento2ce, self).platformify + [ - 'cd {0} && composer require magento/ece-tools magento/magento-cloud-components ' - 'magento/quality-patches -W '.format(self.builddir) + self.composer_defaults() + extraIgnores, - 'cd {0} && composer update -W {1}'.format(self.builddir, self.composer_defaults() + extraIgnores), - ] + # 'cd {0} && composer require magento/ece-tools magento/magento-cloud-components ' + # 'magento/quality-patches -W '.format(self.builddir) + self.composer_defaults() + extraIgnores, + 'cd {0} && composer update -W {1}'.format(self.builddir, self.composer_defaults() + extraIgnores), + ] diff --git a/templates/magento2ce/files/.gitignore b/templates/magento2ce/files/.gitignore index 8b8e99c59..8ec1104f2 100644 --- a/templates/magento2ce/files/.gitignore +++ b/templates/magento2ce/files/.gitignore @@ -32,8 +32,6 @@ atlassian* /package.json /.php_cs /.php_cs.cache -/.php-cs-fixer.php -/.php-cs-fixer.cache /grunt-config.json /pub/media/*.* !/pub/media/.htaccess @@ -60,8 +58,6 @@ atlassian* /pub/media/tmp/* !/pub/media/tmp/.htaccess /pub/media/captcha/* -/pub/media/sitemap/* -!/pub/media/sitemap/.htaccess /pub/static/* !/pub/static/.htaccess @@ -72,47 +68,3 @@ atlassian* /generated/* !/generated/.htaccess .DS_Store - -# Platform.sh -app/* -!app/.htaccess -!app/etc/vendor_path.php -bin/* -!bin/.htaccess -dev -!dev/.htaccess -generated/* -!generated/.htaccess -lib/* -!lib/.htaccess -phpserver/* -!phpserver/.htaccess -!phpserver/README.md - -pub/* -!pub/.htaccess -!pub/errors/.htaccess -!pub/static/.htaccess -setup/* -!setup/.htaccess -!setup/config/.htaccess -!setup/performance-toolkit/.htaccess -!setup/pub/.htaccess -!setup/src/.htaccess -!setup/view/.htaccess - -.php-cs-fixer.dist.php -.user.ini -Gruntfile.js.sample -auth.json.sample -grunt-config.json.sample -nginx.conf.sample -package.json.sample -.htaccess.sample - -docker-sync.yml -mutagen.sh -php.dev.ini -.php_cs.dist -.travic.yml.simple -.user.ini \ No newline at end of file diff --git a/templates/magento2ce/files/.platform.app.yaml b/templates/magento2ce/files/.platform.app.yaml index a9dbbb5ce..11f33a0e3 100644 --- a/templates/magento2ce/files/.platform.app.yaml +++ b/templates/magento2ce/files/.platform.app.yaml @@ -4,110 +4,119 @@ # See https://docs.platform.sh/user_guide/reference/platform-app-yaml.html # The name of this app. Must be unique within a project. -name: app +name: magento # The runtime the application uses. -type: php:8.1 +type: php:7.4 +dependencies: + php: + composer/composer: "^1" + +### # Specify additional PHP extensions that should be loaded. +# To determine what you need to enable +# 1. run locally: composer check-platform-reqs | grep "ext-\|php" +# 2. Compare to https://docs.platform.sh/languages/php/extensions.html +# - "Def" = Already Enabled +# - "Avail" = Available, but you need to enable below. runtime: extensions: - - xsl - - sodium - - redis - - blackfire + - xsl + - sodium + +# Customize your PHP.ini. +# See: https://docs.platform.sh/languages/php/ini.html +variables: + php: + # Include Magento's out-of-the-box settings + include: /app/.user.ini # Configuration of the build of this application. build: flavor: composer -dependencies: - php: - composer/composer: '^2' - # The relationships of the application with services or other applications. # # The left-hand side is the name of the relationship as it will be exposed # to the application in the PLATFORM_RELATIONSHIPS variable. The right-hand # side is in the form `:`. relationships: - database: db:mysql - redis: cache:redis - elasticsearch: indexer:elasticsearch - rabbitmq: queue:rabbitmq + database: magento_database:mysql + redis: magento_redis:redis + search: magento_search:opensearch # The size of the persistent disk of the application (in MB). disk: 2048 # The 'mounts' describe writable, persistent filesystem mounts in the application. mounts: - "/var": - source: local - source_path: "var" - "/app/etc": - source: local - source_path: "etc" - "/pub/media": - source: local - source_path: "media" - "/pub/static": - source: local - source_path: "static" + "var": "shared:files/var" + "generated": "shared:files/generated" + "app/etc": "shared:files/etc" + "pub/media": "shared:files/media" + "pub/static": "shared:files/static" # The hooks executed at various points in the lifecycle of the application. hooks: - build: | - set -e - php ./vendor/bin/ece-tools build:generate - php ./vendor/bin/ece-tools build:transfer - deploy: | - set -e - php ./vendor/bin/ece-tools deploy -vvv - post_deploy: | - set -e - php ./vendor/bin/ece-tools post-deploy -vvv - php bin/magento admin:user:create --admin-user=admin --admin-password=admin --admin-email=admin@example.com --admin-firstname=Admin --admin-lastname=Istrator - -# The configuration of scheduled execution. -crons: - magento: - spec: "*/5 * * * *" - commands: bash -c 'for group in $(grep -shoP "(?<=)" {app,vendor}/*/*/etc/cron_groups.xml); do echo -n Running cron group ${group} --- && php -d memory_limit=-1 bin/magento cron:run --group=${group}; done' - logrotate: - spec: "45 1 * * *" - commands: shtool rotate -n10 $PLATFORM_APP_DIR/var/log/*.log - reportcleanup: - spec: "0 2 * * *" - commands: find $PLATFORM_APP_DIR/var/report/* -mtime +10 -delete + # The build hook runs on your code to prepare it for an active environment. + build: | + set -e + mkdir -p .versioned_backup/etc && cp app/etc/* .versioned_backup/etc/ + # The deploy hook runs after your application has been deployed and started. + deploy: | + set -e + cp .versioned_backup/etc/* app/etc/ + php deploy.php # The configuration of app when it is exposed to the web. web: locations: - "/": - # The public directory of the app, relative to its root. + '/': root: "pub" - # The front-controller script to send non-static requests to. passthru: "/index.php" index: - index.php - expires: -1 scripts: true allow: false rules: \.(css|js|map|hbs|gif|jpe?g|png|tiff|wbmp|ico|jng|bmp|svgz|midi?|mp?ga|mp2|mp3|m4a|ra|weba|3gpp?|mp4|mpe?g|mpe|ogv|mov|webm|flv|mng|asx|asf|wmv|avi|ogx|swf|jar|ttf|eot|woff|otf|html?)$: allow: true - "/media": + ^/sitemap(.*)\.xml$: + passthru: "/media/sitemap$1.xml" + '/media': root: "pub/media" allow: true scripts: false - expires: 1y passthru: "/get.php" - "/static": + expires: 1y + '/static': root: "pub/static" allow: true scripts: false + passthru: "/static.php" expires: 1y - passthru: "/front-static.php" rules: ^/static/version\d+/(?.*)$: passthru: "/static/$resource" + +# The configuration of scheduled execution. +crons: + magento: + spec: "*/5 * * * *" + commands: + start: "php bin/magento cron:run" + +workers: + queue: + size: S + disk: 128 + commands: + start: | + bin/magento queue:consumers:start async.operations.all --single-thread --max-messages=10000 + +source: + operations: + auto-update: + command: | + curl -fsS https://raw.githubusercontent.com/platformsh/source-operations/main/setup.sh | { bash /dev/fd/3 sop-autoupdate; } 3<&0 diff --git a/templates/magento2ce/files/.platform/routes.yaml b/templates/magento2ce/files/.platform/routes.yaml index 09f9d202f..3d83f69f0 100644 --- a/templates/magento2ce/files/.platform/routes.yaml +++ b/templates/magento2ce/files/.platform/routes.yaml @@ -1,3 +1,4 @@ https://{default}/: + id: magento_route type: upstream - upstream: app:http + upstream: magento:http diff --git a/templates/magento2ce/files/.platform/services.yaml b/templates/magento2ce/files/.platform/services.yaml index 7cab9755b..fce05cc59 100644 --- a/templates/magento2ce/files/.platform/services.yaml +++ b/templates/magento2ce/files/.platform/services.yaml @@ -1,14 +1,20 @@ -db: - type: mysql:10.4 - disk: 1500 +# Magento's Database +magento_database: + type: mariadb:10.3 + disk: 2048 -cache: - type: redis:6.0 +# Magento's cache & session redis instance +# Since our sessions will be sent here, we want to enable persistence so customers are not logged out when we deploy +magento_redis: + type: redis-persistent:6.0 + disk: 256 -indexer: - type: elasticsearch:7.9 - disk: 512 - -queue: - type: rabbitmq:3.8 - disk: 1024 +# Magento's Elasticsearch-compatible OpenSearch instance. +magento_search: + # Magento 2.3.7 is also compatible with elasticsearch:7.9 + type: opensearch:1.2 + disk: 256 + configuration: + plugins: + - analysis-icu + - analysis-phonetic