summaryrefslogtreecommitdiffstats
path: root/.github/workflows/phpunit.yaml
blob: f2a0bb4b0ac63c744e329822492fe1f2128d7c14 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
name: Testing php7-mysql-shim
on: [pull_request]
env:
  fail-fast: true
jobs:
  phpunit:
    name: Unit Tests (PHP ${{ matrix.php-versions }})
    runs-on: ubuntu-latest
    services:
      mysql:
        image: mysql:5.7
        env:
          MYSQL_ALLOW_EMPTY_PASSWORD: false
          MYSQL_ROOT_PASSWORD: password
          MYSQL_DATABASE: testing
        ports:
          - 3306/tcp
        options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
    strategy:
      fail-fast: false
      matrix:
        php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4']
    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - name: Setup PHP, with composer and extensions
        uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
        with:
          php-version: ${{ matrix.php-versions }}
          extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, mysql
          coverage: xdebug #optional
      - name: Start mysql service
        run: sudo /etc/init.d/mysql start
      - name: Install Composer dependencies
        run: |
           composer update --no-interaction --prefer-source
      - name: Run Tests
        run: composer run test -- --coverage-text
        env:
          MYSQL_HOST: 127.0.0.1:${{ job.services.mysql.ports['3306'] }}
          MYSQL_USERNAME: root
          MYSQL_PASSWORD: password
      - name: Get Code Coverage
        run: php tests/coverage.php >> $GITHUB_ENV
        if: matrix.php-versions == '7.4'
      - name: Upload Code Coverage
        uses: schneegans/dynamic-badges-action@v1.0.0
        with:
          auth: ${{ secrets.GIST_TOKEN }}
          gistID: ee79527e0098afea147bffc33bf710d3
          filename: coverage.json
          label: Code Coverage
          message: ${{ env.COVERAGE }}
          color: green
        if: matrix.php-versions == '7.4'
        continue-on-error: true # if is fork