Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork405
Can't connect to mysql#1004
-
Good night!
Nothing seems to work. Am I just stupid? name:CIon:pull_request:branches:[ "main", "develop" ]jobs:laravel-tests:runs-on:ubuntu-22.04services:mysql:image:mysql:8.0env:MYSQL_ROOT_PASSWORD:rootMYSQL_DATABASE:testports: -3306/tcp# -> here i also tried using 3306:3306options:--health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3steps: -uses:actions/checkout@v4 -name:Setup PHPuses:shivammathur/setup-php@v2with:php-version:'8.2'extensions:bcmatch, curl, dom, fileinfo, gd, imagick, intl, mbstring, openssl, pdo_mysql, soap, xml, zip# -> here I also tried a set of combination, who knows what might work that this stagecoverage:none -name:Setup Node.js 22uses:actions/setup-node@v5.0.0with:node-version:'22.x' -name:Setup FFmpeguses:federicocarboni/setup-ffmpeg@v3.1# I was having problems with other workflows, or with this one, I don't really remember anymore at this point -name:Remove possible conflicting env filesrun:rm -f .env.example .env.testing .env.testing.example -name:Copy .envrun:cp .env.ci .env# I also tried removing this and the Cache composer dependencies step -name:Get composer cache directoryid:composer-cacherun:echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT -name:Cache composer dependenciesuses:actions/cache@v3with:path:${{ steps.composer-cache.outputs.dir }}# Use composer.json for key, if composer.lock is not committed.# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}key:${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}restore-keys:${{ runner.os }}-composer- -name:Install Composer Dependenciesrun:composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist -name:Install python and piprun:sudo apt-get update --allow-releaseinfo-change && sudo apt-get install -y python3 python3-pip -name:Install pdfmergerun:pip install pdfmerge -name:Install headless chrome required libsrun:| sudo apt-get install -y \ libasound2 \ libatk-bridge2.0-0 \ libatk1.0-0 \ libatspi2.0-0 \ libc6 \ libcairo2 \ libcups2 \ libdbus-1-3 \ libdrm2 \ libexpat1 \ libgbm1 \ libglib2.0-0 \ libnspr4 \ libnss3 \ libpango-1.0-0 \ libpangocairo-1.0-0 \ libstdc++6 \ libudev1 \ libuuid1 \ libx11-6 \ libx11-xcb1 \ libxcb-dri3-0 \ libxcb1 \ libxcomposite1 \ libxcursor1 \ libxdamage1 \ libxext6 \ libxfixes3 \ libxi6 \ libxkbcommon0 \ libxrandr2 \ libxrender1 \ libxshmfence1 \ libxss1 \ libxtst6 -name:Install Node dependenciesrun:npm ci -name:Generate keyrun:php artisan key:generate -name:Directory Permissionsrun:chmod -R 777 storage bootstrap/cache -name:Clear Configrun:php artisan config:clear# This step is new, but I just get the errors here now, nothing changes -name:Run Migrationrun:php artisan migrate -v -name:Execute Larastanrun:vendor/bin/phpstan analyse -name:Execute Laravel Pintrun:vendor/bin/pint --test -name:Execute tests via Pestrun:php artisan test --parallel My APP_NAME=LaravelAPP_ENV=testingAPP_KEY=APP_DEBUG=trueAPP_TIMEZONE=America/Sao_PauloAPP_URL=http://localhostAPP_LOCALE=pt_BRAPP_FALLBACK_LOCALE=enAPP_FAKER_LOCALE=pt_BRAPP_MAINTENANCE_DRIVER=file# APP_MAINTENANCE_STORE=databaseBCRYPT_ROUNDS=12LOG_CHANNEL=stackLOG_STACK=singleLOG_DEPRECATIONS_CHANNEL=nullLOG_LEVEL=debugDB_CONNECTION=mysqlDB_HOST=127.0.0.1# this was the last attemptDB_PORT=3306DB_DATABASE=testDB_USERNAME=rootDB_PASSWORD=rootSESSION_DRIVER=arraySESSION_LIFETIME=120SESSION_ENCRYPT=falseSESSION_PATH=/SESSION_DOMAIN=nullBROADCAST_CONNECTION=logFILESYSTEM_DISK=localQUEUE_CONNECTION=databaseCACHE_STORE=arrayCACHE_PREFIX=MEMCACHED_HOST=127.0.0.1REDIS_CLIENT=phpredisREDIS_HOST=127.0.0.1REDIS_PASSWORD=nullREDIS_PORT=6379MAIL_MAILER=smtpMAIL_HOST=127.0.0.1MAIL_PORT=1025MAIL_USERNAME=nullMAIL_PASSWORD=nullMAIL_ENCRYPTION=nullMAIL_FROM_ADDRESS="xyz@domain.com"MAIL_FROM_NAME="${APP_NAME}"SMS_ZENVIA_URL=SMS_ZENVIA_TOKEN=SMS_ZENVIA_SENDER_ID=AWS_ACCESS_KEY_ID=AWS_SECRET_ACCESS_KEY=AWS_DEFAULT_REGION=us-east-1AWS_BUCKET=AWS_USE_PATH_STYLE_ENDPOINT=falseVITE_APP_NAME="${APP_NAME}" |
BetaWas this translation helpful?Give feedback.
All reactions
First make sure mysql service starts correctly in the second step (Initialize containers)
In your envDB_HOST=127.0.0.1 is correct.
But, when you specify port on a service like this
ports: -3306/tcp
it maps port 3306 on the service container to a random free port on the host container. Then you cannot hard code a DB_PORT in your env. You have to access it using ${{ job.services.mysql.ports['3306'] }} in this case.
Please try changing these steps
-name:Run Migrationrun:php artisan migrate -venv:DB_PORT:${{ job.services.mysql.ports['3306'] }}
and
-name:Execute tests via Pestrun:php artisan test --parallelenv:DB_PORT:${{ job.services.mysql.por…
Replies: 1 comment 2 replies
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
First make sure mysql service starts correctly in the second step (Initialize containers) In your env But, when you specify port on a service like this ports: -3306/tcp it maps port 3306 on the service container to a random free port on the host container. Then you cannot hard code a DB_PORT in your env. You have to access it using ${{ job.services.mysql.ports['3306'] }} in this case. Please try changing these steps -name:Run Migrationrun:php artisan migrate -venv:DB_PORT:${{ job.services.mysql.ports['3306'] }} and -name:Execute tests via Pestrun:php artisan test --parallelenv:DB_PORT:${{ job.services.mysql.ports['3306'] }} On a side note, there is a typo in your workflow |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
Thanks for the quick response! The changes in the Run Migration and Execute tests via Pest worked! Thanks again. |
BetaWas this translation helpful?Give feedback.
All reactions
-
Yes that would also work. |
BetaWas this translation helpful?Give feedback.
All reactions
❤️ 1