From d62d88044fe8893a452de5a49881f575b75535d4 Mon Sep 17 00:00:00 2001 From: lotyp Date: Thu, 13 Jun 2024 18:39:59 +0300 Subject: [PATCH] ci: update workflows --- .github/workflows/apply-labels.yml | 2 +- ...ge-release.yaml => auto-merge-release.yml} | 4 +- .github/workflows/ci.yml | 72 ------ .github/workflows/coding-standards.yml | 200 +++++++++++++++ .github/workflows/create-arch-diagram.yml | 2 +- .github/workflows/create-release.yml | 18 +- .github/workflows/dependency-analysis.yml | 83 ++++++ .github/workflows/refactoring.yml | 66 +++++ .github/workflows/security-analysis.yml | 63 +++++ .github/workflows/shellcheck.yml | 4 +- .github/workflows/static-analysis.yml | 130 ++++++++++ .github/workflows/testing.yml | 242 ++++++++++++++++++ 12 files changed, 803 insertions(+), 83 deletions(-) rename .github/workflows/{auto-merge-release.yaml => auto-merge-release.yml} (93%) delete mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/coding-standards.yml create mode 100644 .github/workflows/dependency-analysis.yml create mode 100644 .github/workflows/refactoring.yml create mode 100644 .github/workflows/security-analysis.yml create mode 100644 .github/workflows/static-analysis.yml create mode 100644 .github/workflows/testing.yml diff --git a/.github/workflows/apply-labels.yml b/.github/workflows/apply-labels.yml index c9b1196b..2a14666f 100644 --- a/.github/workflows/apply-labels.yml +++ b/.github/workflows/apply-labels.yml @@ -14,7 +14,7 @@ name: ๐Ÿท๏ธ Add labels jobs: label: - uses: wayofdev/gh-actions/.github/workflows/apply-labels.yml@master + uses: wayofdev/gh-actions/.github/workflows/apply-labels.yml@v3.1.1 with: os: ubuntu-latest secrets: diff --git a/.github/workflows/auto-merge-release.yaml b/.github/workflows/auto-merge-release.yml similarity index 93% rename from .github/workflows/auto-merge-release.yaml rename to .github/workflows/auto-merge-release.yml index 084a3e12..8f5f45a0 100644 --- a/.github/workflows/auto-merge-release.yaml +++ b/.github/workflows/auto-merge-release.yml @@ -4,6 +4,8 @@ on: # yamllint disable-line rule:truthy pull_request: + branches: + - master permissions: pull-requests: write @@ -13,7 +15,7 @@ name: ๐Ÿคž Auto merge release jobs: auto-merge: - uses: wayofdev/gh-actions/.github/workflows/auto-merge-release.yml@master + uses: wayofdev/gh-actions/.github/workflows/auto-merge-release.yml@v3.1.1 with: os: ubuntu-latest pull-request-number: ${{ github.event.pull_request.number }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 69dab7e9..00000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,72 +0,0 @@ ---- - -on: # yamllint disable-line rule:truthy - pull_request: - branches: - - master - -name: ๐Ÿ” Continuous integration - -jobs: - integration: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: true - matrix: - os: ["ubuntu-22.04"] - php: ["8.2"] - - steps: - - name: ๐Ÿ“ฆ Check out the codebase - uses: actions/checkout@v4 - - - name: ๐Ÿ› ๏ธ Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - extensions: mbstring, fileinfo - ini-values: error_reporting=E_ALL - tools: composer:v2, pecl - coverage: xdebug - - - name: ๐Ÿ› ๏ธ Setup problem matchers - run: | - echo "::add-matcher::${{ runner.tool_cache }}/php.json" - echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" - - - name: โ™ป๏ธ Restore cached dependencies - id: cached-composer-dependencies - uses: actions/cache@v3 - with: - path: vendor - key: vendor-${{ runner.os }}-${{ hashFiles('**/composer.lock') }}-${{ matrix.php }} - - - name: ๐Ÿ“ฅ Install dependencies - if: steps.cached-composer-dependencies.outputs.cache-hit != 'true' - run: composer install - - - name: ๐Ÿ› ๏ธ Prepare environment - run: | - mkdir -p ./.build/php-cs-fixer - mkdir -p ./.build/phpstan - mkdir -p ./.build/phpunit - - - name: ๐Ÿšจ Run coding standards task - run: composer cs:diff - env: - PHP_CS_FIXER_IGNORE_ENV: true - - - name: ๐Ÿงช Execute phpunit and pest tests - run: composer test:cc - - - name: ๐Ÿ” Run static analysis using phpstan - run: composer stan:ci - - - name: ๐Ÿ“ค Upload coverage report to Codecov - uses: codecov/codecov-action@v4 - with: - token: ${{ secrets.CODECOV_TOKEN }} - files: ./coverage.xml - verbose: true - -... diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml new file mode 100644 index 00000000..78b8d5c2 --- /dev/null +++ b/.github/workflows/coding-standards.yml @@ -0,0 +1,200 @@ +--- + +on: # yamllint disable-line rule:truthy + pull_request: + branches: + - master + +name: ๐Ÿงน Fix PHP coding standards + +jobs: + commit-linting: + timeout-minutes: 4 + runs-on: ubuntu-latest + concurrency: + cancel-in-progress: true + group: commit-linting-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + permissions: + contents: read + pull-requests: read + steps: + - name: ๐Ÿ“ฆ Check out the codebase + uses: actions/checkout@v4.1.6 + + - name: ๐Ÿง Lint commits using "commitlint" + uses: wagoid/commitlint-github-action@v6.0.1 + with: + configFile: ${{ github.workspace }}/.github/.commitlint.config.mjs + failOnWarnings: false + failOnErrors: true + helpURL: 'https://github.com/conventional-changelog/commitlint/#what-is-commitlint' + + yaml-linting: + timeout-minutes: 4 + runs-on: ubuntu-latest + concurrency: + cancel-in-progress: true + group: yaml-linting-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + permissions: + contents: read + pull-requests: read + steps: + - name: ๐Ÿ“ฆ Check out the codebase + uses: actions/checkout@v4.1.6 + + - name: ๐Ÿง Lint YAML files + uses: ibiqlik/action-yamllint@v3.1.1 + with: + config_file: .github/.yamllint.yaml + file_or_dir: '.' + strict: true + + markdown-linting: + timeout-minutes: 4 + runs-on: ubuntu-latest + concurrency: + cancel-in-progress: true + group: markdown-linting-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + steps: + - name: ๐Ÿ“ฆ Check out the codebase + uses: actions/checkout@v4.1.6 + + - name: ๐Ÿง Lint Markdown files + uses: DavidAnson/markdownlint-cli2-action@v16.0.0 + with: + config: '.github/.markdownlint.json' + globs: | + **/*.md + !CHANGELOG.md + + composer-linting: + timeout-minutes: 4 + runs-on: ${{ matrix.os }} + concurrency: + cancel-in-progress: true + group: composer-linting-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + strategy: + matrix: + os: + - ubuntu-latest + php-version: + - '8.2' + dependencies: + - locked + permissions: + contents: write + steps: + - name: ๐Ÿ› ๏ธ Setup PHP + uses: shivammathur/setup-php@2.30.5 + with: + php-version: ${{ matrix.php-version }} + extensions: none, ctype, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter, phar, fileinfo, curl + ini-values: error_reporting=E_ALL + coverage: none + tools: phive + + - name: ๐Ÿ“ฆ Check out the codebase + uses: actions/checkout@v4.1.6 + + - name: ๐Ÿ› ๏ธ Setup problem matchers + run: | + echo "::add-matcher::${{ runner.tool_cache }}/php.json" + + - name: ๐Ÿค– Validate composer.json and composer.lock + run: composer validate --ansi --strict + + - name: ๐Ÿ” Get composer cache directory + uses: wayofdev/gh-actions/actions/composer/get-cache-directory@v3.1.1 + + - name: โ™ป๏ธ Restore cached dependencies installed with composer + uses: actions/cache@v4.0.2 + with: + path: ${{ env.COMPOSER_CACHE_DIR }} + key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }} + restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}- + + - name: ๐Ÿ“ฅ Install "${{ matrix.dependencies }}" dependencies with composer + uses: wayofdev/gh-actions/actions/composer/install@v3.1.1 + with: + dependencies: ${{ matrix.dependencies }} + + - name: ๐Ÿ“ฅ Install dependencies with phive + uses: wayofdev/gh-actions/actions/phive/install@v3.1.1 + with: + phive-home: '.phive' + trust-gpg-keys: 0xC00543248C87FB13,0x033E5F8D801A2F8D + + - name: ๐Ÿ” Run ergebnis/composer-normalize + run: .phive/composer-normalize --ansi --dry-run + + coding-standards: + timeout-minutes: 4 + runs-on: ${{ matrix.os }} + concurrency: + cancel-in-progress: true + group: coding-standards-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + strategy: + matrix: + os: + - ubuntu-latest + php-version: + - '8.2' + dependencies: + - locked + permissions: + contents: write + steps: + - name: โš™๏ธ Set git to use LF line endings + run: | + git config --global core.autocrlf false + git config --global core.eol lf + + - name: ๐Ÿ› ๏ธ Setup PHP + uses: shivammathur/setup-php@2.30.5 + with: + php-version: ${{ matrix.php-version }} + extensions: none, ctype, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter, fileinfo, curl + ini-values: error_reporting=E_ALL + coverage: none + + - name: ๐Ÿ“ฆ Check out the codebase + uses: actions/checkout@v4.1.6 + + - name: ๐Ÿ› ๏ธ Setup problem matchers + run: | + echo "::add-matcher::${{ runner.tool_cache }}/php.json" + + - name: ๐Ÿค– Validate composer.json and composer.lock + run: composer validate --ansi --strict + + - name: ๐Ÿ” Get composer cache directory + uses: wayofdev/gh-actions/actions/composer/get-cache-directory@v3.1.1 + + - name: โ™ป๏ธ Restore cached dependencies installed with composer + uses: actions/cache@v4.0.2 + with: + path: ${{ env.COMPOSER_CACHE_DIR }} + key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }} + restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}- + + - name: ๐Ÿ“ฅ Install "${{ matrix.dependencies }}" dependencies with composer + uses: wayofdev/gh-actions/actions/composer/install@v3.1.1 + with: + dependencies: ${{ matrix.dependencies }} + + - name: ๐Ÿ› ๏ธ Prepare environment + run: make prepare + + - name: ๐Ÿšจ Run coding standards task + run: composer cs:fix + env: + PHP_CS_FIXER_IGNORE_ENV: true + + - name: ๐Ÿ“ค Commit and push changed files back to GitHub + uses: stefanzweifel/git-auto-commit-action@v5.0.1 + with: + commit_message: 'style(php-cs-fixer): lint php files and fix coding standards' + branch: ${{ github.head_ref }} + commit_author: 'github-actions ' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/create-arch-diagram.yml b/.github/workflows/create-arch-diagram.yml index abb38a9a..7f1b1e61 100644 --- a/.github/workflows/create-arch-diagram.yml +++ b/.github/workflows/create-arch-diagram.yml @@ -19,7 +19,7 @@ permissions: read-all jobs: codesee: - uses: wayofdev/gh-actions/.github/workflows/create-arch-diagram.yml@master + uses: wayofdev/gh-actions/.github/workflows/create-arch-diagram.yml@v3.1.1 with: os: ubuntu-latest continue-on-error: true diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index e2cc98ab..964751b8 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -2,6 +2,7 @@ # https://github.com/wayofdev/gh-actions/blob/master/.github/workflows/create-release.yml # https://github.com/google-github-actions/release-please-action#release-types-supported +# https://github.com/googleapis/release-please/blob/main/docs/customizing.md on: # yamllint disable-line rule:truthy push: @@ -12,12 +13,15 @@ name: ๐Ÿ“ฆ Create release jobs: release: - uses: wayofdev/gh-actions/.github/workflows/create-release.yml@master - with: - os: ubuntu-latest - branch: master - package-name: laravel-paginator - secrets: - token: ${{ secrets.PERSONAL_GITHUB_TOKEN }} + runs-on: ubuntu-latest + steps: + - name: ๐ŸŽ‰ Create release + uses: googleapis/release-please-action@v4.1.3 + id: release + with: + token: ${{ secrets.PERSONAL_GITHUB_TOKEN }} + config-file: .github/.release-please-config.json + manifest-file: .github/.release-please-manifest.json + target-branch: master ... diff --git a/.github/workflows/dependency-analysis.yml b/.github/workflows/dependency-analysis.yml new file mode 100644 index 00000000..8032bd83 --- /dev/null +++ b/.github/workflows/dependency-analysis.yml @@ -0,0 +1,83 @@ +--- + +on: # yamllint disable-line rule:truthy + push: + branches: + - master + paths: + - 'config/**' + - 'src/**' + - 'tests/**' + - '.php-cs-fixer.dist.php' + - 'composer.*' + pull_request: + branches: + - master + paths: + - 'config/**' + - 'src/**' + - 'tests/**' + - '.php-cs-fixer.dist.php' + - 'composer.*' + +name: ๐Ÿ” Dependency analysis + +jobs: + dependency-analysis: + timeout-minutes: 4 + runs-on: ${{ matrix.os }} + concurrency: + cancel-in-progress: true + group: dependency-analysis-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + strategy: + fail-fast: true + matrix: + os: + - ubuntu-latest + php-version: + - '8.2' + dependencies: + - locked + + steps: + - name: ๐Ÿ“ฆ Check out the codebase + uses: actions/checkout@v4.1.6 + + - name: ๐Ÿ› ๏ธ Setup PHP + uses: shivammathur/setup-php@2.30.5 + with: + php-version: ${{ matrix.php-version }} + extensions: none, ctype, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter, fileinfo + ini-values: error_reporting=E_ALL + coverage: none + tools: phive + + - name: ๐Ÿ› ๏ธ Setup problem matchers + run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" + + - name: ๐Ÿค– Validate composer.json and composer.lock + run: composer validate --ansi --strict + + - name: ๐Ÿ” Get composer cache directory + uses: wayofdev/gh-actions/actions/composer/get-cache-directory@v3.1.1 + + - name: โ™ป๏ธ Restore cached dependencies installed with composer + uses: actions/cache@v4.0.2 + with: + path: ${{ env.COMPOSER_CACHE_DIR }} + key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }} + restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}- + + - name: ๐Ÿ“ฅ Install "${{ matrix.dependencies }}" dependencies + uses: wayofdev/gh-actions/actions/composer/install@v3.1.1 + with: + dependencies: ${{ matrix.dependencies }} + + - name: ๐Ÿ“ฅ Install dependencies with phive + uses: wayofdev/gh-actions/actions/phive/install@v3.1.1 + with: + phive-home: '.phive' + trust-gpg-keys: 0xC00543248C87FB13,0x033E5F8D801A2F8D + + - name: ๐Ÿ”ฌ Run maglnet/composer-require-checker + run: .phive/composer-require-checker check --ansi --config-file="$(pwd)/composer-require-checker.json" --verbose diff --git a/.github/workflows/refactoring.yml b/.github/workflows/refactoring.yml new file mode 100644 index 00000000..a70f9de8 --- /dev/null +++ b/.github/workflows/refactoring.yml @@ -0,0 +1,66 @@ +--- + +on: # yamllint disable-line rule:truthy + pull_request: + branches: + - master + paths: + - 'config/**' + - 'src/**' + - 'tests/**' + - '.php-cs-fixer.dist.php' + - 'rector.php' + +name: โš™๏ธ Refactoring + +jobs: + refactoring: + timeout-minutes: 4 + runs-on: ${{ matrix.os }} + concurrency: + cancel-in-progress: true + group: refactoring-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + strategy: + fail-fast: true + matrix: + os: + - ubuntu-latest + php-version: + - '8.2' + dependencies: + - locked + steps: + - name: ๐Ÿ“ฆ Check out the codebase + uses: actions/checkout@v4.1.6 + + - name: ๐Ÿ› ๏ธ Setup PHP + uses: shivammathur/setup-php@2.30.5 + with: + php-version: ${{ matrix.php-version }} + extensions: mbstring, pdo, pdo_sqlite, fileinfo + ini-values: error_reporting=E_ALL + coverage: none + + - name: ๐Ÿ› ๏ธ Setup problem matchers + run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" + + - name: ๐Ÿค– Validate composer.json and composer.lock + run: composer validate --ansi --strict + + - name: ๐Ÿ” Get composer cache directory + uses: wayofdev/gh-actions/actions/composer/get-cache-directory@v3.1.1 + + - name: โ™ป๏ธ Restore cached dependencies installed with composer + uses: actions/cache@v4.0.2 + with: + path: ${{ env.COMPOSER_CACHE_DIR }} + key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }} + restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}- + + - name: ๐Ÿ“ฅ Install "${{ matrix.dependencies }}" dependencies with composer + uses: wayofdev/gh-actions/actions/composer/install@v3.1.1 + with: + dependencies: ${{ matrix.dependencies }} + + - name: โš™๏ธ Run automated refactoring with rector/rector + run: composer refactor:ci diff --git a/.github/workflows/security-analysis.yml b/.github/workflows/security-analysis.yml new file mode 100644 index 00000000..7f3bb979 --- /dev/null +++ b/.github/workflows/security-analysis.yml @@ -0,0 +1,63 @@ +--- + +on: # yamllint disable-line rule:truthy + pull_request: + branches: + - master + push: + branches: + - master + +name: ๐Ÿ” Security analysis + +jobs: + security-analysis: + timeout-minutes: 4 + runs-on: ${{ matrix.os }} + concurrency: + cancel-in-progress: true + group: security-analysis-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + strategy: + fail-fast: true + matrix: + os: + - ubuntu-latest + php-version: + - '8.2' + dependencies: + - locked + steps: + - name: ๐Ÿ“ฆ Check out the codebase + uses: actions/checkout@v4.1.6 + + - name: ๐Ÿ› ๏ธ Setup PHP + uses: shivammathur/setup-php@2.30.5 + with: + php-version: ${{ matrix.php-version }} + extensions: none, ctype, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter, fileinfo, curl + ini-values: error_reporting=E_ALL + coverage: none + + - name: ๐Ÿ› ๏ธ Setup problem matchers + run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" + + - name: ๐Ÿค– Validate composer.json and composer.lock + run: composer validate --ansi --strict + + - name: ๐Ÿ” Get composer cache directory + uses: wayofdev/gh-actions/actions/composer/get-cache-directory@v3.1.1 + + - name: โ™ป๏ธ Restore cached dependencies installed with composer + uses: actions/cache@v4.0.2 + with: + path: ${{ env.COMPOSER_CACHE_DIR }} + key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }} + restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}- + + - name: ๐Ÿ“ฅ Install "${{ matrix.dependencies }}" dependencies with composer + uses: wayofdev/gh-actions/actions/composer/install@v3.1.1 + with: + dependencies: ${{ matrix.dependencies }} + + - name: ๐Ÿ› Check installed packages for security vulnerability advisories + run: composer audit --ansi diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml index d23d1642..95d35856 100644 --- a/.github/workflows/shellcheck.yml +++ b/.github/workflows/shellcheck.yml @@ -2,6 +2,8 @@ on: # yamllint disable-line rule:truthy pull_request: + branches: + - master name: ๐Ÿž Differential shell-check @@ -10,7 +12,7 @@ permissions: jobs: shellcheck: - uses: wayofdev/gh-actions/.github/workflows/shellcheck.yml@master + uses: wayofdev/gh-actions/.github/workflows/shellcheck.yml@v3.1.1 with: os: ubuntu-latest severity: warning diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml new file mode 100644 index 00000000..01a71095 --- /dev/null +++ b/.github/workflows/static-analysis.yml @@ -0,0 +1,130 @@ +--- + +on: # yamllint disable-line rule:truthy + push: + branches: + - master + paths: + - 'phpstan*' + - 'psalm*' + - 'composer.*' + - 'config/**' + - 'src/**' + - 'tests/**' + - '.php-cs-fixer.dist.php' + pull_request: + branches: + - master + paths: + - 'phpstan*' + - 'psalm*' + - 'composer.*' + - 'config/**' + - 'src/**' + - 'tests/**' + - '.php-cs-fixer.dist.php' + +name: ๐Ÿ” Static analysis + +jobs: + phpstan: + timeout-minutes: 4 + runs-on: ${{ matrix.os }} + concurrency: + cancel-in-progress: true + group: phpstan-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + strategy: + fail-fast: true + matrix: + os: + - ubuntu-latest + php-version: + - '8.2' + dependencies: + - locked + steps: + - name: ๐Ÿ“ฆ Check out the codebase + uses: actions/checkout@v4.1.6 + + - name: ๐Ÿ› ๏ธ Setup PHP + uses: shivammathur/setup-php@2.30.5 + with: + php-version: ${{ matrix.php-version }} + extensions: none, ctype, curl, dom, json, mbstring, phar, simplexml, tokenizer, xml, fileinfo, xmlwriter, opcache, pcntl, posix + ini-values: error_reporting=E_ALL + coverage: none + + - name: ๐Ÿ› ๏ธ Setup problem matchers + run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" + + - name: ๐Ÿค– Validate composer.json and composer.lock + run: composer validate --ansi --strict + + - name: ๐Ÿ” Get composer cache directory + uses: wayofdev/gh-actions/actions/composer/get-cache-directory@v3.1.1 + + - name: โ™ป๏ธ Restore cached dependencies installed with composer + uses: actions/cache@v4.0.2 + with: + path: ${{ env.COMPOSER_CACHE_DIR }} + key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }} + restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}- + + - name: ๐Ÿ“ฅ Install "${{ matrix.dependencies }}" dependencies + uses: wayofdev/gh-actions/actions/composer/install@v3.1.1 + with: + dependencies: ${{ matrix.dependencies }} + + - name: ๐Ÿ” Run static analysis using phpstan/phpstan + run: composer stan:ci + + psalm: + timeout-minutes: 4 + runs-on: ${{ matrix.os }} + concurrency: + cancel-in-progress: true + group: psalm-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + strategy: + fail-fast: true + matrix: + os: + - ubuntu-latest + php-version: + - '8.2' + dependencies: + - locked + steps: + - name: ๐Ÿ“ฆ Check out the codebase + uses: actions/checkout@v4.1.6 + + - name: ๐Ÿ› ๏ธ Setup PHP + uses: shivammathur/setup-php@2.30.5 + with: + php-version: ${{ matrix.php-version }} + extensions: none, ctype, curl, dom, json, mbstring, phar, simplexml, tokenizer, xml, fileinfo, xmlwriter, opcache, pcntl, posix, pdo + ini-values: error_reporting=E_ALL + coverage: xdebug + + - name: ๐Ÿ› ๏ธ Setup problem matchers + run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" + + - name: ๐Ÿค– Validate composer.json and composer.lock + run: composer validate --ansi --strict + + - name: ๐Ÿ” Get composer cache directory + uses: wayofdev/gh-actions/actions/composer/get-cache-directory@v3.1.1 + + - name: โ™ป๏ธ Restore cached dependencies installed with composer + uses: actions/cache@v4.0.2 + with: + path: ${{ env.COMPOSER_CACHE_DIR }} + key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }} + restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}- + + - name: ๐Ÿ“ฅ Install "${{ matrix.dependencies }}" dependencies with composer + uses: wayofdev/gh-actions/actions/composer/install@v3.1.1 + with: + dependencies: ${{ matrix.dependencies }} + + - name: ๐Ÿ” Run static analysis using vimeo/psalm + run: composer psalm:ci diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml new file mode 100644 index 00000000..a085750e --- /dev/null +++ b/.github/workflows/testing.yml @@ -0,0 +1,242 @@ +--- + +on: # yamllint disable-line rule:truthy + pull_request: + branches: + - master + push: + branches: + - master + +name: ๐Ÿงช Unit testing + +jobs: + code-coverage: + timeout-minutes: 4 + runs-on: ${{ matrix.os }} + concurrency: + cancel-in-progress: true + group: code-coverage-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-${{ matrix.php-version }}-${{ matrix.dependencies }} + strategy: + fail-fast: true + matrix: + os: + - ubuntu-latest + php-version: + - '8.2' + dependencies: + - locked + steps: + - name: ๐Ÿ“ฆ Check out the codebase + uses: actions/checkout@v4.1.6 + + - name: ๐Ÿ› ๏ธ Setup PHP + uses: shivammathur/setup-php@2.30.5 + with: + php-version: ${{ matrix.php-version }} + extensions: none, ctype, curl, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter, opcache, pcntl, posix, fileinfo + ini-values: error_reporting=E_ALL + coverage: xdebug + + - name: ๐Ÿ› ๏ธ Setup problem matchers + run: | + echo "::add-matcher::${{ runner.tool_cache }}/php.json" + echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" + + - name: ๐Ÿค– Validate composer.json and composer.lock + run: composer validate --ansi --strict + + - name: ๐Ÿ” Get composer cache directory + uses: wayofdev/gh-actions/actions/composer/get-cache-directory@v3.1.1 + + - name: โ™ป๏ธ Restore cached dependencies installed with composer + uses: actions/cache@v4.0.2 + with: + path: ${{ env.COMPOSER_CACHE_DIR }} + key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }} + restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}- + + - name: ๐Ÿ“ฅ Install "${{ matrix.dependencies }}" dependencies with composer + uses: wayofdev/gh-actions/actions/composer/install@v3.1.1 + with: + dependencies: ${{ matrix.dependencies }} + + - name: ๐Ÿงช Collect code coverage with Xdebug and pestphp/pest + run: composer test:cc + + - name: ๐Ÿ“ค Upload code coverage report to Codecov + uses: codecov/codecov-action@v4.4.1 + with: + files: .build/phpunit/logs/clover.xml + token: ${{ secrets.CODECOV_TOKEN }} + verbose: true + + unit-testing: + timeout-minutes: 4 + runs-on: ${{ matrix.os }} + concurrency: + cancel-in-progress: true + group: unit-testing-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-${{ matrix.php-version }}-${{ matrix.dependencies }} + strategy: + fail-fast: true + matrix: + os: + - ubuntu-latest + php-version: + - '8.2' + - '8.3' + dependencies: + - lowest + - locked + - highest + steps: + - name: ๐Ÿ“ฆ Check out the codebase + uses: actions/checkout@v4.1.6 + + - name: ๐Ÿ› ๏ธ Setup PHP + uses: shivammathur/setup-php@2.30.5 + with: + php-version: ${{ matrix.php-version }} + extensions: none, ctype, curl, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter, opcache, pcntl, posix, fileinfo + ini-values: error_reporting=E_ALL + coverage: xdebug + + - name: ๐Ÿ› ๏ธ Setup problem matchers + run: | + echo "::add-matcher::${{ runner.tool_cache }}/php.json" + echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" + + - name: ๐Ÿค– Validate composer.json and composer.lock + run: composer validate --ansi --strict + + - name: ๐Ÿ” Get composer cache directory + uses: wayofdev/gh-actions/actions/composer/get-cache-directory@v3.1.1 + + - name: โ™ป๏ธ Restore cached dependencies installed with composer + uses: actions/cache@v4.0.2 + with: + path: ${{ env.COMPOSER_CACHE_DIR }} + key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }} + restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}- + + - name: โš™๏ธ Remove platform configuration with composer + if: matrix.dependencies != 'locked' + run: composer config platform.php --ansi --unset + + - name: ๐Ÿ“ฅ Install "${{ matrix.dependencies }}" dependencies + uses: wayofdev/gh-actions/actions/composer/install@v3.1.1 + with: + dependencies: ${{ matrix.dependencies }} + + - name: ๐Ÿงช Run unit tests using pestphp/pest + run: composer test + + arch-testing: + timeout-minutes: 4 + runs-on: ${{ matrix.os }} + concurrency: + cancel-in-progress: true + group: arch-testing-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-${{ matrix.php-version }}-${{ matrix.dependencies }} + strategy: + fail-fast: true + matrix: + os: + - ubuntu-latest + php-version: + - '8.2' + dependencies: + - locked + steps: + - name: ๐Ÿ“ฆ Check out the codebase + uses: actions/checkout@v4.1.6 + + - name: ๐Ÿ› ๏ธ Setup PHP + uses: shivammathur/setup-php@2.30.5 + with: + php-version: ${{ matrix.php-version }} + extensions: none, ctype, curl, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter, opcache, pcntl, posix, fileinfo + ini-values: error_reporting=E_ALL + coverage: xdebug + + - name: ๐Ÿ› ๏ธ Setup problem matchers + run: | + echo "::add-matcher::${{ runner.tool_cache }}/php.json" + echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" + + - name: ๐Ÿค– Validate composer.json and composer.lock + run: composer validate --ansi --strict + + - name: ๐Ÿ” Get composer cache directory + uses: wayofdev/gh-actions/actions/composer/get-cache-directory@v3.1.1 + + - name: โ™ป๏ธ Restore cached dependencies installed with composer + uses: actions/cache@v4.0.2 + with: + path: ${{ env.COMPOSER_CACHE_DIR }} + key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }} + restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}- + + - name: โš™๏ธ Remove platform configuration with composer + if: matrix.dependencies != 'locked' + run: composer config platform.php --ansi --unset + + - name: ๐Ÿ“ฅ Install "${{ matrix.dependencies }}" dependencies + uses: wayofdev/gh-actions/actions/composer/install@v3.1.1 + with: + dependencies: ${{ matrix.dependencies }} + + - name: ๐Ÿงช Run architecture tests using pestphp/pest + run: composer test:arch + + mutation-testing: + timeout-minutes: 16 + runs-on: ${{ matrix.os }} + concurrency: + cancel-in-progress: true + group: mutation-testing-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + strategy: + fail-fast: true + matrix: + os: + - ubuntu-latest + php-version: + - '8.2' + dependencies: + - locked + steps: + - name: ๐Ÿ“ฆ Check out the codebase + uses: actions/checkout@v4.1.6 + + - name: ๐Ÿ› ๏ธ Setup PHP + uses: shivammathur/setup-php@2.30.5 + with: + php-version: ${{ matrix.php-version }} + extensions: mbstring, pdo, pdo_sqlite, fileinfo + ini-values: error_reporting=E_ALL + coverage: xdebug + + - name: ๐Ÿ› ๏ธ Setup problem matchers + run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" + + - name: ๐Ÿค– Validate composer.json and composer.lock + run: composer validate --ansi --strict + + - name: ๐Ÿ” Get composer cache directory + uses: wayofdev/gh-actions/actions/composer/get-cache-directory@v3.1.1 + + - name: โ™ป๏ธ Restore cached dependencies installed with composer + uses: actions/cache@v4.0.2 + with: + path: ${{ env.COMPOSER_CACHE_DIR }} + key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }} + restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}- + + - name: ๐Ÿ“ฅ Install "${{ matrix.dependencies }}" dependencies + uses: wayofdev/gh-actions/actions/composer/install@v3.1.1 + with: + dependencies: ${{ matrix.dependencies }} + + - name: ๐Ÿงช Run mutation testing using Xdebug and infection/infection + run: composer infect:ci + env: + STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}