Problem/Motivation

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

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

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

tedbow created an issue. See original summary.

wim leers’s picture

Issue tags: +maintainability
tedbow’s picture

Issue summary: View changes
tedbow’s picture

Assigned: Unassigned » phenaproxima
phenaproxima’s picture

phenaproxima’s picture

Assigned: phenaproxima » Unassigned

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.

kunal.sachdev’s picture

Assigned: Unassigned » kunal.sachdev

tedbow’s picture

Version: 8.x-2.x-dev » 3.0.x-dev

kunal.sachdev’s picture

Assigned: kunal.sachdev » Unassigned
Status: Active » Needs review
wim leers’s picture

Status: Needs review » Needs work
kunal.sachdev’s picture

Status: Needs work » Needs review
wim leers’s picture

Assigned: Unassigned » kunal.sachdev
Status: Needs review » Needs work

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>...]
kunal.sachdev’s picture

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 🎉.% 

And I also checked the scaffold file mappings, it had copied correct scaffold file mappings.

kunal.sachdev’s picture

Assigned: kunal.sachdev » wim leers
Status: Needs work » Needs review
wim leers’s picture

Assigned: wim leers » kunal.sachdev
Status: Needs review » Needs work
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! 😅

kunal.sachdev’s picture

Assigned: kunal.sachdev » wim leers
Status: Needs work » Needs review
wim leers’s picture

Assigned: wim leers » Unassigned
Status: Needs review » Reviewed & tested by the community
kunal.sachdev’s picture

Assigned: Unassigned » kunal.sachdev
Status: Reviewed & tested by the community » Needs work
kunal.sachdev’s picture

Assigned: kunal.sachdev » Unassigned
Status: Needs work » Needs review
wim leers’s picture

Status: Needs review » Reviewed & tested by the community
  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*
    

    ⇒ 🚀

phenaproxima’s picture

phenaproxima’s picture

Status: Reviewed & tested by the community » Fixed

Like! Over and out.

Status: Fixed » Closed (fixed)

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