Skip to content

Refactor PHP workflow for improved directory structure #216

Refactor PHP workflow for improved directory structure

Refactor PHP workflow for improved directory structure #216

Workflow file for this run

---
name: PHP Quality Assistance
on:
# This event occurs when there is activity on a pull request. The workflow
# will be run against the commits, after merge to the target branch (main).
pull_request:
paths:
- '**.php'
- '.config/phpcs.xml.dist'
- '.config/phpunit.xml.dist'
- '.github/workflows/php.yml'
- 'composer.json'
- 'composer.lock'
branches: [ main ]
types: [ opened, reopened, synchronize ]
# This event occurs when there is a push to the repository.
push:
paths:
- '**.php'
- '.config/phpcs.xml.dist'
- '.config/phpunit.xml.dist'
- '.github/workflows/php.yml'
- 'composer.json'
- 'composer.lock'
# Allow manually triggering the workflow.
workflow_dispatch:
# Cancels all previous workflow runs for the same branch that have not yet completed.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
# Needed to allow the "concurrency" section to cancel a workflow run.
actions: write
jobs:
# 01.preflight.php.lint-syntax.yml
lint-php-syntax:
name: PHP Syntax Linting
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: docker://pipelinecomponents/php-linter
with:
args: >-
parallel-lint
--exclude .git
--exclude vendor
--no-progress
.
# 01.quality.php.validate.dependencies-file.yml
validate-dependencies-file:
name: Validate dependencies file
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- run: >-
composer validate
--check-lock
--no-plugins
--no-scripts
--strict
working-directory: "solid"
# 02.test.php.test-unit.yml
php-unittest:
container:
image: ghcr.io/${{ github.repository }}:main-${{ matrix.nextcloud_version }}
env:
COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ secrets.GITHUB_TOKEN }}"}}'
XDEBUG_MODE: coverage
volumes:
- /usr/bin/composer:/usr/bin/composer
defaults:
run:
shell: bash
working-directory: /var/www/html/apps/
name: PHP Unit Tests
needs:
- lint-php-syntax
- validate-dependencies-file
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
nextcloud_version:
- 28
- 29
- 30
steps:
- uses: actions/checkout@v5
- name: Debug info
run: |
rm /var/www/html/apps/solid/
cp -r "${GITHUB_WORKSPACE}" /var/www/html/apps/
echo " =====> PWD:'$PWD'"
ls -lA "$PWD"
echo " =====> GITHUB_WORKSPACE:'${GITHUB_WORKSPACE}'"
ls -lA "$GITHUB_WORKSPACE"
echo ' =====> ${GITHUB_WORKSPACE}/solid/'
ls -lA "${GITHUB_WORKSPACE}/solid/"
echo ' =====> /var/www/html/apps/solid'
ls -lA "/var/www/html/apps/solid"
- name: Install and Cache Composer dependencies
uses: ramsey/composer-install@v3
with:
working-directory: /var/www/html/apps/solid
env:
COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ secrets.GITHUB_TOKEN }}"}}'
- name: Run PHPUnit
run: |
/var/www/html/apps/solid/bin/phpunit \
--configuration /var/www/html/apps/solid/phpunit.xml \
/var/www/html/apps/solid/tests/Unit
# 03.quality.php.scan.dependencies-vulnerabilities.yml
scan-dependencies-vulnerabilities:
name: Scan Dependencies Vulnerabilities
needs:
- validate-dependencies-file
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- run: >-
composer audit
--abandoned=report
--locked
--no-dev
--no-plugins
--no-scripts
working-directory: "solid"
# 03.quality.php.lint-quality.yml
php-lint-quality:
needs:
- lint-php-syntax
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: docker://pipelinecomponents/php-codesniffer
with:
args: >-
phpcs
-s
--extensions=php
--ignore='*vendor/*'
--standard=.config/phpcs.xml.dist
.
# 03.quality.php.lint-version-compatibility.yml
php-check-version-compatibility:
name: PHP Version Compatibility
needs:
- lint-php-syntax
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
php:
- '8.1' # from 2021-11 to 2023-11 (2025-12)
- '8.2' # from 2022-12 to 2024-12 (2026-12)
- '8.3' # from 2023-11 to 2025-12 (2027-12)
steps:
- uses: actions/checkout@v4
- uses: docker://pipelinecomponents/php-codesniffer
with:
args: >-
phpcs
-s
--extensions=php
--ignore='*vendor/*'
--runtime-set testVersion ${{ matrix.php }}
--standard=PHPCompatibility
.