bashy
bashy
11 months ago (1,086,240 XP)

@Mythos33 What does it say for the composer install command process or does it not show?

Mistral

@Mythos33 I have got the same error. Maybe you have resolved this problem?

gwawr

This is because the ./vendor folder created during the before_script phase isn't carried through into the testing builds. I've yet to reach a satisfactory answer for this - but its currently looking like you need to do a composer install for each of the different build instances.

https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/issues/336

gwawr

It's actually something else... the [[ ! -e /.dockerenv ]] && [[ ! -e /.dockerinit ]] && exit 0 line is causing the script to drop out early

gwawr

Issue is that /.dockerinit was removed in v1.11 so it always fails the test

http://stackoverflow.com/questions/23513045/how-to-check-if-a-process-is-running-inside-docker-container

https://github.com/docker/docker/pull/19490

Replacing that line with

[[ ! -e /.dockerenv ]] && exit 0

works just fine. Running php composer.phar install --no-plugins --no-scripts --dev then runs properly in the before_script section for every test build.

Mythos33

I'm sorry, but I totally forgot about this thread due to missing email notifications. ;-)

@gwawr 's solution works for me, thanks!

gandra404

I have just tried @Refringe setup and Gitlab build fails with similar error as @Mythos33. I have copied files from https://github.com/didikz/laravel-gitlab-ci into my project and push it into GitLab and build fails with error:

Running with gitlab-ci-multi-runner 1.9.0 (82714ae)
Using Docker executor with image php:5.6 ...
Pulling docker image mysql:5.6 ...
Starting service mysql:5.6 ...
Waiting for services to be up and running...
Pulling docker image php:5.6 ...
Running on runner-e11ae361-project-2277718-concurrent-0 via runner-e11ae361-machine-1483904340-0654037a-digital-ocean-4gb...
Cloning repository...
Cloning into '/builds/gandra404/ticketbeast'...
Checking out bacd084d as master...
$ bash .gitlab-ci.sh
$ php vendor/bin/phpunit --colors
Could not open input file: vendor/bin/phpunit
ERROR: Build failed: exit code 1

Here is repo url of the failing project: https://gitlab.com/gandra404/ticketbeast

and here are failiong builds: https://gitlab.com/gandra404/ticketbeast/pipelines/5717598

In case I made some new changes this is relevant commit: https://gitlab.com/gandra404/ticketbeast/commit/bacd084defd3a718b185c8de89ba7f9cabc1fa9b

@Mythos33, can you post your solution? I didn't get what have to change in order to work.

gandra404

Finally I manage to run sucesfully tests on GitLab. Here is the project: https://gitlab.com/gandra404/ticketbeast

This article helped me a lot: https://woohuiren.me/blog/how-to-laravel-testing-on-gitlab-ci-with-docker/

I have code on GitLab. Runner installed on my host(probably would work only with shared runner?) with docker as executor.

I have copied this files in my root: https://github.com/GIANTCRAB/gitlabby-dockerish-laravel

The only error I had at first try was "Unable to prepare route [api/user] for serialization. Uses Closure."(https://gitlab.com/gandra404/ticketbeast/builds/8359637) but seems that is known error: https://laracasts.com/discuss/channels/laravel/why-unable-to-prepare-route-for-serialization-uses-closure

So, at the moment I have commented line php artisan route:cache andbuild paased ok!

scuttlebyte

These scripts are wonderful, thank you all for sharing your knowledge.

I have everything up and running but being new to the CI and docker/container worlds, I feel compelled to ask if theres any way to expedite the build process by pre-compiling php and extensions and creating a container--something along those lines.

Or is there a benefit to using the official images I'm missing out on?

If it helps, I used forge to provision my production server, so if there's a forge-flavored container I'd be safe running my ci-against that would be swell.

bashy
bashy
6 months ago (1,086,240 XP)

@scuttlebyte This may help: https://github.com/WithSocial/docker-build If you look at the Dockerfile, it's pre-compiled like you wanted.

Giolf

Hi all,

While i was reading this topic

i was thinking if it's possibile to have this kind of test functionality into the docker container:

 public function testBasicExample()
    {
        $this->visit('/')
             ->see('Laravel 5')
             ->dontSee('Rails');
    }

If not what i would need ? maybe a webserver that runs into the docker container ?

thank you

nanosolutions

@Mythos33 had same issue but it was random, endedup deviding the stages into build (composer) and then tests and that seem to work for me.

https://gist.github.com/cerw/d46c33297f1fc0f4f778b4e9d2ec4329

Please sign in or create an account to participate in this conversation.