phpmyadmin/phpmyadmin

View on GitHub
.github/workflows/mutation-tests.yml

Summary

Maintainability
Test Coverage
# https://docs.github.com/en/actions

name: Mutation tests

on:
  push:
    branches:
      - master
    paths:
      - 'src/**.php'
      - 'tests/unit/**.php'
  pull_request:
    branches:
      - master
    paths:
      - 'src/**.php'
      - 'tests/unit/**.php'
  workflow_dispatch:
  schedule:
    - cron: '0 0 * * *'

permissions:
  contents: read

jobs:
  infection:
    name: Infection
    runs-on: ${{ matrix.operating-system }}
    strategy:
      matrix:
        php-version:
          - "8.2"
        operating-system:
          - ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
        with:
          fetch-depth: 2

      - name: Checkout base ref code
        if: github.event_name == 'pull_request'
        uses: actions/checkout@v4
        with:
          ref: ${{ github.base_ref }}

      - name: Install Gettext
        run: sudo apt-get install -y gettext

      - name: Generate mo files
        run: ./bin/generate-mo --quiet

      - name: Set up PHP ${{ matrix.php-version }}
        uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ matrix.php-version }}
          coverage: pcov
          tools: composer:v2, infection

      - name: Install Composer dependencies
        uses: ramsey/composer-install@v2

      - name: Run Infection for changed files only
        if: github.event_name == 'push' || github.event_name == 'pull_request'
        run: |
          if [ "$GITHUB_EVENT_NAME" = "push" ]; then \
            INFECTION_GIT_DIFF_BASE="origin/$GITHUB_REF_NAME^"; else \
            INFECTION_GIT_DIFF_BASE="origin/$GITHUB_BASE_REF"; fi
          infection --threads=max --git-diff-lines --git-diff-base="$INFECTION_GIT_DIFF_BASE" \
            --logger-github --ignore-msi-with-no-mutations --only-covered --no-interaction --no-progress

      - name: Run Infection for all files
        if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
        env:
          INFECTION_BADGE_API_KEY: ${{ secrets.INFECTION_BADGE_API_KEY }}
        run: infection --threads=max --no-interaction --log-verbosity=none --logger-github=false