Skip to content

Update phpunit/phpunit requirement from ^9.5 to ^11.3 #17

Update phpunit/phpunit requirement from ^9.5 to ^11.3

Update phpunit/phpunit requirement from ^9.5 to ^11.3 #17

name: Coding Standards
on:
push:
branches:
- main
pull_request:
branches:
- main
paths:
# Any change to a PHP file should run checks.
- '**.php'
# These files configure Composer. Changes could affect the outcome.
- 'composer.*'
# This file configures PHPCS. Changes could affect the outcome.
- 'phpcs.xml.dist'
# Changes to workflow files should always verify all workflows are successful.
- '.github/workflows/*.yml'
workflow_dispatch:
# Cancels all previous workflow runs for pull requests that have not completed.
concurrency:
# The concurrency group contains the workflow name and the branch name for pull requests
# or the commit hash for any other events.
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true
jobs:
phpcs:
name: PHP coding standards
runs-on: ubuntu-latest
timeout-minutes: 20
if: ${{ github.repository == 'CSoellinger/silverstripe-limit-characters-with-html' }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
coverage: none
tools: cs2pr
- name: "Get last Monday's date"
id: get-date
run: echo "date=$(/bin/date -u --date='last Mon' "+%F")" >> $GITHUB_OUTPUT
- name: "Create cache dir"
run: mkdir .cache
- name: Cache PHPCS scan cache
uses: actions/cache@v3
with:
path: |
.cache/phpcs-src.json
.cache/phpcs-tests.json
key: ${{ runner.os }}-date-${{ steps.get-date.outputs.date }}-phpcs-cache-${{ hashFiles('**/composer.json', 'phpcs.xml.dist') }}
- name: Check PHP Version
run: php -v
- name: Validate composer.json and composer.lock
run: composer validate --strict
# Since Composer dependencies are installed using `composer update` and no lock file is in version control,
# passing a custom cache suffix ensures that the cache is flushed at least once per week.
- name: Install Composer dependencies
uses: ramsey/composer-install@v2
with:
custom-cache-suffix: ${{ steps.get-date.outputs.date }}
- name: Make Composer packages available globally
run: echo "${PWD}/vendor/bin" >> $GITHUB_PATH
- name: Run PHPCS on all Core files
id: phpcs-core
run: phpcs -n --report-full --cache=./.cache/phpcs-src.json --report-checkstyle=./.cache/phpcs-report.xml
- name: Show PHPCS results in PR
if: ${{ always() && steps.phpcs-core.outcome == 'failure' }}
run: cs2pr ./.cache/phpcs-report.xml
- name: Check test suite files for warnings
id: phpcs-tests
run: phpcs tests --report-full --cache=./.cache/phpcs-tests.json --report-checkstyle=./.cache/phpcs-tests-report.xml
- name: Show test suite scan results in PR
if: ${{ always() && steps.phpcs-tests.outcome == 'failure' }}
run: cs2pr ./.cache/phpcs-tests-report.xml
- name: Ensure version-controlled files are not modified during the tests
run: git diff --exit-code
# failed-workflow:
# name: Failed workflow tasks
# runs-on: ubuntu-latest
# needs: [ phpcs, jshint, slack-notifications ]
# if: |
# always() &&
# github.repository == 'CSoellinger/silverstripe-limit-characters-with-html' &&
# github.event_name != 'pull_request' &&
# github.run_attempt < 2 &&
# (
# needs.phpcs.result == 'cancelled' || needs.phpcs.result == 'failure' ||
# needs.jshint.result == 'cancelled' || needs.jshint.result == 'failure'
# )
# steps:
# - name: Dispatch workflow run
# uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975 # v6.4.0
# with:
# retries: 2
# retry-exempt-status-codes: 418
# script: |
# github.rest.actions.createWorkflowDispatch({
# owner: context.repo.owner,
# repo: context.repo.repo,
# workflow_id: 'failed-workflow.yml',
# ref: 'trunk',
# inputs: {
# run_id: '${{ github.run_id }}'
# }
# });