Problem/Motivation

I've just added the gitlab-ci pipeline to the project. Tests run, but there are various fails in phpcs, eslint and test results.

Steps to reproduce

run the pipeline - see https://git.drupalcode.org/project/lupus_decoupled/-/pipelines/35154

Proposed resolution

Address test results.

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

fago created an issue. See original summary.

roderik’s picture

Status: Active » Postponed

I'm afraid this is now a duplicate of #3402425: Fix PHPCS and maybe other errors which I opened to fix "some errors I am seeing" -- not realizing (in the beginning) that it was because of the recently added .gitlab-ci.yml.

As far as I know, all issues are fixed in #3402425: Fix PHPCS and maybe other errors after custom_elements gets a new release. Let's see.

roderik’s picture

Status: Postponed » Active

PHPCS / eslint / PHPStan (level 3) are passing now.

This issue is now waiting to see if PHPUnit complaining about custom_elements is going to be resolved by it... or otherwise this issue will have to make sure to pull its -dev release in.

roderik’s picture

Status: Active » Needs work

With the other issue merged and dependent modules having their config schema added:

PHPUnit now shows one remaining failure in at least two issues' jobs, e.g. https://git.drupalcode.org/issue/lupus_decoupled-3320802/-/jobs/379582

1) Drupal\Tests\lupus_decoupled\Functional\LupusDecoupledApiResponseTest::testExistingPageApiResponse
Behat\Mink\Exception\ExpectationException: Current response status code is 404, but 200 expected.
/builds/issue/lupus_decoupled-3320802/vendor/behat/mink/src/WebAssert.php:794
/builds/issue/lupus_decoupled-3320802/vendor/behat/mink/src/WebAssert.php:130
/builds/issue/lupus_decoupled-3320802/tests/src/Functional/LupusDecoupledApiResponseTest.php:76
/builds/issue/lupus_decoupled-3320802/vendor/phpunit/phpunit/src/Framework/TestResult.php:728
ERRORS!
Tests: 3, Assertions: 12, Errors: 1.
HTML output was generated
http://localhost/web/sites/simpletest/browser_output/Drupal_Tests_lupus_decoupled_Functional_LupusDecoupledApiResponseTest-1-17377110.html
http://localhost/web/sites/simpletest/browser_output/Drupal_Tests_lupus_decoupled_Functional_LupusDecoupledApiResponseTest-2-68193535.html
http://localhost/web/sites/simpletest/browser_output/Drupal_Tests_lupus_decoupled_Functional_LupusDecoupledApiResponseTest-3-36512604.html

So that looks like it is present in the main branch / still needs to be investigated and fixed in this issue. Apparently /ce-api/node/1 is unreachable (though /node/1 is reachable).

arthur_lorenz made their first commit to this issue’s fork.

arthur_lorenz’s picture

After some debugging I'm confident that I have located the issue: The BackendApiRequest middleware is checking for the /ce-api prefix in the server's REQUEST_URI. Since the base url in gitlab ci is http://localhost/web, the actual uri that is checked at that point is /web/ce-api/node/1 which the middleware does not recognize as a valid ce api request and therefore passes the request through without altering it.

I did not have time fix it yet though.

arthur_lorenz’s picture

Status: Needs work » Needs review

I fixed the middleware to work with path prefixes.

roderik’s picture

Status: Needs review » Needs work

Oh joy, website install prefixes to shake out bugs!

One comment.

arthur_lorenz’s picture

Status: Needs work » Needs review

Thx, good catch, I improved the string replacement.

roderik’s picture

Status: Needs review » Reviewed & tested by the community

Checked the string replacement thing. (Probably the first time I've consciously seen substr_replace(). Neat.)

Apart from that: I feel confident RTBC'ing because the change is restricted to the internals of this one middleware, and the changes feel predictable.
(Also, it's not trivial to make a test for the feedback I had earlier because the standard prefix is /ce-api.)

fago’s picture

Status: Reviewed & tested by the community » Needs work

* The resulting pipeline does still not pass. Our fix is not fix the pipeline really, but installation with base-paths. Let's open an issue that clearly documents the fix we are doing, fix it there + keep this here open until we can really make it done - with green tests
* Changes seem good, but this is very foundational, so we need to be 100% sure to not cause regressions here. That said, I think this misses test-coverage. Could we add a small unit-test here where we mock $request object, so we could fire it up with all kind of URI combinations and verify it's all correct? (--> in the other issue then)

arthur_lorenz’s picture

The resulting pipeline does still not pass.

I can not confirm this. The pipeline is passing

Otherwise you are right, this should rather be handled and documented in a separate issue.

fago’s picture

Status: Needs work » Fixed

with the fix from that issue, the pipeline passed now! https://git.drupalcode.org/project/lupus_decoupled/-/pipelines/74214

Status: Fixed » Closed (fixed)

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