From 4daa45da347fa27a7d1ec140120085e53e6d9698 Mon Sep 17 00:00:00 2001 From: Eirik Stanghelle Morland Date: Sun, 3 Jul 2022 07:20:26 +0200 Subject: [PATCH] Expand tests and use GitHub actions (#4) --- .github/workflows/test.yml | 83 ++++++++ .travis.yml | 3 +- tests/assets/test-schema.json | 10 - tests/assets/test-schema9.json | 177 ++++++++++++++++++ .../Integration/SiteSchemaIntegrationTest.php | 6 + 5 files changed, 268 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/test.yml create mode 100644 tests/assets/test-schema9.json diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..8edb415 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,83 @@ +name: Test +on: + - push + - pull_request + +jobs: + test: + name: Run tests + runs-on: 'ubuntu-20.04' + env: + SCHEMA_PATH: /tmp/test-schema.json + strategy: + fail-fast: false + matrix: + php-version: + - "7.2" + - "7.3" + - "7.4" + drupal-version: + - "8" + - "9" + drush-version: + - "9" + - "10" + - "11" + steps: + - name: Dump matrix context + env: + MATRIX_CONTEXT: ${{ toJSON(matrix) }} + run: echo "$MATRIX_CONTEXT" + + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + + - name: Dump composer verson + run: composer --version + + - name: Validate composer.json + run: composer --verbose validate + + - name: Install dependencies + run: composer --verbose install + + - name: set skip flag + id: skip + if: ${{ (matrix.drupal-version == '9' && matrix.php-version == '7.2') || (matrix.drush-version == '9' && matrix.drupal-version == '9') || (matrix.drush-version == '11' && matrix.php-version == '7.3') || (matrix.drush-version == '11' && matrix.php-version == '7.2') || (matrix.drupal-version == '8' && matrix.drush-version == '11') }} + run: echo "::set-output name=skip::1" + + - name: Install drupal + if: matrix.drupal-version == '8' + run: | + cd .. && composer create-project drupal/recommended-project:8.9.20 test-project --no-interaction + cd test-project + - name: install drupal + if: ${{ matrix.drupal-version == '9' && steps.skip.outputs.skip != '1' }} + run: | + cd .. && composer create-project drupal/recommended-project:9.4.1 test-project --no-interaction + - name: install Drush + if: ${{ steps.skip.outputs.skip != '1' }} + run: | + cd ../test-project + composer require drush/drush:^${{ matrix.drush-version }} + - name: run tests + if: ${{ steps.skip.outputs.skip != '1' }} + env: + DRUPAL_VERSION: ${{ matrix.drupal-version }} + run: | + cd .. + cd test-project + composer config --no-plugins allow-plugins.composer/installers true + composer config --no-plugins allow-plugins.drupal/core-composer-scaffold true + composer install + ./vendor/bin/drush si minimal --db-url=sqlite://sites/default/files/.ht.sqlite -y + mkdir -p drush/Commands/contrib + cp -r ../drush-site-schema drush/Commands/contrib/site-schema + ./vendor/bin/drush site-schema --format=json > $SCHEMA_PATH + cd ../drush-site-schema + ./vendor/bin/phpunit diff --git a/.travis.yml b/.travis.yml index 09ea857..259da9a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,7 +21,8 @@ install: script: # Run automated tests. - - cd .. && composer create-project drupal/recommended-project test-project --no-interaction + - composer self-update --1 + - cd .. && composer create-project drupal/recommended-project:8.8.6 test-project --no-interaction - cd test-project - composer require drush/drush - ./vendor/bin/drush si minimal --db-url="mysql://$DB_USERNAME@127.0.0.1/$DATABASE" -y diff --git a/tests/assets/test-schema.json b/tests/assets/test-schema.json index 1e781a8..004d87b 100644 --- a/tests/assets/test-schema.json +++ b/tests/assets/test-schema.json @@ -44,11 +44,6 @@ "module": "path_alias", "value": "8000" }, - { - "type": "schema", - "module": "system", - "value": "8805" - }, { "type": "schema", "module": "text", @@ -179,11 +174,6 @@ "module": "", "value": "system_post_update_fix_jquery_extend" }, - { - "type": "post_update", - "module": "", - "value": "system_post_update_fix_jquery_htmlprefilter" - }, { "type": "post_update", "module": "", diff --git a/tests/assets/test-schema9.json b/tests/assets/test-schema9.json new file mode 100644 index 0000000..06a09b3 --- /dev/null +++ b/tests/assets/test-schema9.json @@ -0,0 +1,177 @@ +[ + { + "type": "schema", + "module": "block", + "value": "8003" + }, + { + "type": "schema", + "module": "dblog", + "value": "8600" + }, + { + "type": "schema", + "module": "dynamic_page_cache", + "value": "8000" + }, + { + "type": "schema", + "module": "field", + "value": "8500" + }, + { + "type": "schema", + "module": "filter", + "value": "8000" + }, + { + "type": "schema", + "module": "minimal", + "value": "8000" + }, + { + "type": "schema", + "module": "node", + "value": "8700" + }, + { + "type": "schema", + "module": "page_cache", + "value": "8000" + }, + { + "type": "schema", + "module": "path_alias", + "value": "8000" + }, + { + "type": "schema", + "module": "sqlite", + "value": "8000" + }, + { + "type": "schema", + "module": "system", + "value": "8901" + }, + { + "type": "schema", + "module": "text", + "value": "8000" + }, + { + "type": "schema", + "module": "update", + "value": "8001" + }, + { + "type": "schema", + "module": "user", + "value": "9301" + }, + { + "type": "post_update", + "module": "", + "value": "block_post_update_replace_node_type_condition" + }, + { + "type": "post_update", + "module": "", + "value": "node_post_update_glossary_view_published" + }, + { + "type": "post_update", + "module": "", + "value": "node_post_update_modify_base_field_author_override" + }, + { + "type": "post_update", + "module": "", + "value": "node_post_update_rebuild_node_revision_routes" + }, + { + "type": "post_update", + "module": "", + "value": "system_post_update_claro_dropbutton_variants" + }, + { + "type": "post_update", + "module": "", + "value": "system_post_update_delete_authorize_settings" + }, + { + "type": "post_update", + "module": "", + "value": "system_post_update_delete_rss_settings" + }, + { + "type": "post_update", + "module": "", + "value": "system_post_update_enable_provider_database_driver" + }, + { + "type": "post_update", + "module": "", + "value": "system_post_update_entity_revision_metadata_bc_cleanup" + }, + { + "type": "post_update", + "module": "", + "value": "system_post_update_extra_fields_form_display" + }, + { + "type": "post_update", + "module": "", + "value": "system_post_update_remove_key_value_expire_all_index" + }, + { + "type": "post_update", + "module": "", + "value": "system_post_update_schema_version_int" + }, + { + "type": "post_update", + "module": "", + "value": "system_post_update_service_advisory_settings" + }, + { + "type": "post_update", + "module": "", + "value": "system_post_update_sort_all_config" + }, + { + "type": "post_update", + "module": "", + "value": "system_post_update_uninstall_classy" + }, + { + "type": "post_update", + "module": "", + "value": "system_post_update_uninstall_entity_reference_module" + }, + { + "type": "post_update", + "module": "", + "value": "system_post_update_uninstall_simpletest" + }, + { + "type": "post_update", + "module": "", + "value": "system_post_update_uninstall_stable" + }, + { + "type": "post_update", + "module": "", + "value": "text_post_update_add_required_summary_flag_form_display" + }, + { + "type": "post_update", + "module": "", + "value": "update_post_update_add_view_update_notifications_permission" + }, + { + "type": "post_update", + "module": "", + "value": "user_post_update_update_roles" + } +] diff --git a/tests/src/Integration/SiteSchemaIntegrationTest.php b/tests/src/Integration/SiteSchemaIntegrationTest.php index aff1846..60e24d8 100644 --- a/tests/src/Integration/SiteSchemaIntegrationTest.php +++ b/tests/src/Integration/SiteSchemaIntegrationTest.php @@ -15,6 +15,12 @@ public function testOutput() { $data = json_decode(file_get_contents($filepath)); // It should at least contain all of the things we had when we made this. $expected_contents = json_decode(file_get_contents(__DIR__ . '/../../assets/test-schema.json')); + if (getenv('DRUPAL_VERSION')) { + $filename = __DIR__ . '/../../assets/test-schema' . getenv('DRUPAL_VERSION') . '.json'; + if (file_exists($filename)) { + $expected_contents = json_decode(file_get_contents($filename)); + } + } foreach ($expected_contents as $item) { // We expect it to be in the generated one. foreach ($data as $generated_item) {