diff --git a/.github/actions/setup-action/action.yml b/.github/actions/setup-action/action.yml new file mode 100644 index 00000000..5ff13c1e --- /dev/null +++ b/.github/actions/setup-action/action.yml @@ -0,0 +1,45 @@ +name: 'Setup' +description: 'Sets up the environment for Respect\Validation workflows.' + +inputs: + php-version: + description: 'The PHP version to install.' + required: false + default: '8.5' + coverage: + description: 'PHP Coverage mode.' + required: false + default: 'none' + extensions: + description: 'Comma-separated list of PHP extensions to install.' + required: false + default: '' + python-version: + description: 'The Python version to install.' + required: false + python-deps: + description: 'Space-separated list of Python packages to install.' + required: false + default: '' + +runs: + using: 'composite' + steps: + + - uses: shivammathur/setup-php@v2 + with: + php-version: ${{ inputs.php-version }} + coverage: ${{ inputs.coverage }} + extensions: ${{ inputs.extensions }} + + - if: ${{ inputs.python-version != '' }} + uses: actions/setup-python@v6 + with: + python-version: ${{ inputs.python-version }} + + - if: ${{ inputs.python-deps != '' }} + run: pip install ${{ inputs.python-deps }} + shell: bash + + - run: composer install --prefer-dist + shell: bash \ No newline at end of file diff --git a/.github/workflows/ci-code.yml b/.github/workflows/ci-code.yml new file mode 100644 index 00000000..97d20f98 --- /dev/null +++ b/.github/workflows/ci-code.yml @@ -0,0 +1,59 @@ +name: CI - Code + +on: + push: + paths-ignore: + - 'bin/**' + - 'docs/**' + pull_request: + paths-ignore: + - 'bin/**' + - 'docs/**' + +jobs: + tests: + name: Tests + runs-on: ubuntu-latest + + strategy: + matrix: + php-version: ["8.5"] + + steps: + - uses: actions/checkout@v6 + - uses: ./.github/actions/setup-action + with: + php-version: ${{ matrix.php-version }} + + - run: composer phpunit + - run: composer pest + + code-coverage: + name: Code Coverage + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v6 + - uses: ./.github/actions/setup-action + with: + coverage: pcov + + - name: Generating Code Coverage Report + run: ./vendor/bin/pest --compact --coverage-clover=coverage.xml + + - name: Send Code Coverage Report to Codecov.io + uses: codecov/codecov-action@v5 + with: + token: ${{ secrets.CODECOV_TOKEN }} + + static-analysis: + name: Static Analysis + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v6 + - uses: ./.github/actions/setup-action + + - run: composer phpcs + - run: composer phpstan + - run: bin/console lint:mixin diff --git a/.github/workflows/ci-docs.yml b/.github/workflows/ci-docs.yml new file mode 100644 index 00000000..81996bcb --- /dev/null +++ b/.github/workflows/ci-docs.yml @@ -0,0 +1,22 @@ +name: CI - Docs + +on: + push: + paths-ignore: + - 'data/**' + - 'tests/**' + pull_request: + paths-ignore: + - 'data/**' + - 'tests/**' + +jobs: + docs: + name: Lint + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v6 + - uses: ./.github/actions/setup-action + + - run: bin/console lint:docs diff --git a/.github/workflows/continuous-integration-perf.yml b/.github/workflows/ci-perf.yml similarity index 81% rename from .github/workflows/continuous-integration-perf.yml rename to .github/workflows/ci-perf.yml index 26041eb1..f7a1b632 100644 --- a/.github/workflows/continuous-integration-perf.yml +++ b/.github/workflows/ci-perf.yml @@ -1,14 +1,16 @@ -name: Continuous Integration (perf) +name: CI - Perf on: push: - paths-ignore: - - 'bin/**' - - 'docs/**' + paths: + - 'src/**' + - 'tests/**' + - '.github/**' pull_request: - paths-ignore: - - 'bin/**' - - 'docs/**' + paths: + - 'src/**' + - 'tests/**' + - '.github/**' workflow_dispatch: inputs: baseline: @@ -23,31 +25,20 @@ jobs: tests: name: Benchmarks runs-on: ubuntu-latest + continue-on-error: true # This job is experimental permissions: contents: write pull-requests: write - strategy: - matrix: - php-version: - - "8.5" - steps: - - name: Checkout - uses: actions/checkout@v6 + - uses: actions/checkout@v6 with: persist-credentials: true - - - name: Install PHP - uses: shivammathur/setup-php@v2 + - uses: ./.github/actions/setup-action with: - php-version: ${{ matrix.php-version }} extensions: xdebug - - name: Install Dependencies - run: composer install --prefer-dist ${{ matrix.composer-extra-arguments }} - - name: Fetch Benchmarks run: | git fetch origin benchmarks @@ -75,7 +66,7 @@ jobs: cat report.md - - name: Commit Benchmark Results + - name: Commit Results if: github.ref == 'refs/heads/main' && github.event_name == 'push' run: | set -euo pipefail diff --git a/.github/workflows/continuous-integration-code.yml b/.github/workflows/continuous-integration-code.yml deleted file mode 100644 index 866b12d5..00000000 --- a/.github/workflows/continuous-integration-code.yml +++ /dev/null @@ -1,94 +0,0 @@ -name: Continuous Integration (code) - -on: - push: - paths-ignore: - - 'bin/**' - - 'docs/**' - pull_request: - paths-ignore: - - 'bin/**' - - 'docs/**' - -jobs: - tests: - name: Tests - - runs-on: ubuntu-latest - - strategy: - matrix: - php-version: - - "8.5" - - steps: - - name: Checkout - uses: actions/checkout@v6 - - - name: Install PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php-version }} - coverage: none - - - name: Install Dependencies - run: composer install --prefer-dist ${{ matrix.composer-extra-arguments }} - - - name: Run Unit Tests - run: ./vendor/bin/phpunit --testsuite=unit - - - name: Run Integration Tests - run: ./vendor/bin/pest --testsuite=feature --compact - - code-coverage: - name: Code coverage - - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v6 - - - name: Install PHP - uses: shivammathur/setup-php@v2 - with: - php-version: 8.5 - coverage: pcov - - - name: Install Dependencies - run: composer install --prefer-dist ${{ matrix.composer-extra-arguments }} - - - name: Generating Code Coverage Report - run: ./vendor/bin/pest --compact --coverage-clover=coverage.xml - - - name: Send Code Coverage Report to Codecov.io - uses: codecov/codecov-action@v5 - with: - token: ${{ secrets.CODECOV_TOKEN }} - - static-analysis: - name: Static Analysis - - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v6 - - - name: Install PHP - uses: shivammathur/setup-php@v2 - with: - php-version: 8.5 - coverage: none - - - name: Install dependencies - run: composer install --prefer-dist - - - name: Run PHP_CodeSniffer - run: vendor/bin/phpcs - - - name: Run PHPStan - run: vendor/bin/phpstan analyze - - - name: Run Validator's mixin linter - run: bin/console lint:mixin diff --git a/.github/workflows/continuous-integration-docs.yml b/.github/workflows/continuous-integration-docs.yml deleted file mode 100644 index b98424ec..00000000 --- a/.github/workflows/continuous-integration-docs.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Continuous Integration (docs) - -on: - push: - paths-ignore: - - 'data/**' - - 'tests/**' - pull_request: - paths-ignore: - - 'data/**' - - 'tests/**' - -jobs: - docs: - name: Documentation - - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v6 - - - name: Install PHP - uses: shivammathur/setup-php@v2 - with: - php-version: 8.5 - coverage: none - - - name: Install dependencies - run: composer install --prefer-dist - - - name: Lint documentation files - run: bin/console lint:docs diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2a472328..dc0a4792 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,8 +6,7 @@ jobs: build: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v6 + - uses: actions/checkout@v6 - name: Release uses: softprops/action-gh-release@v2 if: github.ref_type == 'tag' \ No newline at end of file diff --git a/.github/workflows/reuse.yml b/.github/workflows/reuse.yml index 00258ca8..721fb748 100644 --- a/.github/workflows/reuse.yml +++ b/.github/workflows/reuse.yml @@ -13,28 +13,11 @@ jobs: name: Compliance Check runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v6 - - - name: Set up Python - uses: actions/setup-python@v6 + - uses: actions/checkout@v6 + - uses: ./.github/actions/setup-action with: python-version: '3.x' + python-deps: reuse - - name: Install PHP - uses: shivammathur/setup-php@v2 - with: - php-version: 8.5 - coverage: none - - - name: Install dependencies - run: composer install --prefer-dist - - - name: Install REUSE tool - run: pip install reuse - - - name: Run REUSE check - run: reuse lint - - - name: Run SPDX conventions check - run: bin/console lint:spdx + - run: reuse lint + - run: bin/console lint:spdx diff --git a/REUSE.toml b/REUSE.toml index e6de1abf..f046559d 100644 --- a/REUSE.toml +++ b/REUSE.toml @@ -1,6 +1,6 @@ version = 1 [[annotations]] -path = [ "*.yml", "*.yaml", ".git*", "*.dist", "docs/.pages", "docs/validators/.pages", "composer.json", "tests/fixtures/*", ".github/*.yml", ".github/workflows/**.yml", ".github/PULL_REQUEST_TEMPLATE.md", ".github/ISSUE_TEMPLATE/**" ] +path = [ "*.yml", "*.yaml", ".git*", "*.dist", "docs/.pages", "docs/validators/.pages", "composer.json", "tests/fixtures/*", ".github/*.yml", ".github/actions/**.yml", ".github/workflows/**.yml", ".github/PULL_REQUEST_TEMPLATE.md", ".github/ISSUE_TEMPLATE/**" ] SPDX-FileCopyrightText = "Respect Project Contributors" SPDX-License-Identifier = "MIT"