wait for db container to be ready/reachable #12
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Framework Package Tests | |
| on: | |
| push: | |
| branches: [main, "feature/**"] | |
| pull_request: | |
| jobs: | |
| core-tests: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| env: | |
| FROXLOR_APP_DIR: ${{ github.workspace }}/froxlor | |
| FROXLOR_FRAMEWORK_DIR: ${{ github.workspace }}/framework | |
| steps: | |
| - name: Checkout framework | |
| uses: actions/checkout@v7 | |
| with: | |
| path: framework | |
| - name: Checkout froxlor app | |
| uses: actions/checkout@v7 | |
| with: | |
| repository: froxlor/froxlor | |
| path: froxlor | |
| - name: Verify CI paths | |
| run: | | |
| pwd | |
| test -d "$FROXLOR_APP_DIR" | |
| test -d "$FROXLOR_FRAMEWORK_DIR" | |
| - name: Use local framework checkout | |
| working-directory: froxlor | |
| run: | | |
| php -r '$file = "composer.json"; $json = json_decode(file_get_contents($file), true, 512, JSON_THROW_ON_ERROR); $json["repositories"] = [["name" => "framework", "type" => "path", "url" => "../framework", "options" => ["reference" => "config", "symlink" => true]]]; file_put_contents($file, json_encode($json, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . PHP_EOL);' | |
| - name: Install PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: "8.5" | |
| coverage: none | |
| tools: composer:v2 | |
| - name: Cache composer downloads | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.composer/cache/files | |
| key: composer-${{ runner.os }}-${{ hashFiles('froxlor/composer.json', 'framework/composer.json') }} | |
| restore-keys: composer-${{ runner.os }}- | |
| - name: Install dependencies | |
| working-directory: froxlor | |
| run: | | |
| composer update --no-interaction --prefer-dist --no-progress | |
| - name: Start docker stack | |
| working-directory: framework | |
| run: docker compose -f docker-compose.ci.yml up -d | |
| - name: Prepare Laravel env | |
| working-directory: froxlor | |
| run: | | |
| cp .env.example .env | |
| { | |
| echo "APP_ENV=testing" | |
| echo "APP_KEY=base64:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" | |
| echo "APP_DEBUG=true" | |
| echo "APP_URL=http://localhost" | |
| echo "DB_CONNECTION=mysql" | |
| echo "DB_HOST=db" | |
| echo "DB_PORT=3306" | |
| echo "DB_DATABASE=froxlor" | |
| echo "DB_USERNAME=froxlor" | |
| echo "DB_PASSWORD=froxlor" | |
| echo "CACHE_STORE=array" | |
| echo "QUEUE_CONNECTION=sync" | |
| echo "SESSION_DRIVER=array" | |
| echo "MAIL_MAILER=array" | |
| echo "DEV_NODE=local" | |
| echo "DEV_EMAIL=admin@froxlor.test" | |
| echo "DEV_FIRST_NAME=Admin" | |
| echo "DEV_LAST_NAME=User" | |
| echo "DEV_PASSWORD=secret-password" | |
| echo "DEV_SEED_DEVELOPMENT_DATA=true" | |
| } >> .env | |
| - name: Wait for database | |
| working-directory: framework | |
| run: | | |
| docker compose -f docker-compose.ci.yml exec -T db mariadb-admin ping -h localhost -uroot -proot --wait=60 | |
| - name: Fresh database with seeders | |
| working-directory: framework | |
| run: docker compose -f docker-compose.ci.yml exec -T froxlor php /var/www/html/froxlor/artisan migrate:fresh --seed --force | |
| - name: Run tests | |
| working-directory: framework | |
| run: docker compose -f docker-compose.ci.yml exec -T froxlor php /var/www/html/froxlor/artisan test /var/www/html/framework/packages/core/tests | |
| - name: Docker logs on failure | |
| working-directory: framework | |
| if: failure() | |
| run: docker compose -f docker-compose.ci.yml logs --no-color | |
| - name: Stop docker stack | |
| working-directory: framework | |
| if: always() | |
| run: docker compose -f docker-compose.ci.yml down -v --remove-orphans |