<commit_before>name: Integration Tests

on:
  - pull_request
  - push
  - workflow_dispatch

jobs:
  integration-tests:
    name: Integration Tests
    runs-on: ubuntu-latest
    if: github.repository == 'kreait/firebase-php'

    env:
      php-version: '7.4'
      extensions: ctype, dom, grpc, json, mbstring, openssl, xml, zip, zlib
      key: cache-integration-v3 # can be any string, change to clear the extension cache.

    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Setup cache environment
        id: cache-env
        uses: shivammathur/cache-extensions@v1
        with:
          php-version: ${{ env.php-version }}
          extensions: ${{ env.extensions }}
          key: ${{ env.key }}

      - name: Cache extensions
        uses: actions/cache@v1
        with:
          path: ${{ steps.cache-env.outputs.dir }}
          key: ${{ steps.cache-env.outputs.key }}
          restore-keys: ${{ steps.cache-env.outputs.key }}

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ env.php-version }}
          extensions: ${{ env.extensions }}
          tools: composer, pecl
          coverage: xdebug

      - name: Setup problem matchers for PHP
        run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"

      - name: Get Composer Cache Directory
        id: composer-cache
        run: echo "::set-output name=dir::$(composer config cache-files-dir)"

      - name: Cache dependencies
        uses: actions/cache@v1
        with:
          path: ${{ steps.composer-cache.outputs.dir }}
          key: ${{ runner.os }}-${{ matrix.php }}-v6-composer-${{ hashFiles('**/composer.json') }}
          restore-keys: ${{ runner.os }}-${{ matrix.php }}-composer-

      - name: Install dependencies
        run: composer install --prefer-dist --no-interaction --no-suggest --no-progress

      - name: Setup Problem Matchers for PHPUnit
        run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

      - name: Run Integration Tests
        env:
          TEST_FIREBASE_CREDENTIALS: ${{secrets.TEST_FIREBASE_CREDENTIALS}}
          TEST_REGISTRATION_TOKENS: ${{secrets.TEST_REGISTRATION_TOKENS}}
          TEST_FIREBASE_RTDB_URI: ${{secrets.TEST_FIREBASE_RTDB_URI}}
        run: vendor/bin/phpunit --testsuite=integration --coverage-clover=coverage.xml --log-junit=test-report.xml --verbose

      - name: Upload code coverage
        uses: codecov/codecov-action@v1
        with:
          token: ${{ secrets.CODECOV_TOKEN }}
          flags: integration<commit_msg>Use PHP 8.0 for integration tests<commit_after>name: Integration Tests

on:
  - pull_request
  - push
  - workflow_dispatch

jobs:
  integration-tests:
    name: Integration Tests
    runs-on: ubuntu-latest
    if: github.repository == 'kreait/firebase-php'

    env:
      php-version: '8.0'
      extensions: ctype, dom, grpc, json, mbstring, openssl, xml, zip, zlib
      key: cache-integration-v4 # can be any string, change to clear the extension cache.

    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Setup cache environment
        id: cache-env
        uses: shivammathur/cache-extensions@v1
        with:
          php-version: ${{ env.php-version }}
          extensions: ${{ env.extensions }}
          key: ${{ env.key }}

      - name: Cache extensions
        uses: actions/cache@v1
        with:
          path: ${{ steps.cache-env.outputs.dir }}
          key: ${{ steps.cache-env.outputs.key }}
          restore-keys: ${{ steps.cache-env.outputs.key }}

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ env.php-version }}
          extensions: ${{ env.extensions }}
          tools: composer, pecl
          coverage: xdebug

      - name: Setup problem matchers for PHP
        run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"

      - name: Get Composer Cache Directory
        id: composer-cache
        run: echo "::set-output name=dir::$(composer config cache-files-dir)"

      - name: Cache dependencies
        uses: actions/cache@v1
        with:
          path: ${{ steps.composer-cache.outputs.dir }}
          key: ${{ runner.os }}-${{ matrix.php }}-${{ env.key }}-composer-${{ hashFiles('**/composer.json') }}
          restore-keys: ${{ runner.os }}-${{ matrix.php }}-composer-

      - name: Install dependencies
        run: composer install --prefer-dist --no-interaction --no-suggest --no-progress

      - name: Setup Problem Matchers for PHPUnit
        run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

      - name: Run Integration Tests
        env:
          TEST_FIREBASE_CREDENTIALS: ${{secrets.TEST_FIREBASE_CREDENTIALS}}
          TEST_REGISTRATION_TOKENS: ${{secrets.TEST_REGISTRATION_TOKENS}}
          TEST_FIREBASE_RTDB_URI: ${{secrets.TEST_FIREBASE_RTDB_URI}}
        run: vendor/bin/phpunit --testsuite=integration --coverage-clover=coverage.xml --log-junit=test-report.xml --verbose

      - name: Upload code coverage
        uses: codecov/codecov-action@v1
        with:
          token: ${{ secrets.CODECOV_TOKEN }}
          flags: integration
{'fraction_non_alphanumeric': 0.1297431966270602, 'fraction_numerical': 0.004024530471444998, 'mean_word_length': 2.2578027465667914, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4725092', 'n_tokens_mistral': 1657, 'n_tokens_neox': 1568, 'n_words': 365}