-
Notifications
You must be signed in to change notification settings - Fork 2
47 lines (39 loc) · 1.38 KB
/
phpunit.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
name: PHPUnit Tests
on:
push:
branches:
- '*'
pull_request:
branches: [ main ]
permissions:
contents: read
pull-requests: write
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
- name: Install dependencies
run: composer install --prefer-dist --no-progress
- name: Run PHPUnit tests
run: vendor/bin/phpunit --testdox --colors=always > phpunit-results.txt
- name: Post PHPUnit results as PR comment
if: github.event_name == 'pull_request'
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const fs = require('fs');
const phpunitOutput = fs.readFileSync('phpunit-results.txt', 'utf8');
const summary = phpunitOutput.split('\n').slice(0, 10).join('\n'); // Get first 10 lines for summary
const fullReport = '## PHPUnit Test Results\n\n<details><summary>Click to expand full report</summary>\n\n```\n' + phpunitOutput + '\n```\n</details>';
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '## PHPUnit Test Summary\n\n```\n' + summary + '\n```\n\n' + fullReport
});