Problem/Motivation

In order to prove that our new way of creating a 'composer ready' project is functional, we need to have some build tests to prove that our new way works, and to prevent it from breaking in the future.

Proposed resolution

DrupalCI is the source of truth, so we'll need to figure out
what *kinds* of tests do we run
when to trigger these tests,
how they get executed
what to do if they fail

Remaining tasks

Also should figure out *what to test*.

The initial POC test should be:
1. Run composer install on drupal/legacy-project and drupal/recommended-project
2. ensure that it scaffolded correctly

Following on from there, we should do some minimal functional tests, e.g. use the Build tests to install Drupal and verify that the site can be spun up.

CommentFileSizeAuthor
#4 autoloaderstuff.diff12.06 KBMixologic

Comments

Mixologic created an issue. See original summary.

Mixologic’s picture

diff -rq might be just the thing we need.

Mixologic’s picture

There is a build test that lives in the .travis.yml file located here:

https://github.com/drupal/drupal-project-legacy/blob/8.6.x/.travis.yml

This is kicking off tests that prove that we're recreating the git repository.

It's already revealing some icky things.

Mixologic’s picture

StatusFileSize
new12.06 KB

Here's what it does:

It clones the git repo, runs composer install, then does a composer create project drupal/drupal-project-legacy, and then does a diff -rq On the two subdirectories to see what the differences are.

https://travis-ci.org/drupal/drupal-project-legacy/builds/400730577

I have adjusted which files are put into place in the fork of the scaffold project here:
https://github.com/drupal/drupal-scaffold/blob/8.6.x/src/Handler.php#L361

And I have also forked and added the webflo/drupal-core-strict to https://github.com/drupal/drupal-core-strict/blob/8.6.x/composer.json

But there are a couple things that this shows us that we need to address. LICENSE.txt, README.md, I think we can keep the LICENSE.txt, as that will just get overwritten by packaging anyhow, but will still be there if somebody does use the `composer create project` methodology.

The other things, it seems, are a result of the fact that in drupal core we have some scripts that only ever get ran if you are doing a composer install of 'drupal/drupal'.

Specifically these in the root composer.json of drupal's git repo.

        "pre-autoload-dump": "Drupal\\Core\\Composer\\Composer::preAutoloadDump",
        "post-autoload-dump": "Drupal\\Core\\Composer\\Composer::ensureHtaccess",
        "post-package-install": "Drupal\\Core\\Composer\\Composer::vendorTestCodeCleanup",
        "post-package-update": "Drupal\\Core\\Composer\\Composer::vendorTestCodeCleanup",

So, we'll need a way to run those commands, or, find some other way to do that stuff.

Beyond those, the only other difference I see at this point is in the autoloaders, some of which is how they get named, but other parts appear to be a result of the fact that the components arent making it into the autoloader right now (probably a result of the composer merge plugin nastyness)

I've attached a diff file to show what they look like.

Mixologic’s picture

Mixologic’s picture

Title: Create Build Tests » Create Build Tests For Composer and Drupal
mile23’s picture

Just some thoughts:

It turns out that you can make a packages.json file and specify it for composer create-project. This would let us do an in-place build.

So we'd make a packages.json file for all the packages in the core filesystem. Their repository types would be path. We'd do composer create-project --repository our/packages.json. Then we'd have our criteria for pass/fail.

Moving forward, using only a diff against the tarball isn't going to be enough, but for initial work it might suffice to prove that we got all the files we need.

Eventually we're going to have to run some tests in order to make sure everything is autoloaded and so forth. This might not work so well for composer projects that rearrange the file system a lot, because there are a lot of tests that make assumptions about the file system. For now we should run unit and kernel tests, while we're working on drupal-project-legacy. The goal of legacy is to end up with the same file system.

So:

  • If the canonical subtree split file looks like a packages.json file we could use that. If not, add a tool to build one, either from the subtree split file or just from known locations.
  • Apply patch.
  • create-project in place with packages.json.
  • Diff resulting project against repo.
  • Run some tests.
Mixologic’s picture

Issue summary: View changes

deleted

webflo’s picture

Issue tags: +Composer

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

mile23’s picture

Status: Active » Postponed

This issue and #3031379: Add a new test type to do real update testing have very similar needs from the testing system, but unique special cases.

This issue addresses a testing scenario which we will need in the (hopefully near) future, while #3031379: Add a new test type to do real update testing addresses a current need.

Postponing this issue on that one, since we'll likely develop a new testing framework there which will be used here.

greg.1.anderson’s picture

Just for reference, I made a test script based on #4 / #7 and, over time, have been trying to minimize the amount of file fixup and diff ignore files done to get a passing test.

See the test file, test.sh, which includes comments on the differences.

Mixologic’s picture

Status: Postponed » Active

This issue seems like its available for working on now that #3031379: Add a new test type to do real update testing is in.

greg.1.anderson’s picture

