FrankProjects/UltimateWarfare

View on GitHub
.github/workflows/continuous-integration.yml

Summary

Maintainability
Test Coverage
name: "Continuous Integration"

on: [ push, pull_request ]

env:
  fail-fast: true

jobs:
  phpunit:
    name: "PHPUnit"
    runs-on: "ubuntu-latest"

    strategy:
      matrix:
        php-version:
          - "8.3"

    steps:
      - name: "Checkout"
        uses: "actions/checkout@v2"
        with:
          fetch-depth: 2

      - name: "Install PHP with Xdebug"
        uses: "shivammathur/setup-php@v2"
        with:
          php-version: "${{ matrix.php-version }}"
          coverage: "xdebug"
          ini-values: "zend.assertions=1"

      - name: "Cache dependencies installed with composer"
        uses: "actions/cache@v2"
        with:
          path: "~/.composer/cache"
          key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}"
          restore-keys: "php-${{ matrix.php-version }}-composer-locked-"

      - name: "Install dependencies with composer"
        run: "composer install --no-interaction --prefer-dist"

      - name: "Run PHPUnit"
        run: "php bin/phpunit --coverage-clover=coverage.xml"

      - name: "Upload coverage file"
        uses: "actions/upload-artifact@v2"
        with:
          name: "phpunit-${{ matrix.php-version }}.coverage"
          path: "coverage.xml"

  upload_coverage:
    name: "Upload coverage to Codecov"
    runs-on: "ubuntu-latest"
    needs:
      - "phpunit"

    steps:
      - name: "Checkout"
        uses: "actions/checkout@v2"
        with:
          fetch-depth: 2

      - name: "Download coverage files"
        uses: "actions/download-artifact@v2"
        with:
          path: "reports"

      - name: "Upload to Codecov"
        uses: "codecov/codecov-action@v1"
        with:
          directory: "reports"