Skip to content

Commit

Permalink
Expand tests and use GitHub actions (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
eiriksm authored Jul 3, 2022
1 parent 629263b commit 4daa45d
Show file tree
Hide file tree
Showing 5 changed files with 268 additions and 11 deletions.
83 changes: 83 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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://[email protected]/$DATABASE" -y
Expand Down
10 changes: 0 additions & 10 deletions tests/assets/test-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@
"module": "path_alias",
"value": "8000"
},
{
"type": "schema",
"module": "system",
"value": "8805"
},
{
"type": "schema",
"module": "text",
Expand Down Expand Up @@ -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": "",
Expand Down
177 changes: 177 additions & 0 deletions tests/assets/test-schema9.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
6 changes: 6 additions & 0 deletions tests/src/Integration/SiteSchemaIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 4daa45d

Please sign in to comment.