diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8ab8d12..359f12d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,185 +6,76 @@ on: - "**" jobs: - php84: - name: "php 8.4" + php-tests: + name: php ${{ matrix.php-version }} runs-on: ubuntu-latest - container: "nofutur3/php-tests:8.4" - services: - openAPImock: - image: mockserver/mockserver - ports: - - 1080:1080 - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Install dependencies - run: composer install - - - name: Run static analysis - run: composer stan + strategy: + fail-fast: false + matrix: + php-version: ['7.4', '8.0', '8.1', '8.3', '8.4', '8.5'] - - name: Create mock server from our production OpenAPI - run: curl -X PUT -d "{\"specUrlOrPayload\":\"https://gate.thepay.cz/openapi.yaml\"}" http://openAPImock:1080/mockserver/openapi - - - name: Run tests - run: composer test - - php83: - name: "php 8.3" - runs-on: ubuntu-latest - container: "nofutur3/php-tests:8.3" - services: - openAPImock: - image: mockserver/mockserver - ports: - - 1080:1080 steps: - - name: Checkout repository - uses: actions/checkout@v4 + - name: Start mock server + run: docker run -d -p 1080:1080 mockserver/mockserver - - name: Install dependencies - run: composer install - - - name: Run static analysis - run: composer stan - - - name: Create mock server from our production OpenAPI - run: curl -X PUT -d "{\"specUrlOrPayload\":\"https://gate.thepay.cz/openapi.yaml\"}" http://openAPImock:1080/mockserver/openapi - - - name: Run tests - run: composer test - - php82: - name: "php 8.2 psr/http-message 2.0" - runs-on: ubuntu-latest - container: "nofutur3/php-tests:8.2" - services: - openAPImock: - image: mockserver/mockserver - ports: - - 1080:1080 - steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v6 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + coverage: none + extensions: mbstring, intl, curl - name: Install dependencies - run: composer update --no-interaction --with psr/http-message:^2.0 + run: composer install --no-interaction - - name: Check code style + - name: Check code style (PHP 8.5) + if: matrix.php-version == '8.5' run: composer cs-check - name: Run static analysis run: composer stan - name: Create mock server from our production OpenAPI - run: curl -X PUT -d "{\"specUrlOrPayload\":\"https://gate.thepay.cz/openapi.yaml\"}" http://openAPImock:1080/mockserver/openapi + run: curl -X PUT -d "{\"specUrlOrPayload\":\"https://gate.thepay.cz/openapi.yaml\"}" http://localhost:1080/mockserver/openapi - name: Run tests run: composer test - php82psrmessage10: - name: "php 8.2 psr/http-message 1.0" - runs-on: ubuntu-latest - container: "nofutur3/php-tests:8.2" - services: - openAPImock: - image: mockserver/mockserver - ports: - - 1080:1080 - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Install dependencies - run: composer update --no-interaction --with psr/http-message:^1.0 - - - name: Run static analysis - run: composer stan - - - name: Create mock server from our production OpenAPI - run: curl -X PUT -d "{\"specUrlOrPayload\":\"https://gate.thepay.cz/openapi.yaml\"}" http://openAPImock:1080/mockserver/openapi - - - name: Run tests - run: composer test - - php81: - name: "php 8.1" - runs-on: ubuntu-latest - container: "nofutur3/php-tests:8.1" - services: - openAPImock: - image: mockserver/mockserver - ports: - - 1080:1080 - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Install dependencies - run: composer install --no-interaction - - - name: Run static analysis - run: composer stan - - name: Create mock server from our production OpenAPI - run: curl -X PUT -d "{\"specUrlOrPayload\":\"https://gate.thepay.cz/openapi.yaml\"}" http://openAPImock:1080/mockserver/openapi - - - name: Run tests - run: composer test - - php80: - name: "php 8.0" + php-with-psr-tests: + name: php ${{ matrix.php-version }} psr/http-message ${{ matrix.psr-http-message-version }} runs-on: ubuntu-latest - container: "nofutur3/php-tests:8.0" - services: - openAPImock: - image: mockserver/mockserver - ports: - - 1080:1080 - steps: - - name: Checkout repository - uses: actions/checkout@v3 + strategy: + fail-fast: false + matrix: + php-version: ['8.2'] + psr-http-message-version: ['1.0', '2.0'] - - name: Install dependencies - run: composer install --no-interaction - - - name: Run static analysis - run: composer stan - - - name: Create mock server from our production OpenAPI - run: curl -X PUT -d "{\"specUrlOrPayload\":\"https://gate.thepay.cz/openapi.yaml\"}" http://openAPImock:1080/mockserver/openapi - - - name: Run tests - run: composer test - - php74: - name: "php 7.4" - runs-on: ubuntu-latest - container: "nofutur3/php-tests:7.4" - services: - openAPImock: - image: mockserver/mockserver - ports: - - 1080:1080 steps: - # Deprecation example for future support removal. - # - #- name: Deprecation check (2023-01-01T00:00:00+01:00) - # run: if [ "$(date +%s)" -gt "1672527600" ]; then echo "This PHP version support ended"; exit1; else echo "Deprecation OK"; fi + - name: Start mock server + run: docker run -d -p 1080:1080 mockserver/mockserver - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v6 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + coverage: none + extensions: mbstring, intl, curl - name: Install dependencies - run: composer install --no-interaction + run: composer update --no-interaction --with psr/http-message:^${{ matrix.psr-http-message-version }} - name: Run static analysis run: composer stan - name: Create mock server from our production OpenAPI - run: curl -X PUT -d "{\"specUrlOrPayload\":\"https://gate.thepay.cz/openapi.yaml\"}" http://openAPImock:1080/mockserver/openapi + run: curl -X PUT -d "{\"specUrlOrPayload\":\"https://gate.thepay.cz/openapi.yaml\"}" http://localhost:1080/mockserver/openapi - name: Run tests run: composer test @@ -195,7 +86,7 @@ jobs: container: "node" steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v6 - name: Install dependencies run: npm install diff --git a/tests/Mocks/TheConfig.php b/tests/Mocks/TheConfig.php index 5187368..4ab2556 100644 --- a/tests/Mocks/TheConfig.php +++ b/tests/Mocks/TheConfig.php @@ -22,9 +22,6 @@ public function __construct() */ public function getApiUrl(?string $specificVersion = null): string { - if ($specificVersion !== null) { - return 'http://openAPImock:1080/' . $specificVersion . '/'; - } - return 'http://openAPImock:1080/' . $this->getApiVersion() . '/'; + return 'http://localhost:1080/' . ($specificVersion ?? $this->getApiVersion()) . '/'; } }