diff --git a/.github/ci/files/composer.json b/.github/ci/files/composer.json deleted file mode 100644 index 94074c67..00000000 --- a/.github/ci/files/composer.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "type": "project", - "config": { - "optimize-autoloader": true, - "sort-packages": true, - "discard-changes": true, - "process-timeout": 0, - "allow-plugins": { - "php-http/discovery": false, - "symfony/runtime": true - } - }, - "prefer-stable": true, - "minimum-stability": "dev", - "require": { - "pimcore/generic-data-index-bundle": "@dev" - }, - "require-dev": { - "codeception/codeception": "^5.3.2", - "codeception/phpunit-wrapper": "^9", - "codeception/module-asserts": "^2", - "codeception/module-symfony": "^3.1.1", - "phpunit/phpunit": "10.2.7" - }, - "autoload": { - "psr-4": { - "App\\": "src/", - "Pimcore\\Model\\DataObject\\": "var/classes/DataObject" - }, - "files": [ - "kernel/Kernel.php" - ] - }, - "extra": { - "symfony-assets-install": "relative" - }, - "repositories": { - "bundles": { - "type": "path", - "url": "./bundles/*/*", - "options": { - "symlink": true - } - } - } -} diff --git a/.github/ci/scripts/setup-pimcore-environment-functional-tests.sh b/.github/ci/scripts/setup-pimcore-environment-functional-tests.sh deleted file mode 100755 index 00e1bd81..00000000 --- a/.github/ci/scripts/setup-pimcore-environment-functional-tests.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -.github/ci/scripts/setup-pimcore-environment.sh - -# Add Elasticsearch config if specified -if [ "$1" == "elasticsearch" ]; then - CONFIG_FILE_PATH="config/packages/test/config.yaml" - echo -e "\n# Added by functional test script\npimcore_generic_data_index:\n index_service:\n client_params:\n client_type: 'elasticsearch'" >> "$CONFIG_FILE_PATH" -fi - -cp .github/ci/files/composer.json . -cp bundles/pimcore/generic-data-index-bundle/codeception.dist.yml . \ No newline at end of file diff --git a/.github/ci/scripts/setup-pimcore-environment.sh b/.github/ci/scripts/setup-pimcore-environment.sh index ac32e84e..29e5a1d7 100755 --- a/.github/ci/scripts/setup-pimcore-environment.sh +++ b/.github/ci/scripts/setup-pimcore-environment.sh @@ -5,7 +5,6 @@ set -eu mkdir -p var/config mkdir -p bin -cp .github/ci/files/.env . cp -r .github/ci/files/config/. config cp -r .github/ci/files/templates/. templates cp -r .github/ci/files/bin/console bin/console diff --git a/.github/workflows/elastic-search-codeception.yaml b/.github/workflows/elastic-search-codeception.yaml index b1495507..47e713a8 100644 --- a/.github/workflows/elastic-search-codeception.yaml +++ b/.github/workflows/elastic-search-codeception.yaml @@ -1,9 +1,8 @@ name: "Codeception Tests with Elasticsearch" on: - # Enable Later. schedule: - - cron: '0 3 * * 1,3,5' + - cron: "0 3 * * 1,3,5" workflow_dispatch: pull_request: branches: @@ -14,110 +13,77 @@ on: branches: - "[0-9]+.[0-9]+" - "[0-9]+.x" - env: PIMCORE_PROJECT_ROOT: ${{ github.workspace }} - APP_ENV: test - PIMCORE_TEST: 1 - PIMCORE_TEST_DB_DSN: "mysql://root@127.0.0.1:33006/pimcore_test" - PIMCORE_ELASTIC_SEARCH_HOST: "localhost:5300" - CODECEPTION_BUNDLE_PATH: "bundles/pimcore/generic-data-index-bundle/" - PIMCORE_INSTANCE_IDENTIFIER: ${{ secrets.PIMCORE_CI_INSTANCE_IDENTIFIER }} - PIMCORE_ENCRYPTION_SECRET: ${{ secrets.PIMCORE_CI_ENCRYPTION_SECRET }} - PIMCORE_PRODUCT_KEY: ${{ secrets.PIMCORE_CI_PRODUCT_KEY }} - -jobs: - codeception-tests: - name: "Codeception tests" - runs-on: "ubuntu-latest" - continue-on-error: ${{ matrix.experimental }} - strategy: - matrix: - include: - - { php-version: "8.4", dependencies: "highest", pimcore_version: "12.x-dev as 12.99.9", experimental: true, search_engine: "elasticsearch"} - - services: - mariadb: - image: "mariadb:10.11" - ports: - - 33006:3306 - env: - MYSQL_ALLOW_EMPTY_PASSWORD: yes + PRIVATE_REPO: ${{ github.event.repository.private }} - elastic: - image: elasticsearch:8.5.3 - ports: - - 5300:9200 - env: - discovery.type: "single-node" - ES_JAVA_OPTS: "-Xms1g -Xmx1g" - xpack.security.enabled: "true" - xpack.security.authc.anonymous.roles: "superuser,kibana_admin,kibana_system,kibana_user" - ELASTIC_USERNAME: "elastic" - ELASTIC_PASSWORD: "somethingsecret" +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }} + cancel-in-progress: true +jobs: + setup-matrix: + runs-on: ubuntu-latest + outputs: + php_versions: ${{ steps.parse-php-versions.outputs.php_versions }} + matrix: ${{ steps.set-matrix.outputs.matrix }} + private_repo: ${{ env.PRIVATE_REPO }} steps: - - name: "Checkout code" - uses: "actions/checkout@v4" - with: - path: "bundles/pimcore/generic-data-index-bundle" - - - name: "Copy .github directory" - env: - REQUIRE_ADMIN_BUNDLE: "${{ matrix.require_admin_bundle }}" - run: | - cp -R bundles/pimcore/generic-data-index-bundle/.github .github - - - name: "Install PHP" - uses: "shivammathur/setup-php@v2" - with: - coverage: xdebug - ini-values: display_errors=On, display_startup_errors=On, error_reporting=32767 - php-version: "${{ matrix.php-version }}" - - - name: Verify MariaDB connection - run: | - cp .github/ci/files/.my.cnf ~/.my.cnf - while ! mysqladmin ping --silent; do - sleep 1 - done + - name: Checkout code + uses: actions/checkout@v4 - - name: "Setup Pimcore environment" - env: - REQUIRE_ADMIN_BUNDLE: "${{ matrix.require_admin_bundle }}" - run: | - mysql -e "CREATE DATABASE pimcore_test CHARSET=utf8mb4;" - cp -R bundles/pimcore/generic-data-index-bundle/tests tests - mkdir src - chmod 755 .github/ci/scripts/setup-pimcore-environment-functional-tests.sh - .github/ci/scripts/setup-pimcore-environment-functional-tests.sh "${{ matrix.search_engine }}" + - name: Checkout reusable workflow repo + uses: actions/checkout@v4 + with: + repository: pimcore/workflows-collection-public + ref: main + path: reusable-workflows - - name: "Wait for Elasticsearch to be up" + - name: Parse PHP versions from composer.json + id: parse-php-versions run: | - if [ "${{ matrix.search_engine }}" == "elasticsearch" ]; then - echo "Waiting for Elasticsearch to be ready..." - until curl -s -u elastic:somethingsecret http://localhost:5300/_cluster/health | grep -q '"status":"green"'; do - echo "Waiting... Elasticsearch is not yet available." - sleep 5 - done - echo "Elasticsearch is up and running!" + if [ -f composer.json ]; then + php_versions=$(jq -r '.require.php' composer.json | grep -oP '\d+\.\d+' | tr '\n' ',' | sed 's/,$//') + if [ -z "$php_versions" ]; then + echo "php_versions=default" >> "$GITHUB_OUTPUT" + else + echo "php_versions=$php_versions" >> "$GITHUB_OUTPUT" + fi else - echo "Using OpenSearch for testing, skipping Elasticsearch wait." - fi + exit 1 + fi - - name: "Update Pimcore version" - env: - PIMCORE_VERSION: "${{ matrix.pimcore_version }}" + - name: Set up matrix JSON + id: set-matrix run: | - if [ ! -z "$PIMCORE_VERSION" ]; then - composer require --no-update pimcore/pimcore:"${PIMCORE_VERSION}" - fi - - - name: "Install dependencies with Composer" - uses: "ramsey/composer-install@v2" - with: - dependency-versions: "${{ matrix.dependencies }}" + php_versions="${{ steps.parse-php-versions.outputs.php_versions }}" + MATRIX_JSON=$(cat reusable-workflows/codeception-tests-configuration/matrix-config.json) + FILTERED_MATRIX_JSON=$(echo "$MATRIX_JSON" | jq --arg php_versions "$php_versions" '{ matrix: [ .configs[] | select(.php_version == $php_versions) | .matrix[] ] }') + ENCODED_MATRIX_JSON=$(echo "$FILTERED_MATRIX_JSON" | jq -c .) + echo "matrix=$ENCODED_MATRIX_JSON" >> "$GITHUB_OUTPUT" - - name: "Run Codeception" - run: | - vendor/bin/codecept run -c . -vvv --xml --coverage-xml + codeception-tests: + needs: setup-matrix + strategy: + matrix: ${{ fromJson(needs.setup-matrix.outputs.matrix) }} + uses: pimcore/workflows-collection-public/.github/workflows/reusable-codeception-tests-centralized.yaml@main + with: + APP_ENV: test + PIMCORE_TEST: "1" + PRIVATE_REPO: ${{ needs.setup-matrix.outputs.private_repo }} + PHP_VERSION: ${{ matrix.matrix.php-version }} + DATABASE: "mariadb:10.11" + DEPENDENCIES: ${{ matrix.matrix.dependencies }} + EXPERIMENTAL: ${{ matrix.matrix.experimental }} + PIMCORE_VERSION: ${{ matrix.matrix.pimcore_version }} + REQUIRE_ADMIN_BUNDLE: "false" + PIMCORE_ELASTIC_SEARCH_HOST: "39201" + PIMCORE_ELASTIC_SEARCH_VERSION: "8.5.3" + ENABLE_ELASTICSEARCH: true + COVERAGE: "none" + secrets: + SSH_PRIVATE_KEY_PIMCORE_DEPLOYMENTS_USER: ${{ secrets.SSH_PRIVATE_KEY_PIMCORE_DEPLOYMENTS_USER }} + COMPOSER_PIMCORE_REPO_PACKAGIST_TOKEN: ${{ secrets.COMPOSER_PIMCORE_REPO_PACKAGIST_TOKEN }} + PIMCORE_CI_INSTANCE_IDENTIFIER: ${{ secrets.PIMCORE_CI_INSTANCE_IDENTIFIER }} + PIMCORE_CI_ENCRYPTION_SECRET: ${{ secrets.PIMCORE_CI_ENCRYPTION_SECRET }} + PIMCORE_CI_PRODUCT_KEY: ${{ secrets.PIMCORE_CI_PRODUCT_KEY }} diff --git a/.github/workflows/open-search-codeception.yaml b/.github/workflows/open-search-codeception.yaml index 05c97135..144b3a5c 100644 --- a/.github/workflows/open-search-codeception.yaml +++ b/.github/workflows/open-search-codeception.yaml @@ -1,9 +1,8 @@ name: "Codeception Tests with OpenSearch" on: - # Enable Later. schedule: - - cron: '0 3 * * 1,3,5' + - cron: "0 3 * * 1,3,5" workflow_dispatch: pull_request: branches: @@ -17,97 +16,75 @@ on: env: PIMCORE_PROJECT_ROOT: ${{ github.workspace }} - APP_ENV: test - PIMCORE_TEST: 1 - PIMCORE_TEST_DB_DSN: "mysql://root@127.0.0.1:33006/pimcore_test" - PIMCORE_OPEN_SEARCH_HOST: "localhost:39200" - CODECEPTION_BUNDLE_PATH: "bundles/pimcore/generic-data-index-bundle/" - PIMCORE_INSTANCE_IDENTIFIER: ${{ secrets.PIMCORE_CI_INSTANCE_IDENTIFIER }} - PIMCORE_ENCRYPTION_SECRET: ${{ secrets.PIMCORE_CI_ENCRYPTION_SECRET }} - PIMCORE_PRODUCT_KEY: ${{ secrets.PIMCORE_CI_PRODUCT_KEY }} + PRIVATE_REPO: ${{ github.event.repository.private }} -jobs: - codeception-tests: - name: "Codeception tests" - runs-on: "ubuntu-latest" - continue-on-error: ${{ matrix.experimental }} - strategy: - matrix: - include: - - { php-version: "8.3", dependencies: "lowest", pimcore_version: "", experimental: false, search_engine: "openSearch" } - - { php-version: "8.4", dependencies: "highest", pimcore_version: "", experimental: false, search_engine: "openSearch"} - - { php-version: "8.4", dependencies: "highest", pimcore_version: "12.x-dev as 12.99.9", experimental: true, search_engine: "openSearch"} - - services: - mariadb: - image: "mariadb:10.11" - ports: - - 33006:3306 - env: - MYSQL_ALLOW_EMPTY_PASSWORD: yes - - opensearch: - image: opensearchproject/opensearch:2 - ports: - - 39200:9200 - env: - cluster.name: "opensearch-cluster" - node.name: "opensearch-node" - discovery.seed_hosts: "opensearch-node" - bootstrap.memory_lock: true - OPENSEARCH_JAVA_OPTS: "-Xms512m -Xmx512m" - discovery.type: "single-node" - DISABLE_SECURITY_PLUGIN: true +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }} + cancel-in-progress: true +jobs: + setup-matrix: + runs-on: ubuntu-latest + outputs: + php_versions: ${{ steps.parse-php-versions.outputs.php_versions }} + matrix: ${{ steps.set-matrix.outputs.matrix }} + private_repo: ${{ env.PRIVATE_REPO }} steps: - - name: "Checkout code" - uses: "actions/checkout@v4" - with: - path: "bundles/pimcore/generic-data-index-bundle" + - name: Checkout code + uses: actions/checkout@v4 - - name: "Copy .github directory" - env: - REQUIRE_ADMIN_BUNDLE: "${{ matrix.require_admin_bundle }}" - run: | - cp -R bundles/pimcore/generic-data-index-bundle/.github .github + - name: Checkout reusable workflow repo + uses: actions/checkout@v4 + with: + repository: pimcore/workflows-collection-public + ref: main + path: reusable-workflows - - name: "Install PHP" - uses: "shivammathur/setup-php@v2" - with: - coverage: xdebug - ini-values: display_errors=On, display_startup_errors=On, error_reporting=32767 - php-version: "${{ matrix.php-version }}" - - - name: Verify MariaDB connection - run: | - cp .github/ci/files/.my.cnf ~/.my.cnf - while ! mysqladmin ping --silent; do - sleep 1 - done - - - name: "Setup Pimcore environment" - env: - REQUIRE_ADMIN_BUNDLE: "${{ matrix.require_admin_bundle }}" + - name: Parse PHP versions from composer.json + id: parse-php-versions run: | - mysql -e "CREATE DATABASE pimcore_test CHARSET=utf8mb4;" - cp -R bundles/pimcore/generic-data-index-bundle/tests tests - mkdir src - chmod 755 .github/ci/scripts/setup-pimcore-environment-functional-tests.sh - .github/ci/scripts/setup-pimcore-environment-functional-tests.sh "${{ matrix.search_engine }}" + if [ -f composer.json ]; then + php_versions=$(jq -r '.require.php' composer.json | grep -oP '\d+\.\d+' | tr '\n' ',' | sed 's/,$//') + if [ -z "$php_versions" ]; then + echo "php_versions=default" >> "$GITHUB_OUTPUT" + else + echo "php_versions=$php_versions" >> "$GITHUB_OUTPUT" + fi + else + exit 1 + fi - - name: "Update Pimcore version" - env: - PIMCORE_VERSION: "${{ matrix.pimcore_version }}" + - name: Set up matrix JSON + id: set-matrix run: | - if [ ! -z "$PIMCORE_VERSION" ]; then - composer require --no-update pimcore/pimcore:"${PIMCORE_VERSION}" - fi + php_versions="${{ steps.parse-php-versions.outputs.php_versions }}" + MATRIX_JSON=$(cat reusable-workflows/codeception-tests-configuration/matrix-config.json) + FILTERED_MATRIX_JSON=$(echo "$MATRIX_JSON" | jq --arg php_versions "$php_versions" '{ matrix: [ .configs[] | select(.php_version == $php_versions) | .matrix[] ] }') + ENCODED_MATRIX_JSON=$(echo "$FILTERED_MATRIX_JSON" | jq -c .) + echo "matrix=$ENCODED_MATRIX_JSON" >> "$GITHUB_OUTPUT" - - name: "Install dependencies with Composer" - uses: "ramsey/composer-install@v2" - with: - dependency-versions: "${{ matrix.dependencies }}" - - - name: "Run Codeception" - run: | - vendor/bin/codecept run -c . -vvv --xml --coverage-xml + codeception-tests: + needs: setup-matrix + strategy: + matrix: ${{ fromJson(needs.setup-matrix.outputs.matrix) }} + uses: pimcore/workflows-collection-public/.github/workflows/reusable-codeception-tests-centralized.yaml@main + with: + APP_ENV: test + PIMCORE_TEST: "1" + PRIVATE_REPO: ${{ needs.setup-matrix.outputs.private_repo }} + PHP_VERSION: ${{ matrix.matrix.php-version }} + DATABASE: "mariadb:10.11" + DEPENDENCIES: ${{ matrix.matrix.dependencies }} + EXPERIMENTAL: ${{ matrix.matrix.experimental }} + PIMCORE_VERSION: ${{ matrix.matrix.pimcore_version }} + REQUIRE_ADMIN_BUNDLE: "false" + PIMCORE_OPEN_SEARCH_HOST: "39200" + PIMCORE_OPENSEARCH_VERSION: "2" + ENABLE_ELASTICSEARCH: false + COVERAGE: "none" + secrets: + SSH_PRIVATE_KEY_PIMCORE_DEPLOYMENTS_USER: ${{ secrets.SSH_PRIVATE_KEY_PIMCORE_DEPLOYMENTS_USER }} + COMPOSER_PIMCORE_REPO_PACKAGIST_TOKEN: ${{ secrets.COMPOSER_PIMCORE_REPO_PACKAGIST_TOKEN }} + PIMCORE_CI_INSTANCE_IDENTIFIER: ${{ secrets.PIMCORE_CI_INSTANCE_IDENTIFIER }} + PIMCORE_CI_ENCRYPTION_SECRET: ${{ secrets.PIMCORE_CI_ENCRYPTION_SECRET }} + PIMCORE_CI_PRODUCT_KEY: ${{ secrets.PIMCORE_CI_PRODUCT_KEY }}