When using PostgreSQL in Gitlab CI, executing ./vendor/bin/testbench migrate will encounter the following error message
In Connection.php line 829:
SQLSTATE[08006] [7] invalid integer value "tcp://172.17.0.3:5432" for conne
ction option "port" (Connection: pgsql, SQL: select * from information_sche
ma.tables where table_catalog = myDatabase and table_schema = public and ta
ble_name = migrations and table_type = 'BASE TABLE')
In Connector.php line 65:
SQLSTATE[08006] [7] invalid integer value "tcp://172.17.0.3:5432" for conne
ction option "port"
But using Mysql will not
The following is the result of executing ./vendor/bin/testbench config:show database
3. Push to Gitlab, then wait CI
# Possible temporary solution:
At present, I unset the `POSTGRES_PORT` environment variable at the very beginning of CI, but I think maybe testbench can add a flag in `testbench.yaml` to prevent testbench from executing the actions in `HandlesDatabaseConnections.php`
Description:
When using PostgreSQL in Gitlab CI, executing
./vendor/bin/testbench migrate
will encounter the following error messageBut using Mysql will not
The following is the result of executing
./vendor/bin/testbench config:show database
I think the reason is that in Gitlab CI,
services
(i.e. PostgreSQL) is connected using docker link.And according to the way Docker operates, the environment variable:
POSTGRES_PORT
will be created, and the value istcp://172.17.0.3:5432
Then testbench will use this environment variable in HandlesDatabaseConnections.php and set it in laravel config
However, PostgreSQL does not accept this content, so it prints an error
Reference 1: https://stackoverflow.com/questions/42976181/postgresql-on-aws-ecs-psycopg2-operationalerror-invalid-port-number-5432 Reference 2: https://docs.gitlab.com/ee/ci/services/#how-services-are-linked-to-the-job Reference 3: https://docs.docker.com/network/links/#environment-variables
Steps To Reproduce:
I create demo project: https://gitlab.com/danny60072/testbench-postgres-port-test
The fail job: https://gitlab.com/danny60072/testbench-postgres-port-test/-/jobs/6284037647
Steps To Reproduce:
.gitlab-ci.yml
filetest-mysql8.0: stage: test image: danny60072/gitlab-ci-pipeline-php:8.1-node18 variables:
laravel
services:
test-postgres:15: stage: test image: danny60072/gitlab-ci-pipeline-php:8.1-node18 variables:
laravel
services: