Dynamically copy scaffold file mapping when create fake_site fixture

Created on 6 February 2023, over 2 years ago
Updated 23 February 2023, about 2 years ago

Problem/Motivation

follow-up to 🐛 The 'fake_site' fixture cannot be using with `composer show` because the packages are not installed Fixed

modules/automatic_updates/package_manager/tests/fixtures/path_repos/drupal--core has drupal-scaffold.file_mapping specified that was copied from the pre #3335908 version of package_manager/tests/fixtures/fake_site/vendor/composer/installed.json

Steps to reproduce

Proposed resolution

During \Drupal\automatic_updates\Development\ComposerFixtureCreator::createFixture which is run just when creating updating the fixture at package_manager/tests/fixtures/fake_site and then will be committed to the repo
We should see if we can just copy the file_mapping values from `core/composer.json` to /automatic_updates/package_manager/tests/fixtures/path_repos/drupal--core

We should check how this affects ScaffoldFilePermissionsValidatorTest to ensure we don't lose test coverage and if we need to change/extend coverage

Remaining tasks

User interface changes

API changes

Data model changes

📌 Task
Status

Fixed

Version

3.0

Component

Code

Created by

🇺🇸United States tedbow Ithaca, NY, USA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @tedbow
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
  • 🇺🇸United States tedbow Ithaca, NY, USA
  • Assigned to phenaproxima
  • 🇺🇸United States tedbow Ithaca, NY, USA
  • Issue was unassigned.
  • 🇺🇸United States phenaproxima Massachusetts

    Given that the scope of this issue, per discussion with @tedbow, only involves the file mapping from drupal/core and the root composer.json, I think it's probably okay if someone who isn't me deals with this.

  • Assigned to kunal.sachdev
  • @kunalsachdev opened merge request.
  • 🇺🇸United States tedbow Ithaca, NY, USA
  • @kunalsachdev opened merge request.
  • Issue was unassigned.
  • Status changed to Needs review over 2 years ago
  • Status changed to Needs work over 2 years ago
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
  • Status changed to Needs review over 2 years ago
  • Assigned to kunal.sachdev
  • Status changed to Needs work about 2 years ago
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    Did you try running it locally? The creator of the fixture itself does not have tests, so a green test run is meaningless!

    $ composer create-site-fixture ~/core
    > \Drupal\automatic_updates\Development\ComposerFixtureCreator::createFixture
    Script \Drupal\automatic_updates\Development\ComposerFixtureCreator::createFixture handling the create-site-fixture event terminated with an exception
    
    In ComposerFixtureCreator.php line 39:
                                                                                                                                                                                     
      file_get_contents(/Users/wim.leers/core/modules/contrib/automatic_updates/scripts/src/../../package_manager/tests/fixtures/fake_site../path_repos/drupal--core/composer.json)  
      : Failed to open stream: No such file or directory                                                                                                                             
                                                                                                                                                                                     
    
    create-site-fixture [--dev] [--no-dev] [--] [<args>...]
    
    

    And if I fix that I get

    $ composer create-site-fixture ~/core
    > \Drupal\automatic_updates\Development\ComposerFixtureCreator::createFixture
    Script \Drupal\automatic_updates\Development\ComposerFixtureCreator::createFixture handling the create-site-fixture event terminated with an exception
    
    In ComposerFixtureCreator.php line 41:
                                             
      Undefined array key "drupal-scaffold"  
                                             
    
    create-site-fixture [--dev] [--no-dev] [--] [<args>...]
    
  • 🇮🇳India kunal.sachdev

    If I run it locally I get

    $ composer create-site-fixture ../../../core
    > \Drupal\automatic_updates\Development\ComposerFixtureCreator::createFixture
    Script \Drupal\automatic_updates\Development\ComposerFixtureCreator::createFixture handling the create-site-fixture event terminated with an exception
    
    In ComposerFixtureCreator.php line 39:
                                                                                   
      file_get_contents(/Users/kunal.sachdev/www/d9-autoupdates/modules/contrib/a  
      utomatic_updates/scripts/src/../../package_manager/tests/fixtures/fake_site  
      ../path_repos/drupal--core/composer.json): Failed to open stream: No such f  
      ile or directory                                                             
                                                                                   
    
    create-site-fixture [--dev] [--no-dev] [--] [<args>...]

    And if I fix that I get

    $ composer create-site-fixture ../../../core
    > \Drupal\automatic_updates\Development\ComposerFixtureCreator::createFixture
    
    Fixture created 🎉.% 
  • Assigned to wim leers
  • Status changed to Needs review about 2 years ago
  • Assigned to kunal.sachdev
  • Status changed to Needs work about 2 years ago
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
    composer create-site-fixture ~/core
    

    was wrong of me!

    I should've done

    $ composer create-site-fixture ~/core/core
    > \Drupal\automatic_updates\Development\ComposerFixtureCreator::createFixture
    
    Fixture created 🎉.
    

    I can confirm this works correctly. But what's missing is actually including the results of executing that command in this MR! 😅

  • Assigned to wim leers
  • Status changed to Needs review about 2 years ago
  • Issue was unassigned.
  • Status changed to RTBC about 2 years ago
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
  • Assigned to kunal.sachdev
  • Status changed to Needs work about 2 years ago
  • Issue was unassigned.
  • Status changed to Needs review about 2 years ago
  • Status changed to RTBC about 2 years ago
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
    1. Changes look good. 👍
    2. Manual test:
      curl https://git.drupalcode.org/project/automatic_updates/-/merge_requests/701.diff | git apply -3v
      
      $ rm -rf package_manager/tests/fixtures/fake_site/composer.lock 
      wim.leers at MacBookPro-WimLeers in ~/core/modules/contrib/automatic_updates on 3.0.x*
      $ composer create-site-fixture /Users/wim.leers/core/core
      > \Drupal\automatic_updates\Development\ComposerFixtureCreator::createFixture
      
      Fixture created 🎉.
      wim.leers at MacBookPro-WimLeers in ~/core/modules/contrib/automatic_updates on 3.0.x*
      $ git diff
      wim.leers at MacBookPro-WimLeers in ~/core/modules/contrib/automatic_updates on 3.0.x*
      

      ⇒ 🚀

  • 🇺🇸United States phenaproxima Massachusetts
  • Status changed to Fixed about 2 years ago
  • 🇺🇸United States phenaproxima Massachusetts

    Like! Over and out.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024