From b998f6b7c2697495e79f835cf091bd2618468521 Mon Sep 17 00:00:00 2001 From: Ben Peachey Date: Wed, 12 Mar 2025 14:46:24 +0100 Subject: [PATCH 1/2] Add (or update) GitHub Action (GHA) files and related config. --- .config/.remarkrc | 6 + .config/.yamllint | 14 ++ phpunit.xml.dist => .config/phpunit.xml.dist | 14 +- .github/workflows/json.yml | 46 +++++++ .github/workflows/linting-php.yml | 21 --- .github/workflows/markdown.yml | 42 ++++++ .github/workflows/php-version-sniff.yml | 31 ----- .github/workflows/php.yml | 136 +++++++++++++++++++ .github/workflows/tests.yml | 32 ----- .github/workflows/yaml.yml | 42 ++++++ composer.json | 2 +- 11 files changed, 294 insertions(+), 92 deletions(-) create mode 100644 .config/.remarkrc create mode 100644 .config/.yamllint rename phpunit.xml.dist => .config/phpunit.xml.dist (65%) create mode 100644 .github/workflows/json.yml delete mode 100644 .github/workflows/linting-php.yml create mode 100644 .github/workflows/markdown.yml delete mode 100644 .github/workflows/php-version-sniff.yml create mode 100644 .github/workflows/php.yml delete mode 100644 .github/workflows/tests.yml create mode 100644 .github/workflows/yaml.yml diff --git a/.config/.remarkrc b/.config/.remarkrc new file mode 100644 index 0000000..bfa065d --- /dev/null +++ b/.config/.remarkrc @@ -0,0 +1,6 @@ +{ + "plugins": [ + "remark-preset-lint-recommended", + ["remark-lint-list-item-indent", "space"] + ] +} diff --git a/.config/.yamllint b/.config/.yamllint new file mode 100644 index 0000000..7c1b6e4 --- /dev/null +++ b/.config/.yamllint @@ -0,0 +1,14 @@ +--- +extends: default + +ignore: | + vendor/ + +rules: + brackets: + max-spaces-inside: 1 + document-start: disable + line-length: + level: warning + max: 120 + truthy: {allowed-values: ["true", "false", "on"]} diff --git a/phpunit.xml.dist b/.config/phpunit.xml.dist similarity index 65% rename from phpunit.xml.dist rename to .config/phpunit.xml.dist index e1791a5..9beadd4 100644 --- a/phpunit.xml.dist +++ b/.config/phpunit.xml.dist @@ -1,13 +1,13 @@ - tests/ + ../tests/ - + - src/ + ../src/ @@ -30,4 +30,4 @@ - \ No newline at end of file + diff --git a/.github/workflows/json.yml b/.github/workflows/json.yml new file mode 100644 index 0000000..7e83269 --- /dev/null +++ b/.github/workflows/json.yml @@ -0,0 +1,46 @@ +--- +name: JSON 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: + branches: [ main ] + paths: + - '**.json' + - '.github/workflows/json.yml' + types: [ opened, reopened, synchronize ] + # This event occurs when there is a push to the repository. + push: + paths: + - '**.json' + - '.github/workflows/json.yml' + # 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.json.lint-syntax.yml + lint-json-syntax: + name: JSON Syntax Linting + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + - uses: docker://pipelinecomponents/jsonlint + with: + args: >- + find . + -not -path '*/.git/*' + -not -path '*/node_modules/*' + -not -path '*/vendor/*' + -name '*.json' + -type f + -exec jsonlint --quiet {} ; diff --git a/.github/workflows/linting-php.yml b/.github/workflows/linting-php.yml deleted file mode 100644 index 1cc6694..0000000 --- a/.github/workflows/linting-php.yml +++ /dev/null @@ -1,21 +0,0 @@ ---- -name: Linting PHP - -on: - - push - - pull_request - # Allow manually triggering the workflow. - - workflow_dispatch - -# Cancels all previous workflow runs for the same branch that have not yet completed. -concurrency: - # The concurrency group contains the workflow name and the branch name. - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - lint-php: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v3 - - uses: pipeline-components/php-linter@master diff --git a/.github/workflows/markdown.yml b/.github/workflows/markdown.yml new file mode 100644 index 0000000..581b9c7 --- /dev/null +++ b/.github/workflows/markdown.yml @@ -0,0 +1,42 @@ +--- +name: Markdown 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: + branches: [ main ] + paths: + - '**.md' + - '.github/workflows/markdown.yml' + types: [ opened, reopened, synchronize ] + # This event occurs when there is a push to the repository. + push: + paths: + - '**.md' + - '.github/workflows/markdown.yml' + # 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.quality.markdown.lint-syntax.yml + lint-markdown-syntax: + name: Markdown Linting + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + - uses: docker://pipelinecomponents/remark-lint + with: + args: >- + remark + --rc-path=.config/.remarkrc + --ignore-pattern='*/vendor/*' diff --git a/.github/workflows/php-version-sniff.yml b/.github/workflows/php-version-sniff.yml deleted file mode 100644 index 5b2b8ad..0000000 --- a/.github/workflows/php-version-sniff.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- -name: PHP Version Compatibility - -on: - - push - - pull_request - # Allow manually triggering the workflow. - - workflow_dispatch - -# Cancels all previous workflow runs for the same branch that have not yet completed. -concurrency: - # The concurrency group contains the workflow name and the branch name. - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - php-codesniffer: - strategy: - matrix: - php: [ '8.0', '8.1' ] - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v3 - - uses: pipeline-components/php-codesniffer@master - with: - options: >- - -s - --ignore='*vendor/*' - --standard=PHPCompatibility - --extensions=php - --runtime-set testVersion ${{ matrix.php }} diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml new file mode 100644 index 0000000..33c065c --- /dev/null +++ b/.github/workflows/php.yml @@ -0,0 +1,136 @@ +--- +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 + # 02.test.php.test-unit.yml + php-unittest: + name: PHP Unit Tests + needs: + - lint-php-syntax + - validate-dependencies-file + runs-on: ubuntu-24.04 + strategy: + fail-fast: false + matrix: + php: + - '8.0' # from 2020-11 to 2022-11 (2023-11) + - '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: shivammathur/setup-php@v2 + with: + coverage: xdebug + ini-values: error_reporting=E_ALL, display_errors=On + php-version: ${{ matrix.php }} + - name: Install and Cache Composer dependencies + uses: "ramsey/composer-install@v2" + env: + COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ secrets.GITHUB_TOKEN }}"}}' + - run: bin/phpunit --configuration .config/phpunit.xml.dist + # 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 + - name: Install and Cache Composer dependencies + uses: "ramsey/composer-install@v2" + env: + COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ secrets.GITHUB_TOKEN }}"}}' + - run: >- + composer audit + --abandoned=report + --no-dev + --no-plugins + --no-scripts + # 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.0' # from 2020-11 to 2022-11 (2023-11) + - '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 + . diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml deleted file mode 100644 index 50814af..0000000 --- a/.github/workflows/tests.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- -name: Test jobs - -on: - - push - - pull_request - # Allow manually triggering the workflow. - - workflow_dispatch - -# Cancels all previous workflow runs for the same branch that have not yet completed. -concurrency: - # The concurrency group contains the workflow name and the branch name. - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - phpunit: - runs-on: ubuntu-20.04 - - strategy: - matrix: - php: ['8.0', '8.1'] - - steps: - - uses: actions/checkout@v3 - - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - - uses: "ramsey/composer-install@v2" - with: - composer-options: --no-scripts - - run: bin/phpunit diff --git a/.github/workflows/yaml.yml b/.github/workflows/yaml.yml new file mode 100644 index 0000000..ad8fb9d --- /dev/null +++ b/.github/workflows/yaml.yml @@ -0,0 +1,42 @@ +--- +name: YAML 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: + branches: [ main ] + paths: + - '**.yml' + - '**.yaml' + types: [ opened, reopened, synchronize ] + # This event occurs when there is a push to the repository. + push: + paths: + - '**.yml' + - '**.yaml' + # 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.yaml.lint.yml + lint-yaml: + name: YAML Linting + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + - uses: docker://pipelinecomponents/yamllint + with: + args: >- + yamllint + --config-file=.config/.yamllint + . diff --git a/composer.json b/composer.json index f3cbb6b..fb38675 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ }, "scripts": { "dev:example": "php -S localhost:${PORT:-8080} -t ./src/ ./src/example.php", - "tests:unit": "phpunit ./tests/unit" + "tests:unit": "phpunit --configuration `.config/phpunit.xml.dist` ./tests/unit" }, "scripts-descriptions": { "dev:example": "Run internal PHP development server with example code", From fe26866a042c044cd50b2ca2acf86932a5c7799b Mon Sep 17 00:00:00 2001 From: Ben Peachey Date: Sun, 16 Mar 2025 19:56:55 +0100 Subject: [PATCH 2/2] Fix Yamml Lint violations. --- _config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_config.yml b/_config.yml index 65e3498..d9dd1f5 100644 --- a/_config.yml +++ b/_config.yml @@ -33,7 +33,7 @@ nav: exclude: - / - /404.html - favicon_ico : /favicon.ico + favicon_ico: /favicon.ico main_title: link: '/' recurse: true