From 8da7c1450b648cfc37c506a2604ca5660e2690b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20Nork=C5=ABnas?= Date: Thu, 1 Aug 2024 15:12:23 +0300 Subject: [PATCH] Sync CI test workflows (#666) --- .github/scripts/get-latest-meilisearch-rc.sh | 12 ++ .github/workflows/meilisearch-beta-tests.yml | 78 +++++++----- .github/workflows/pre-release-tests.yml | 124 ++++++++++++------- 3 files changed, 137 insertions(+), 77 deletions(-) create mode 100644 .github/scripts/get-latest-meilisearch-rc.sh diff --git a/.github/scripts/get-latest-meilisearch-rc.sh b/.github/scripts/get-latest-meilisearch-rc.sh new file mode 100644 index 00000000..af6b47e9 --- /dev/null +++ b/.github/scripts/get-latest-meilisearch-rc.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# This script is used in the SDK CIs to fetch the latest Meilisearch RC name (ex: v0.16.0rc2). +# The Meilisearch RC is needed when maintainers are developing features during the pre-release week because the final Meilisearch release is not out yet. + +temp_file='temp_file' # temp_file needed because `grep` would start before the download is over +curl -s 'https://api.github.com/repos/meilisearch/meilisearch/releases' > "$temp_file" +latest_rc_release=$(cat "$temp_file" \ + | grep -E 'tag_name' | grep 'rc' | head -1 \ + | tr -d ',"' | cut -d ':' -f2 | tr -d ' ') +rm -rf "$temp_file" +echo "$latest_rc_release" diff --git a/.github/workflows/meilisearch-beta-tests.yml b/.github/workflows/meilisearch-beta-tests.yml index 145522e8..12500c06 100644 --- a/.github/workflows/meilisearch-beta-tests.yml +++ b/.github/workflows/meilisearch-beta-tests.yml @@ -11,16 +11,19 @@ on: jobs: meilisearch-version: runs-on: ubuntu-latest - outputs: - version: ${{ steps.grep-step.outputs.version }} steps: - - uses: actions/checkout@v4 + - name: Checkout code + uses: actions/checkout@v4 + - name: Grep docker beta version of Meilisearch id: grep-step run: | MEILISEARCH_VERSION=$(sh .github/scripts/beta-docker-version.sh) echo $MEILISEARCH_VERSION - echo ::set-output name=version::$MEILISEARCH_VERSION + echo "version=$MEILISEARCH_VERSION" >> $GITHUB_OUTPUT + outputs: + version: ${{ steps.grep-step.outputs.version }} + tests: runs-on: ubuntu-latest needs: ['meilisearch-version'] @@ -34,41 +37,54 @@ jobs: - '7700:7700' strategy: matrix: - php-versions: ['7.4', '8.0', '8.1'] - name: integration-tests-against-rc (PHP ${{ matrix.php-versions }}) + php-version: ['7.4', '8.0', '8.1', '8.2', '8.3'] + http-client: ['Guzzle-7', 'Guzzle-7-Adapter', 'Symfony-HttpClient', 'PHP-HTTP-CurlClient', 'Kriswallsmith-Buzz'] + exclude: + - php-version: '7.4' + http-client: 'Symfony-HttpClient' + - php-version: '8.0' + http-client: 'Symfony-HttpClient' + - php-version: '8.1' + http-client: 'Symfony-HttpClient' + + name: integration-tests-against-rc (PHP ${{ matrix.php-version }}) (${{ matrix.http-client }}) steps: - - uses: actions/checkout@v4 + - name: Checkout code + uses: actions/checkout@v4 + - name: Install PHP uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-versions }} + - name: Validate composer.json and composer.lock run: composer validate - - name: Install dependencies - run: | - composer remove --dev friendsofphp/php-cs-fixer --no-update --no-interaction - composer install --prefer-dist --no-progress --no-suggest - - name: Run test suite - default HTTP client (Guzzle 7) - run: | - sh scripts/tests.sh - composer remove --dev guzzlehttp/guzzle http-interop/http-factory-guzzle - - name: Run test suite - php-http/guzzle6-adapter + + - name: Switch to Guzzle7 Adapter + if: matrix.http-client == 'Guzzle-7-Adapter' run: | - composer require --dev php-http/guzzle6-adapter http-interop/http-factory-guzzle - sh scripts/tests.sh - composer remove --dev php-http/guzzle6-adapter http-interop/http-factory-guzzle - - name: Run test suite - symfony/http-client + sed -i 's/"guzzlehttp\/guzzle": "^[0-9]\+\.[0-9]\+\.[0-9]\+\",/"php-http\/guzzle7-adapter": "^1.0.0",/' composer.json + + - name: Switch to Symfony HttpClient + if: matrix.http-client == 'Symfony-HttpClient' run: | - composer require --dev symfony/http-client nyholm/psr7 - sh scripts/tests.sh - composer remove --dev symfony/http-client nyholm/psr7 - - name: Run test suite - php-http/curl-client + sed -i 's/"guzzlehttp\/guzzle": "^[0-9]\+\.[0-9]\+\.[0-9]\+\",/"symfony\/http-client": "^7.1.1",/' composer.json + sed -i 's/"http-interop\/http-factory-guzzle": "^[0-9]\+\.[0-9]\+\.[0-9]\+\",/"nyholm\/psr7": "^1.8.1",/' composer.json + + - name: Switch to PHP HTTP CurlClient + if: matrix.http-client == 'PHP-HTTP-CurlClient' run: | - composer require --dev php-http/curl-client nyholm/psr7 - sh scripts/tests.sh - composer remove --dev php-http/curl-client nyholm/psr7 - - name: Run test suite - kriswallsmith/buzz + sed -i 's/"guzzlehttp\/guzzle": "^[0-9]\+\.[0-9]\+\.[0-9]\+\",/"php-http\/curl-client": "^2.3.2",/' composer.json + sed -i 's/"http-interop\/http-factory-guzzle": "^[0-9]\+\.[0-9]\+\.[0-9]\+\",/"nyholm\/psr7": "^1.8.1",/' composer.json + + - name: Switch to Kriswallsmith Buzz + if: matrix.http-client == 'Kriswallsmith-Buzz' run: | - composer require --dev kriswallsmith/buzz nyholm/psr7 --with-all-dependencies - sh scripts/tests.sh - composer remove --dev kriswallsmith/buzz nyholm/psr7 + sed -i 's/"guzzlehttp\/guzzle": "^[0-9]\+\.[0-9]\+\.[0-9]\+\",/"kriswallsmith\/buzz": "^1.2.1",/' composer.json + sed -i 's/"http-interop\/http-factory-guzzle": "^[0-9]\+\.[0-9]\+\.[0-9]\+\",/"nyholm\/psr7": "^1.8.1",/' composer.json + + - name: Install dependencies + uses: ramsey/composer-install@v3 + + - name: Run test suite + run: sh scripts/tests.sh diff --git a/.github/workflows/pre-release-tests.yml b/.github/workflows/pre-release-tests.yml index 1465a6e4..1cef4b42 100644 --- a/.github/workflows/pre-release-tests.yml +++ b/.github/workflows/pre-release-tests.yml @@ -4,83 +4,115 @@ name: Pre-Release Tests # Will only run for PRs and pushes to bump-meilisearch-v* on: push: - branches: bump-meilisearch-v* + branches: ['bump-meilisearch-v*'] pull_request: - branches: bump-meilisearch-v* + branches: ['bump-meilisearch-v*'] jobs: + meilisearch-version: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Grep docker latest rc version of Meilisearch + id: grep-step + run: | + MEILISEARCH_VERSION=$(sh .github/scripts/get-latest-meilisearch-rc.sh) + echo $MEILISEARCH_VERSION + echo "version=$MEILISEARCH_VERSION" >> $GITHUB_OUTPUT + outputs: + version: ${{ steps.grep-step.outputs.version }} + tests: runs-on: ubuntu-latest + needs: ['meilisearch-version'] + name: integration-tests-against-rc (PHP ${{ matrix.php-versions }}) + services: + meilisearch: + image: getmeili/meilisearch:${{ needs.meilisearch-version.outputs.version }} + env: + MEILI_MASTER_KEY: 'masterKey' + MEILI_NO_ANALYTICS: 'true' + ports: + - '7700:7700' strategy: matrix: php-versions: ['7.4', '8.0', '8.1', '8.2', '8.3'] - name: integration-tests-against-rc (PHP ${{ matrix.php-versions }}) steps: - - uses: actions/checkout@v4 + - name: Checkout code + uses: actions/checkout@v4 + - name: Install PHP uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-versions }} coverage: none + - name: Validate composer.json and composer.lock run: composer validate - - name: Install dependencies - run: | - composer remove --dev friendsofphp/php-cs-fixer --no-update --no-interaction - composer install --prefer-dist --no-progress --no-suggest - - name: Get the latest Meilisearch RC - run: echo "MEILISEARCH_VERSION=$(curl https://raw.githubusercontent.com/meilisearch/integration-guides/main/scripts/get-latest-meilisearch-rc.sh | bash)" >> $GITHUB_ENV - - name: Meilisearch (${{ env.MEILISEARCH_VERSION }}) setup with Docker - run: docker run -d -p 7700:7700 getmeili/meilisearch:${{ env.MEILISEARCH_VERSION }} meilisearch --master-key=masterKey --no-analytics - - name: Run test suite - default HTTP client (Guzzle 7) - run: | - sh scripts/tests.sh - composer remove --dev guzzlehttp/guzzle http-interop/http-factory-guzzle - - name: Run test suite - php-http/guzzle7-adapter + + - name: Switch to Guzzle7 Adapter + if: matrix.http-client == 'Guzzle-7-Adapter' run: | - composer require --dev php-http/guzzle7-adapter http-interop/http-factory-guzzle - sh scripts/tests.sh - composer remove --dev php-http/guzzle7-adapter http-interop/http-factory-guzzle - - name: Run test suite - symfony/http-client + sed -i 's/"guzzlehttp\/guzzle": "^[0-9]\+\.[0-9]\+\.[0-9]\+\",/"php-http\/guzzle7-adapter": "^1.0.0",/' composer.json + + - name: Switch to Symfony HttpClient + if: matrix.http-client == 'Symfony-HttpClient' run: | - composer require --dev symfony/http-client nyholm/psr7 - sh scripts/tests.sh - composer remove --dev symfony/http-client nyholm/psr7 - - name: Run test suite - php-http/curl-client + sed -i 's/"guzzlehttp\/guzzle": "^[0-9]\+\.[0-9]\+\.[0-9]\+\",/"symfony\/http-client": "^7.1.1",/' composer.json + sed -i 's/"http-interop\/http-factory-guzzle": "^[0-9]\+\.[0-9]\+\.[0-9]\+\",/"nyholm\/psr7": "^1.8.1",/' composer.json + + - name: Switch to PHP HTTP CurlClient + if: matrix.http-client == 'PHP-HTTP-CurlClient' run: | - composer require --dev php-http/curl-client nyholm/psr7 - sh scripts/tests.sh - composer remove --dev php-http/curl-client nyholm/psr7 - - name: Run test suite - kriswallsmith/buzz + sed -i 's/"guzzlehttp\/guzzle": "^[0-9]\+\.[0-9]\+\.[0-9]\+\",/"php-http\/curl-client": "^2.3.2",/' composer.json + sed -i 's/"http-interop\/http-factory-guzzle": "^[0-9]\+\.[0-9]\+\.[0-9]\+\",/"nyholm\/psr7": "^1.8.1",/' composer.json + + - name: Switch to Kriswallsmith Buzz + if: matrix.http-client == 'Kriswallsmith-Buzz' run: | - composer require --dev kriswallsmith/buzz nyholm/psr7 --with-all-dependencies - composer update php-http/client-common:2.6.0 php-http/httplug:2.3.0 psr/http-message - sh scripts/tests.sh - composer remove --dev kriswallsmith/buzz nyholm/psr7 + sed -i 's/"guzzlehttp\/guzzle": "^[0-9]\+\.[0-9]\+\.[0-9]\+\",/"kriswallsmith\/buzz": "^1.2.1",/' composer.json + sed -i 's/"http-interop\/http-factory-guzzle": "^[0-9]\+\.[0-9]\+\.[0-9]\+\",/"nyholm\/psr7": "^1.8.1",/' composer.json + + - name: Install dependencies + uses: ramsey/composer-install@v3 + + - name: Run test suite + run: sh scripts/tests.sh test_php_7_guzzle_6: runs-on: ubuntu-latest + needs: ['meilisearch-version'] name: integration-tests-against-rc (PHP 7.4 & Guzzle 6) + services: + meilisearch: + image: getmeili/meilisearch:${{ needs.meilisearch-version.outputs.version }} + env: + MEILI_MASTER_KEY: 'masterKey' + MEILI_NO_ANALYTICS: 'true' + ports: + - '7700:7700' + steps: - - uses: actions/checkout@v4 + - name: Checkout code + uses: actions/checkout@v4 + - name: Install PHP uses: shivammathur/setup-php@v2 with: php-version: '7.4' coverage: none + - name: Validate composer.json and composer.lock run: composer validate - - name: Install dependencies + + - name: Switch to Guzzle 6 run: | - composer remove --dev friendsofphp/php-cs-fixer --no-update --no-interaction - composer update --prefer-dist --no-progress - composer remove --dev guzzlehttp/guzzle http-interop/http-factory-guzzle - composer update php-http/client-common:2.6.0 php-http/httplug:2.3.0 psr/http-message - - name: Get the latest Meilisearch RC - run: echo "MEILISEARCH_VERSION=$(curl https://raw.githubusercontent.com/meilisearch/integration-guides/main/scripts/get-latest-meilisearch-rc.sh | bash)" >> $GITHUB_ENV - - name: Meilisearch (${{ env.MEILISEARCH_VERSION }}) setup with Docker - run: docker run -d -p 7700:7700 getmeili/meilisearch:${{ env.MEILISEARCH_VERSION }} meilisearch --master-key=masterKey --no-analytics + sed -i 's/"guzzlehttp\/guzzle": "^[0-9]\+\.[0-9]\+\.[0-9]\+\",/"php-http\/guzzle6-adapter": "^2.0.2",/' composer.json + + - name: Install dependencies + uses: ramsey/composer-install@v3 + - name: Run test suite - php-http/guzzle6-adapter - run: | - composer require --dev php-http/guzzle6-adapter http-interop/http-factory-guzzle - sh scripts/tests.sh + run: sh scripts/tests.sh