diff options
author | Maurício Meneghini Fauth <mauricio@fauth.dev> | 2022-02-25 19:29:21 +0300 |
---|---|---|
committer | Maurício Meneghini Fauth <mauricio@fauth.dev> | 2022-07-22 23:16:09 +0300 |
commit | ee744a6fd570222938ffdbed4b626ea6aa552240 (patch) | |
tree | d36054a2fa628e77e090d4bf1a1d5385de71f886 /.github/workflows | |
parent | 8ecf99a90444fed5482d2d3e08266c9dd507f1cf (diff) |
Improve mutation tests workflow
- Runs only if has changes in `'*/classes/**.php'` files.
- Runs full test for `push`.
- Runs only for changed files for `pull_request`.
- Adds GitHub Annotations for pull requests
- Removes the unnecessary checks for [ci skip].
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
Diffstat (limited to '.github/workflows')
-rw-r--r-- | .github/workflows/mutation-tests.yml | 59 |
1 files changed, 29 insertions, 30 deletions
diff --git a/.github/workflows/mutation-tests.yml b/.github/workflows/mutation-tests.yml index 17d0da682d..ad08a5ca87 100644 --- a/.github/workflows/mutation-tests.yml +++ b/.github/workflows/mutation-tests.yml @@ -1,34 +1,38 @@ +# https://docs.github.com/en/actions + name: Mutation tests on: push: - branches: [master] + branches: + - master + paths: + - '*/classes/**.php' pull_request: - branches: [master] + branches: + - master + paths: + - '*/classes/**.php' permissions: contents: read jobs: - tests: - name: Mutation tests with PHP ${{ matrix.php-version }} + infection: + name: Infection runs-on: ${{ matrix.operating-system }} strategy: matrix: - php-version: ["8.0"] - operating-system: [ubuntu-latest] + php-version: + - "8.1" + operating-system: + - ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v3 - - name: Fetch github.base_ref (for diffing) - if: ${{ github.base_ref != '' }} - run: | - git fetch --depth=1 origin +refs/heads/${{ github.base_ref }}:refs/remotes/origin/${{ github.base_ref }} - - name: Install Gettext - run: | - sudo apt-get install -y gettext + run: sudo apt-get install -y gettext - name: Generate mo files run: ./scripts/generate-mo --quiet @@ -43,31 +47,26 @@ jobs: - name: Install Infection # The GPG key can be found at https://infection.github.io/guide/installation.html - run: | - phive --no-progress install --target ./build/tools --trust-gpg-keys C5095986493B4AA0 infection + run: phive --no-progress install --target ./build/tools --trust-gpg-keys C5095986493B4AA0 infection - name: Install Composer dependencies - uses: ramsey/composer-install@v1 + uses: ramsey/composer-install@v2 with: dependency-versions: highest - name: Collect coverage report - run: | - composer run phpunit -- --testsuite unit --stop-on-failure + run: composer run phpunit -- --testsuite unit --stop-on-failure - - name: Infection - if: ${{ github.base_ref != '' }} + - name: Run Infection for changed files only + if: github.event_name == 'pull_request' run: | - CHANGED_FILES=$(git diff origin/$GITHUB_BASE_REF --diff-filter=AM --name-only | grep libraries/classes/ | paste -sd "," -); - ./build/tools/infection -j$(nproc) --skip-initial-tests --no-interaction --no-progress --coverage=build/logs \ - --ignore-msi-with-no-mutations \ - --filter=$CHANGED_FILES - env: - INFECTION_BADGE_API_KEY: ${{ secrets.INFECTION_BADGE_API_KEY }} + git fetch --depth=1 origin $GITHUB_BASE_REF + ./build/tools/infection -j$(nproc) --git-diff-lines --git-diff-base=origin/$GITHUB_BASE_REF \ + --logger-github --ignore-msi-with-no-mutations --only-covered \ + --skip-initial-tests --coverage=build/logs --no-interaction --no-progress - - name: Infection - if: ${{ github.base_ref == '' }} - run: | - ./build/tools/infection -j$(nproc) --skip-initial-tests --no-interaction --no-progress --coverage=build/logs + - name: Run Infection + if: github.event_name == 'push' env: INFECTION_BADGE_API_KEY: ${{ secrets.INFECTION_BADGE_API_KEY }} + run: ./build/tools/infection -j$(nproc) --skip-initial-tests --coverage=build/logs --no-interaction --no-progress |