I don't think that we need / should compare the result of composer create-project against the tarball downloads. While that is an interesting question today, in the near future, the download tarballs will themselves be created by composer create-project, making it a somewhat pointless comparison. Even if you go for the double-accounting benefits of testing that the tarball actually did what it was supposed to, it would be a difficult thing to compare them, because the tarball will be the last packaged result, whereas composer create-project will have all of the changes from the latest patch. We want to test the later, not the former (with the exception of update testing).

The current interim DrupalCI test scripts do this:

 info "Installing recommended project composer template"
 composer --working-dir="${SOURCE_DIR}/composer/Template/RecommendedProject" config repositories.scaffold path '../../Plugin/Scaffold'
 composer --working-dir="${SOURCE_DIR}/composer/Template/RecommendedProject" install --no-suggest --no-progress --no-interaction
 info "Recommended project composer template installed successfully."
 assertScaffold "${SOURCE_DIR}/composer/Template/RecommendedProject/web"
 
 info "Installing legacy project composer template"
 composer --working-dir="${SOURCE_DIR}/composer/Template/LegacyProject" config repositories.scaffold path '../../Plugin/Scaffold'
 composer --working-dir="${SOURCE_DIR}/composer/Template/LegacyProject" install --no-suggest --no-progress --no-interaction
 info "Legacy project composer template installed successfully."
 assertScaffold "${SOURCE_DIR}/composer/Template/LegacyProject"

We should make something similar using phpunit tests, perhaps followed up by some tests to perhaps install Drupal, and then start up a web browser and see if it worked.

Mixologic’s picture

Basically, the issue summary is way out of date, as is most of the discussion on this issue.
The title is what I was focusing on. I agree that we dont really need a test to compare the tarballs - that was only an interim goal to give us confidence in our strategies.

Really what this issue should be about is, now that we can have build tests that demonstrate all sorts of scenarios, what ones should we have? The first one that comes to mind is to replace the drupalci.yml tests shell tests we added and convert those into a build test.

Many tests that we'd write would potentially/possibly require external sites to function (packagist/drupal.org) so maybe some of these tests need to be run separately with different expectations (i.e. we normally do not want to 'test the internet' but in the case of testing an upgrade, we just might want that to happen)

greg.1.anderson’s picture

Regarding upgrade tests, I would imagine that we would want to rely on drupal.org to download an old version of Drupal to upgrade from. For the target site, though, we should be upgrading to the site-under test; Packagist, Drush etc. should not be involved.

I think the process would be something like:

  1. Download and untar an old version of Drupal from drupal.org
  2. Run site-install
  3. Copy the site-under-test code over the unpackaged site
  4. Run updatedb
  5. Profit

The last step is the tricky one, as we'll need to detect whether anything went wrong with the upgrade. To do a really thorough upgrade test, we'd want to enable all of the core modules and add date to them and then check to see if they still worked. An MVP upgrade test could just check to see if the updates all ran without error, and the home page can still be fetched without a WSOD.

I think this issue should just be focused on composer create-project and the installation of a site. We should make a follow-up for the upgrade test.

Mixologic’s picture

The thing we actually want to test isn't whether or not the upgrade system works, we want to prove that we can upgrade using composer, using a tarball, and using drush etc.

Since we can create on-disk 'repositories' and use that instead of packagist and packages.drupal.org, we could have a test that uses all the same composer commands, but gathers its information from the local filesystem with the SUT.

But yes, this issue is 'what can we prove, composer initiative wise, with these new build tests'. Upgrades and the like might be out of scope. Although, an upgrade from 8.7.* to 8.8.* might be valuable to prove that the repository maneouvering we have done didnt mess something up. I.e. if somebody *did* have drupal/drupal or a git clone of drupal that they started from in 8.7 -> can they upgrade? are there issues?

greg.1.anderson’s picture

I guess another question is, how many of those tests should run on every patch, and how many should run less often?

If we wanted to install Drush 8.x as a fixture, we could configure it to get update information from somewhere other than drupal.org. We might be able to get pm-update to think that there was a new release available from the current SUT. We'd probably have to package the SUT up as a tarball and put it on disk somewhere, and make release XML to point at it. A little complicated, perhaps, but possible.

But I guess we should discuss this on our follow-on issue.

Mixologic’s picture

Ideally, again, we have another build target that is different than "patch submission" or "commit push" -> probably more like daily tests. These tests are going to be slow by default, so we're *not* necessarily wanting them on every patch. These are more like end to end integration tests and we just need to know if we 'break the build' or not.

We'll be able to run them in a patch context, of course, when adding new ones etc, but ideally they only run on a much more infrequent basis.

heddn’s picture

As a reminder, when we add real tests, we'll want to update https://git.drupalcode.org/project/drupal/blob/8.8.x/core/tests/Drupal/T... to search for Build tests.

heddn’s picture

Mixologic’s picture

This one more of a composer initiative meta to address "what should we test now that we can", with the explicit acknowledgement that we definitely need to convert the one shell script test that already exists.

mile23’s picture

greg.1.anderson’s picture

Issue summary: View changes
Issue tags: -Composer +Composer initiative

Fix issue tags and update issue summary

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

mile23’s picture

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.