Closed alexkuc closed 1 year ago
@tn3rb I'll need your input here. We discussed 2 modes of operation - testing using docker and testing on MENW staging. I believe, it would be best to separate it into 2 separate processes (e2e codebase can be the same though with slight variations to support this).
We discussed the following E2E flow:
work branch -> PR -> unit tests -> dev branch -> E2E tests -> master branch
However, I am thinking now, do we really need a dev
branch? Why not run E2E as a part of PR check? We initially assumed that E2E will take several hours however:
Don't forget to build assets and make sure barista plugin is activated too!
We discussed 2 modes of operation - testing using docker and testing on MENW staging.
ok so to be clear, the platform used for testing is inconsequential to me. As far as i'm concerned that is a technical decision best left to whoever is engineering the testing system (ie: YOU! 😆). The final decision should be whatever works best based on whatever criteria ends up being most important, which i'm not even sure of atm. SO everything is subject to change... until it's not! 😆
I believe, it would be best to separate it into 2 separate processes
sure, imho, this is the kind of technical decision best left to the engineer(s) doing the work as opposed to the person managing said engineer(s).
Why not run E2E as a part of PR check?
my only concern is the length of time they will take to run. Even the current PHP unit tests take too long to run imho (most of the PHP unit tests are technically integration tests due to the way that the WordPress testing framework is set up) and i may be breaking these up in the future so that only "pure" unit tests run during PR pushes. Longer running integration tests would then run later on in the CI/CD pipeline similar to what i am envisioning for e2e tests.
...if E2E fails, we shouldn't merge PR
ya this is a really important point... like HUGELY important (is "hugely" a word? 🤔) and will most certainly effect the final configuration of our CI/CD pipeline. What might be the best compromise would be to move integration and e2e tests, as well as PR merging, into a workflow that is manually triggered via a PR comment. So after all code reviews and modifications are completed, the PR author would enter a comment like: /merge
or merge-me
or whatever, and that would trigger a workflow to run which would do the following:
DEV
i think i can set up branch protection rules that would restrict PR merging to only the EE Bot user account, who would be responsible for performing the merge. This would satisfy your concerns (and mine) with having PRs that fail tests progressing along the CI/CD pipeline further than they should be allowed.
I think your last comment perfectly covers everything for now. I'll proceed with the implementation as you have mentioned.
Evaluation criteria
git pull
DDEV
Lando
Setting up repository, e.g. downloading dependencies, installing them, compiling assets, etc. should not be part of MakeEnv.ts
otherwise that will lead to tight coupling of the code and possible fragility of the implementation.
Edit: In other words, DDEV scaffolder should not care about environment, it should be ready. It should just execute the necessary DDEV commands to achieve the desired result in a repeatable and scalable fashion.
Requires dependencies:
In this (barista) repository, unit tests are run only partially as a part of CI checks. To trigger all unit tests, we would need to include test-all
in the commit message:
Perhaps, a similar strategy could be employed for E2E where during PR checks only a subset of E2E suites will be run. And once PR is approved, the entire suite of E2E tests would run.
Perhaps, for e2e that's not doable to due to Jest tests (unit tests) being tightly coupled to actual source code where code would be able to infer --changedSince
for appropriate files include source. Whereas E2E will be running against https://<website>
and programmatic inferral would be way more difficult.
My idea was to use tags, however, it will require a programmatic way to determine which tags to run during CI checks
I will proceed to implement this as it seems like the best trade-off between time, complexity and performance:
What might be the best compromise would be to move integration and e2e tests, as well as PR merging, into a workflow that is manually triggered via a PR comment. So after all code reviews and modifications are completed, the PR author would enter a comment like: /merge or merge-me or whatever, and that would trigger a workflow...
i think i can set up branch protection rules that would restrict PR merging to only the EE Bot user account, who would be responsible for performing the merge.
@tn3rb this looks totally doable using branch protection rules (requires either GitHub Team or GitHub Free organization)
Docker-related caching is currently problematic so I will keep it as it is (i.e. no cache) for the time being. Out-of-the-box, GitHub Actions do not cache official Docker images. Using workaround based on docker save
and docker load
leads to substantially longer times:
Type | Time |
---|---|
cache restore | ~4min |
docker pull | ~2min |
Keep in mind that the task for saving result of docker save
to cache took nearly ~10min.
In terms of caching installation of tools like mkcert or DDEV, the general consensus is to use a pre-baked Docker image that already includes those installed pre-installed and ready-for-use out-of-the-box. Unfortunately, in our case, it leads to Docker-in-Docker scenario, since DDEV scaffolds WordPress environments using Docker as well. The other possibility is to use a self-hosted runner where these tools would be pre-installed. Currently, running a single test from environment.spec.ts:6
leads to results between 3 and 5 minutes. If we reduce "startup" time (time taken to prepare environment) to an approximate 1 minute, this improvement would look negligible if the overall time to run end-to-end tests would be close to 1 hour. If we consider the current time to prepare environment to be approximately 4 minutes, and reducing it to approximately 1 minute, we would save 3 minute or 5% if the overall time to run the end-to-end tests would be close to 1 hour.
References:
How to get branch name on event issue_comment
: https://github.com/actions/checkout/issues/331
Fixed by #1254
Update file
e2e-tests.yml
to use Playwright runner instead of Playwright in library modeReferences