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.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | autoloaderstuff.diff | 12.06 KB | Mixologic |
Comments
Comment #2
Mixologicdiff -rqmight be just the thing we need.Comment #3
MixologicThere 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.
Comment #4
MixologicHere'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 -rqOn 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.
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.
Comment #5
MixologicComment #6
MixologicComment #7
mile23Just some thoughts:
It turns out that you can make a
packages.jsonfile and specify it forcomposer create-project. This would let us do an in-place build.So we'd make a
packages.jsonfile for all the packages in the core filesystem. Theirrepositorytypes would bepath. We'd docomposer 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:
Comment #8
Mixologicdeleted
Comment #9
webflo commentedComment #12
mile23This 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.
Comment #13
greg.1.anderson commentedJust 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.
Comment #14
MixologicThis issue seems like its available for working on now that #3031379: Add a new test type to do real update testing is in.
Comment #15
greg.1.anderson commentedI don't think that we need / should compare the result of
composer create-projectagainst the tarball downloads. While that is an interesting question today, in the near future, the download tarballs will themselves be created bycomposer 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, whereascomposer create-projectwill 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:
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.
Comment #16
MixologicBasically, 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)
Comment #17
greg.1.anderson commentedRegarding 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:
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-projectand the installation of a site. We should make a follow-up for the upgrade test.Comment #18
MixologicThe 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?
Comment #19
greg.1.anderson commentedI 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.
Comment #20
MixologicIdeally, 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.
Comment #21
heddnAs 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.
Comment #22
heddnThis seems a duplicate of #3082230: [meta] Convert some tests to Build tests.
Comment #23
MixologicThis 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.
Comment #24
mile23New child issue: #3086644: LegacyProject composer templates wrongly reference 8.x + fix test coverage
Comment #25
greg.1.anderson commentedFix issue tags and update issue summary
Comment #27
mile23New child: #3096044: Ensure quickstart feature works with drupal/core-recommended