-
-
Notifications
You must be signed in to change notification settings - Fork 56
chore: split unit tests from the main CI workflow and report combined coverage to Coveralls #425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
90441cd
chore: split unit tests from the main CI workflow and report combined…
martin-georgiev 4a1ce29
no message
martin-georgiev c38de96
no message
martin-georgiev 432d7e3
Update .github/workflows/coverage.yml
martin-georgiev 887da00
no message
martin-georgiev 9827dd3
no message
martin-georgiev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| name: Coverage | ||
|
|
||
| on: | ||
| workflow_run: | ||
| workflows: ["Integration Tests", "Unit Tests"] | ||
| types: [completed] | ||
|
|
||
| jobs: | ||
| finalize: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| const workflows = await github.rest.actions.listWorkflowRunsForRepo({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| head_sha: context.payload.workflow_run.head_sha, | ||
| status: 'completed' | ||
| }); | ||
|
|
||
| const bothComplete = ['Integration Tests', 'Unit Tests'].every(name => | ||
| workflows.data.workflow_runs.some(run => run.name === name) | ||
| ); | ||
|
|
||
| if (!bothComplete) { | ||
| core.info('Waiting for other workflow to complete'); | ||
| process.exit(0); | ||
| } | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| - uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b | ||
| with: | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||
| parallel-finished: true | ||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| name: Unit Tests | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| paths-ignore: | ||
| - '.github/actions/release-please/**' | ||
| pull_request: | ||
| branches: | ||
| - main | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| should-run: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| run: ${{ steps.check.outputs.run }} | ||
| steps: | ||
| - name: Skip for release-please | ||
| id: check | ||
| run: | | ||
| if [ "${{ github.event.pull_request.user.id }}" = "41898282" ]; then | ||
| echo "run=false" >> $GITHUB_OUTPUT | ||
| echo "::notice::Skipping unit tests - this a release-please bot's interaction" | ||
| else | ||
| echo "run=true" >> $GITHUB_OUTPUT | ||
| echo "::notice::Unit tests will execute - the actor is not the release-please bot" | ||
| fi | ||
| unit-tests: | ||
| needs: should-run | ||
| if: needs.should-run.outputs.run == 'true' | ||
| runs-on: ubuntu-latest | ||
| name: "PHP ${{ matrix.php }} + Doctrine ORM ${{ matrix.doctrine-orm }} + Doctrine Lexer ${{ matrix.doctrine-lexer }}" | ||
|
|
||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| php: ['8.1', '8.2', '8.3', '8.4'] | ||
| doctrine-lexer: ['2.1', '3.0', 'latest'] | ||
| doctrine-orm: ['2.14', '2.18', '3.0', 'latest'] | ||
| include: | ||
| - php: '8.1' | ||
| doctrine-orm: '2.14' | ||
| doctrine-lexer: '1.2' | ||
| - php: '8.4' # Run coverage report only based on the latest dependencies | ||
| doctrine-lexer: 'latest' | ||
| doctrine-orm: 'latest' | ||
| calculate-code-coverage: true | ||
| exclude: | ||
| - doctrine-orm: '2.14' | ||
| doctrine-lexer: '3.0' | ||
| - doctrine-orm: '3.0' | ||
| doctrine-lexer: '2.1' | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4 | ||
|
|
||
| - name: Set up PHP with PECL extension | ||
| uses: shivammathur/setup-php@20529878ed81ef8e78ddf08b480401e6101a850f # v2 | ||
| with: | ||
| php-version: ${{ matrix.php }} | ||
| coverage: xdebug | ||
| extensions: ctype, json, mbstring | ||
| tools: composer | ||
|
|
||
| - name: Cache Composer packages | ||
| id: composer-cache | ||
| uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4 | ||
| with: | ||
| path: vendor | ||
| key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-php- | ||
| - name: Install Doctrine Lexer dependency | ||
| run: | | ||
| if [ "${{ matrix.doctrine-lexer }}" = "1.2" ]; then | ||
| composer require doctrine/lexer "~1.2" --dev --prefer-dist --no-interaction --no-progress | ||
| elif [ "${{ matrix.doctrine-lexer }}" = "2.1" ]; then | ||
| composer require doctrine/lexer "~2.1" --dev --prefer-dist --no-interaction --no-progress | ||
| elif [ "${{ matrix.doctrine-lexer }}" = "3.0" ]; then | ||
| composer require doctrine/lexer "~3.0" --dev --prefer-dist --no-interaction --no-progress | ||
| else | ||
| composer update --prefer-dist --no-interaction --no-progress | ||
| fi | ||
| - name: Install Doctrine ORM dependency | ||
| run: | | ||
| if [ "${{ matrix.doctrine-orm }}" = "2.14" ]; then | ||
| composer require doctrine/orm "~2.14" --prefer-dist --no-interaction --no-progress --with-all-dependencies | ||
| elif [ "${{ matrix.doctrine-orm }}" = "2.18" ]; then | ||
| composer require doctrine/orm "~2.18" --prefer-dist --no-interaction --no-progress --with-all-dependencies | ||
| elif [ "${{ matrix.doctrine-orm }}" = "3.0" ]; then | ||
| composer require doctrine/orm "~3.0" --prefer-dist --no-interaction --no-progress --with-all-dependencies | ||
| else | ||
| composer update --prefer-dist --no-interaction --no-progress | ||
| fi | ||
| - name: Run static analysis | ||
| run: composer run-static-analysis | ||
| continue-on-error: ${{ matrix.continue-on-error || false }} | ||
|
|
||
| - name: Run unit test suite | ||
| run: composer run-unit-tests | ||
|
|
||
| - name: Upload coverage results to Coveralls | ||
| if: matrix.calculate-code-coverage == true | ||
| uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b # v2 | ||
| with: | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||
| file: ./var/logs/test-coverage/unit/clover.xml | ||
| parallel: true | ||
| flag-name: "Unit" | ||
| fail-on-error: false |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.