From 174c190836385c8f769634824924c4ea112e8d54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Thu, 31 Mar 2022 15:54:06 +0200 Subject: [PATCH 1/3] [CI] Moved integration tests to Github Actions (#93) --- .github/workflows/ci.yaml | 3 + .../workflows/integration-tests-callable.yaml | 50 +++++++++++++ .travis.yml | 74 ------------------- composer.json | 3 +- 4 files changed, 55 insertions(+), 75 deletions(-) create mode 100644 .github/workflows/integration-tests-callable.yaml delete mode 100644 .travis.yml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d2fdba1d..b601db77 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -67,3 +67,6 @@ jobs: - name: Run unit test suite run: composer test + integration-tests: + name: "REST integration tests" + uses: ./.github/workflows/integration-tests-callable.yaml diff --git a/.github/workflows/integration-tests-callable.yaml b/.github/workflows/integration-tests-callable.yaml new file mode 100644 index 00000000..db58bd25 --- /dev/null +++ b/.github/workflows/integration-tests-callable.yaml @@ -0,0 +1,50 @@ +on: + workflow_call: ~ + +env: + APP_ENV: dev + APP_DEBUG: 1 + PHP_INI_ENV_memory_limit: 512M + COMPOSER_CACHE_DIR: ~/.composer/cache + PROJECT_VERSION: ^3.3.x-dev + PROJECT_EDITION: oss + SETUP: "doc/docker/base-dev.yml:doc/docker/selenium.yml" + WEB_HOST: web + +jobs: + integration-tests-rest: + runs-on: ubuntu-latest + timeout-minutes: 15 + + steps: + - uses: actions/checkout@v2 + + - name: Setup PHP Action + uses: shivammathur/setup-php@v2 + with: + php-version: 7.4 + coverage: none + + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: ${{ env.COMPOSER_CACHE_DIR }} + key: ${{ env.PROJECT_EDITION }}-${{ env.PROJECT_VERSION }}-${{ github.sha }} + restore-keys: | + ${{ env.PROJECT_EDITION }}-${{ env.PROJECT_VERSION }} + + - name: Set up whole project using the tested dependency + run: | + curl -L "https://raw.githubusercontent.com/ibexa/ci-scripts/main/bin/${{ env.PROJECT_VERSION }}/prepare_project_edition.sh" > prepare_project_edition.sh + chmod +x prepare_project_edition.sh + ./prepare_project_edition.sh ${{ env.PROJECT_EDITION }} ${{ env.PROJECT_VERSION }} ${{ env.SETUP }} + + - name: Run setup command + run: | + cd "$HOME/build/project" + docker-compose --env-file=.env exec -T --user www-data app sh -c "APP_ENV=behat php bin/console ibexa:behat:create-language 'pol-PL' 'Polish (polski)'" + + - name: Run tests + run: | + cd "$HOME/build/project" + docker-compose --env-file=.env exec -T --user www-data app sh -c "cd vendor/ezsystems/ezplatform-rest && composer update && composer integration" diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index cca9b16b..00000000 --- a/.travis.yml +++ /dev/null @@ -1,74 +0,0 @@ -# Use trusty for better performance (and avoiding mysql/postgres/solr gone issues on precise and container infra) -dist: trusty -sudo: required - -language: php - -services: - - mysql - -# Mysql isn't installed on trusty (only client is), so we need to specifically install it -addons: - apt: - packages: - - mysql-server-5.6 - - mysql-client-core-5.6 - - mysql-client-5.6 - -cache: - directories: - - $HOME/.composer/cache/files - -env: - global: - # For functional and acceptance tests - - COMPOSE_FILE="doc/docker/base-dev.yml:doc/docker/selenium.yml" - - PROJECT_VERSION=^3.3.x-dev - -matrix: - fast_finish: true - include: -# 7.3 - - name: "PHP 7.3 REST Integration Tests" - php: 7.3 - env: - - REST_TEST_CONFIG="phpunit-integration-rest.xml" - - APP_ENV=dev - - APP_DEBUG=1 - - SF_CMD="ez:behat:create-language 'pol-PL' 'Polish (polski)'" - - WEB_HOST=web - -# test only master, stable branches and pull requests -branches: - only: - - master - - /^\d.\d+$/ - -# setup requirements for running unit/integration/behat tests -install: - # Disable memory_limit for composer - - echo "memory_limit=-1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini - # Prepare system - - travis_retry composer install --prefer-dist --no-interaction --no-suggest - - ./vendor/bin/prepare_project_edition.sh oss ${PROJECT_VERSION} ${COMPOSE_FILE} - # Execute Symfony command if specified - - cd "$HOME/build/project"; docker-compose exec --user www-data app sh -c "APP_ENV=behat php bin/console $SF_CMD" - # Detecting timezone issues by testing on random timezone - - TEST_TIMEZONES=("America/New_York" "Asia/Calcutta" "UTC") - - TEST_TIMEZONE=${TEST_TIMEZONES["`shuf -i 0-2 -n 1`"]} - -# execute phpunit or behat as the script command -script: - - cd "$HOME/build/project"; docker-compose exec app sh -c "cd ezsystems/ezplatform-rest && composer update && php ./vendor/bin/phpunit -c phpunit-integration-rest.xml" - -notifications: - slack: - rooms: - - secure: EesyExipldfURHELpH76Dp31/CePOvkJAjg9sw1OF/FdNtuAiOr9LzU3xmVDrZRJwVgjtyfHS/RqwrkS883ohZVo4p38uA+XsMDjWJ/KzGzQGpqFivPH3hv3MUjaHjASokF9ChbBhwp0RY/bCiRSaKEAuHmVJnbFU7C81Pd0Fr7ObSc0GrhMX728VFX38I8RLzaYG656nrUszHGkER8Mz8y0QYdSbxQhfiN67d2+U1e/sZaY44nP4MDPKkqTkIDLb8e/wgGT97Lj05KHTXps7UVsJLQeQ14dSmAQKo6QMAz+LEz+/Rd3JN9B50D4pbU/gM0L1JbNcsb4D2asXWP3ZHF0EaZQ0uv1n5pOgw1DJEdTa6VsbM+r4Wbq/PE+IdZoIBZTyojWKD/tbzUapd6kX2fOq0DyZaUCvXNEIAOPbwfI/TstLtbU7eWBwzTsdW5V5PTcRqxjpCtzxMeNlarNWDzWP97nkgf7xErOkiMGE4g8wyaKqFG4EBDilQNzmUCqRKdgNUXmxxD7oxU0c6t8qnrp7mpud+jm3u0VoQKzNCDOLTZyA6k3Vd/lGwm3VKMfadi0x/Ssy5JE0mNcA9b4Vrt2fn/iAHMLf/qop3m49evaY9ytyiEmux/mFpFL3LiCrmGac/rqDL4h0eCjeQFuKfJJwu7RKuvHhsXX7yrOvaU= - on_success: change - on_failure: always - on_pull_requests: false - -# reduce depth (history) of git checkout -git: - depth: 30 diff --git a/composer.json b/composer.json index 54b759e1..bec86f96 100644 --- a/composer.json +++ b/composer.json @@ -60,7 +60,8 @@ "scripts": { "fix-cs": "php-cs-fixer fix -v --show-progress=estimating", "check-cs": "@fix-cs --dry-run", - "test": "phpunit -c phpunit.xml" + "test": "phpunit -c phpunit.xml", + "integration": "phpunit -c phpunit-integration-rest.xml" }, "extra": { "branch-alias": { From 446828fb4d35db2fadc5bce49fdd3d74b34a4621 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Thu, 31 Mar 2022 17:56:09 +0200 Subject: [PATCH 2/3] [CI] Run tests on 4.0.x-dev --- .github/workflows/integration-tests-callable.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/integration-tests-callable.yaml b/.github/workflows/integration-tests-callable.yaml index db58bd25..1e6ec9ff 100644 --- a/.github/workflows/integration-tests-callable.yaml +++ b/.github/workflows/integration-tests-callable.yaml @@ -6,7 +6,7 @@ env: APP_DEBUG: 1 PHP_INI_ENV_memory_limit: 512M COMPOSER_CACHE_DIR: ~/.composer/cache - PROJECT_VERSION: ^3.3.x-dev + PROJECT_VERSION: 4.0.x-dev PROJECT_EDITION: oss SETUP: "doc/docker/base-dev.yml:doc/docker/selenium.yml" WEB_HOST: web @@ -47,4 +47,4 @@ jobs: - name: Run tests run: | cd "$HOME/build/project" - docker-compose --env-file=.env exec -T --user www-data app sh -c "cd vendor/ezsystems/ezplatform-rest && composer update && composer integration" + docker-compose --env-file=.env exec -T --user www-data app sh -c "cd vendor/ibexa/rest && composer update && composer integration" From 72e2578496e6773d099ac84058b7c080374de30c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Thu, 31 Mar 2022 17:58:46 +0200 Subject: [PATCH 3/3] Fixed route creation based on Content Type status --- .../Output/ValueObjectVisitor/CreatedFieldDefinition.php | 2 +- .../Server/Output/ValueObjectVisitor/FieldDefinitionList.php | 2 +- .../Server/Output/ValueObjectVisitor/RestContentTypeBase.php | 4 ++-- .../Server/Output/ValueObjectVisitor/RestFieldDefinition.php | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib/Server/Output/ValueObjectVisitor/CreatedFieldDefinition.php b/src/lib/Server/Output/ValueObjectVisitor/CreatedFieldDefinition.php index 24a628b2..1f7cc244 100644 --- a/src/lib/Server/Output/ValueObjectVisitor/CreatedFieldDefinition.php +++ b/src/lib/Server/Output/ValueObjectVisitor/CreatedFieldDefinition.php @@ -33,7 +33,7 @@ public function visit(Visitor $visitor, Generator $generator, $data) $visitor->setHeader( 'Location', $this->router->generate( - "ibexa.rest.load_content_type_{$draftUriPart}field_definition", + "ibexa.rest.load_content_type{$draftUriPart}_field_definition", [ 'contentTypeId' => $restFieldDefinition->contentType->id, 'fieldDefinitionId' => $restFieldDefinition->fieldDefinition->id, diff --git a/src/lib/Server/Output/ValueObjectVisitor/FieldDefinitionList.php b/src/lib/Server/Output/ValueObjectVisitor/FieldDefinitionList.php index 51511e2e..c2e670bc 100644 --- a/src/lib/Server/Output/ValueObjectVisitor/FieldDefinitionList.php +++ b/src/lib/Server/Output/ValueObjectVisitor/FieldDefinitionList.php @@ -37,7 +37,7 @@ public function visit(Visitor $visitor, Generator $generator, $data) $generator->startAttribute( 'href', $this->router->generate( - 'ibexa.rest.load_content_type_' . $urlTypeSuffix . 'field_definition_list', + 'ibexa.rest.load_content_type' . $urlTypeSuffix . '_field_definition_list', [ 'contentTypeId' => $contentType->id, ] diff --git a/src/lib/Server/Output/ValueObjectVisitor/RestContentTypeBase.php b/src/lib/Server/Output/ValueObjectVisitor/RestContentTypeBase.php index 3343de1a..9bba8fd3 100644 --- a/src/lib/Server/Output/ValueObjectVisitor/RestContentTypeBase.php +++ b/src/lib/Server/Output/ValueObjectVisitor/RestContentTypeBase.php @@ -26,9 +26,9 @@ protected function getUrlTypeSuffix($contentTypeStatus) { switch ($contentTypeStatus) { case Values\ContentType\ContentType::STATUS_DRAFT: - return 'draft_'; + return '_draft'; case Values\ContentType\ContentType::STATUS_MODIFIED: - return 'modified_'; + return '_modified'; case Values\ContentType\ContentType::STATUS_DEFINED: default: return ''; diff --git a/src/lib/Server/Output/ValueObjectVisitor/RestFieldDefinition.php b/src/lib/Server/Output/ValueObjectVisitor/RestFieldDefinition.php index 72d495b3..601bdbab 100644 --- a/src/lib/Server/Output/ValueObjectVisitor/RestFieldDefinition.php +++ b/src/lib/Server/Output/ValueObjectVisitor/RestFieldDefinition.php @@ -56,7 +56,7 @@ public function visit(Visitor $visitor, Generator $generator, $data) $generator->startAttribute( 'href', $this->router->generate( - "ibexa.rest.load_content_type_{$urlTypeSuffix}field_definition", + "ibexa.rest.load_content_type{$urlTypeSuffix}_field_definition", [ 'contentTypeId' => $contentType->id, 'fieldDefinitionId' => $fieldDefinition->id,