[changelog] Fix Dependabot fallback branch validation (#191) #542
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Run PHPUnit Tests | |
| on: | |
| workflow_call: | |
| inputs: | |
| min-coverage: | |
| description: Minimum line coverage percentage enforced by dev-tools tests. | |
| required: false | |
| type: number | |
| default: 80 | |
| max-outdated: | |
| description: Maximum number of outdated packages allowed by the dependencies command. | |
| required: false | |
| type: number | |
| default: -1 | |
| workflow_dispatch: | |
| inputs: | |
| min-coverage: | |
| description: Minimum line coverage percentage enforced by dev-tools tests. | |
| required: false | |
| type: number | |
| default: 80 | |
| max-outdated: | |
| description: Maximum number of outdated packages allowed by the dependencies command. | |
| required: false | |
| type: number | |
| default: -1 | |
| pull_request: | |
| paths: | |
| - 'src/**' | |
| - 'tests/**' | |
| - 'composer.json' | |
| - 'composer.lock' | |
| - '.github/actions/**' | |
| - '.github/workflows/tests.yml' | |
| push: | |
| branches: [ "main" ] | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: ${{ github.event_name == 'pull_request' && format('tests-pr-{0}', github.event.pull_request.number) || format('tests-{0}', github.ref) }} | |
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | |
| env: | |
| FORCE_COLOR: '1' | |
| jobs: | |
| resolve_php: | |
| name: Resolve PHP Version | |
| runs-on: ubuntu-latest | |
| outputs: | |
| php-version: ${{ steps.resolve.outputs.php-version }} | |
| php-version-source: ${{ steps.resolve.outputs.php-version-source }} | |
| test-matrix: ${{ steps.resolve.outputs.test-matrix }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Checkout dev-tools workflow action source | |
| uses: actions/checkout@v6 | |
| with: | |
| repository: php-fast-forward/dev-tools | |
| ref: ${{ github.repository == 'php-fast-forward/dev-tools' && (github.event_name == 'pull_request_target' && github.event.pull_request.base.sha || github.sha) || 'main' }} | |
| path: .dev-tools-actions | |
| sparse-checkout: | | |
| .github/actions | |
| - name: Resolve workflow PHP version | |
| id: resolve | |
| uses: ./.dev-tools-actions/.github/actions/php/resolve-version | |
| tests: | |
| needs: resolve_php | |
| name: Run Tests | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: ${{ fromJson(needs.resolve_php.outputs.test-matrix) }} | |
| env: | |
| TESTS_ROOT_VERSION: ${{ github.event_name == 'pull_request' && format('dev-{0}', github.event.pull_request.head.ref) || 'dev-main' }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Checkout dev-tools workflow action source | |
| uses: actions/checkout@v6 | |
| with: | |
| repository: php-fast-forward/dev-tools | |
| ref: ${{ github.repository == 'php-fast-forward/dev-tools' && (github.event_name == 'pull_request_target' && github.event.pull_request.base.sha || github.sha) || 'main' }} | |
| path: .dev-tools-actions | |
| sparse-checkout: | | |
| .github/actions | |
| - name: Setup PHP and install dependencies | |
| uses: ./.dev-tools-actions/.github/actions/php/setup-composer | |
| with: | |
| php-version: ${{ matrix.php-version }} | |
| extensions: pcov, pcntl | |
| coverage: pcov | |
| root-version: ${{ env.TESTS_ROOT_VERSION }} | |
| install-options: --prefer-dist --no-progress --no-interaction --no-plugins --no-scripts | |
| - name: Composer Audit | |
| env: | |
| COMPOSER_ROOT_VERSION: ${{ env.TESTS_ROOT_VERSION }} | |
| run: composer audit | |
| - name: Resolve minimum coverage | |
| id: minimum-coverage | |
| run: echo "value=${INPUT_MIN_COVERAGE:-80}" >> "$GITHUB_OUTPUT" | |
| env: | |
| INPUT_MIN_COVERAGE: ${{ inputs.min-coverage }} | |
| - name: Run PHPUnit tests | |
| env: | |
| COMPOSER_ROOT_VERSION: ${{ env.TESTS_ROOT_VERSION }} | |
| run: composer dev-tools tests -- --coverage=.dev-tools/coverage --min-coverage=${{ steps.minimum-coverage.outputs.value }} | |
| dependency-health: | |
| needs: resolve_php | |
| name: Dependency Health | |
| runs-on: ubuntu-latest | |
| env: | |
| TESTS_ROOT_VERSION: ${{ github.event_name == 'pull_request' && format('dev-{0}', github.event.pull_request.head.ref) || 'dev-main' }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Checkout dev-tools workflow action source | |
| uses: actions/checkout@v6 | |
| with: | |
| repository: php-fast-forward/dev-tools | |
| ref: ${{ github.repository == 'php-fast-forward/dev-tools' && (github.event_name == 'pull_request_target' && github.event.pull_request.base.sha || github.sha) || 'main' }} | |
| path: .dev-tools-actions | |
| sparse-checkout: | | |
| .github/actions | |
| - name: Setup PHP and install dependencies | |
| uses: ./.dev-tools-actions/.github/actions/php/setup-composer | |
| with: | |
| php-version: ${{ needs.resolve_php.outputs.php-version }} | |
| root-version: ${{ env.TESTS_ROOT_VERSION }} | |
| install-options: --prefer-dist --no-progress --no-interaction --no-plugins --no-scripts | |
| - name: Run dependency health check | |
| env: | |
| COMPOSER_ROOT_VERSION: ${{ env.TESTS_ROOT_VERSION }} | |
| run: composer dev-tools dependencies -- --max-outdated=${{ inputs.max-outdated || -1 }} | |
| summarize: | |
| if: ${{ always() }} | |
| name: Summarize Test Workflow | |
| needs: | |
| - resolve_php | |
| - tests | |
| - dependency-health | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Checkout dev-tools workflow action source | |
| uses: actions/checkout@v6 | |
| with: | |
| repository: php-fast-forward/dev-tools | |
| ref: ${{ github.repository == 'php-fast-forward/dev-tools' && (github.event_name == 'pull_request_target' && github.event.pull_request.base.sha || github.sha) || 'main' }} | |
| path: .dev-tools-actions | |
| sparse-checkout: | | |
| .github/actions | |
| - uses: ./.dev-tools-actions/.github/actions/summary/write | |
| with: | |
| markdown: | | |
| ## Tests Workflow Summary | |
| - Workflow PHP version: `${{ needs.resolve_php.outputs.php-version }}` | |
| - PHP version source: `${{ needs.resolve_php.outputs.php-version-source }}` | |
| - Test matrix: `${{ needs.resolve_php.outputs.test-matrix }}` | |
| - Minimum coverage threshold: `${{ inputs.min-coverage || 80 }}` | |
| - Dependency health `max-outdated`: `${{ inputs.max-outdated || -1 }}` | |
| - Tests job result: `${{ needs.tests.result }}` | |
| - Dependency health result: `${{ needs.dependency-health.result }}` |