|
| 1 | +# GitHub Action for Phalcon with MySQL |
| 2 | +## Notes |
| 3 | +## Make sure you have .env.example or .env file in your project |
| 4 | +## and you have loaded Dotenv (https://github.com/vlucas/phpdotenv) |
| 5 | +name: Testing Phalcon with MySQL |
| 6 | +on: [push, pull_request] |
| 7 | +jobs: |
| 8 | + phalcon: |
| 9 | + name: Phalcon (PHP ${{ matrix.php-versions }}) |
| 10 | + runs-on: ubuntu-latest |
| 11 | + env: |
| 12 | + DB_ADAPTER: mysql |
| 13 | + DB_HOST: 127.0.0.1 |
| 14 | + DB_NAME: phalcon |
| 15 | + DB_USERNAME: root |
| 16 | + DB_PASSWORD: password |
| 17 | + services: |
| 18 | + mysql: |
| 19 | + image: mysql:5.7 |
| 20 | + env: |
| 21 | + MYSQL_ALLOW_EMPTY_PASSWORD: false |
| 22 | + MYSQL_ROOT_PASSWORD: password |
| 23 | + MYSQL_DATABASE: phalcon |
| 24 | + ports: |
| 25 | + - 3306 |
| 26 | + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 |
| 27 | + strategy: |
| 28 | + fail-fast: false |
| 29 | + matrix: |
| 30 | + php-versions: ['7.2', '7.3', '7.4'] |
| 31 | + # For phalcon 3.x, use |
| 32 | + # php-versions: ['7.0', '7.1', '7.2', '7.3'] |
| 33 | + steps: |
| 34 | + - name: Checkout |
| 35 | + uses: actions/checkout@v1 |
| 36 | + - name: Setup PHP, with composer and extensions |
| 37 | + uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php |
| 38 | + with: |
| 39 | + php-version: ${{ matrix.php-versions }} |
| 40 | + extensions: mbstring, dom, zip, phalcon4, mysql #use phalcon3 for the phalcon 3.x. |
| 41 | + coverage: xdebug #optional |
| 42 | + - name: Get composer cache directory |
| 43 | + id: composer-cache |
| 44 | + run: echo "::set-output name=dir::$(composer config cache-files-dir)" |
| 45 | + - name: Cache composer dependencies |
| 46 | + uses: actions/cache@v1 |
| 47 | + with: |
| 48 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 49 | + # Use composer.json for key, if composer.lock is not committed. |
| 50 | + # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} |
| 51 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} |
| 52 | + restore-keys: ${{ runner.os }}-composer- |
| 53 | + - name: Install Composer dependencies |
| 54 | + run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader --ignore-platform-reqs |
| 55 | + - name: Prepare the application |
| 56 | + run: php -r "file_exists('.env') || copy('.env.example', '.env');" |
| 57 | + - name: Run Tests |
| 58 | + run: | |
| 59 | + vendor/bin/codecept build |
| 60 | + vendor/bin/codecept run unit |
| 61 | + env: |
| 62 | + DB_PORT: ${{ job.services.mysql.ports['3306'] }} |
0 commit comments