1+ ---
2+
3+ name : 🧪 Unit testing
4+
5+ on : # yamllint disable-line rule:truthy
6+ pull_request :
7+ branches :
8+ - main
9+ push :
10+ branches :
11+ - main
12+
13+ jobs :
14+ code-coverage :
15+ timeout-minutes : 4
16+ runs-on : ${{ matrix.os }}
17+ concurrency :
18+ cancel-in-progress : true
19+ group : code-coverage-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-${{ matrix.php-version }}-${{ matrix.dependencies }}
20+ strategy :
21+ fail-fast : true
22+ matrix :
23+ os :
24+ - ubuntu-latest
25+ php-version :
26+ - ' 8.2'
27+ dependencies :
28+ - locked
29+ steps :
30+ - name : 📦 Check out the codebase
31+ uses : actions/checkout@v4
32+
33+ - name : 🛠️ Setup PHP
34+ uses :
shivammathur/[email protected] 35+ with :
36+ php-version : ${{ matrix.php-version }}
37+ extensions : none, ctype, curl, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter, sockets, opcache, pcntl, posix
38+ ini-values : error_reporting=E_ALL
39+ coverage : xdebug
40+
41+ - name : 🛠️ Setup problem matchers
42+ run : |
43+ echo "::add-matcher::${{ runner.tool_cache }}/php.json"
44+ echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
45+
46+ - name : 🤖 Validate composer.json and composer.lock
47+ run : composer validate --ansi --strict
48+
49+ - name : 🔍 Get composer cache directory
50+ uses :
wayofdev/gh-actions/actions/composer/[email protected] 51+
52+ - name : ♻️ Restore cached dependencies installed with composer
53+ uses : actions/cache@v4
54+ with :
55+ path : ${{ env.COMPOSER_CACHE_DIR }}
56+ key : php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}
57+ restore-keys : php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-
58+
59+ - name : 📥 Install "${{ matrix.dependencies }}" dependencies
60+ uses :
wayofdev/gh-actions/actions/composer/[email protected] 61+ with :
62+ dependencies : ${{ matrix.dependencies }}
63+
64+ - name : 🧪 Collect code coverage with Xdebug and pestphp/pest
65+ run : composer test:cc
66+
67+ - name : 📤 Upload code coverage report to Codecov
68+ 69+ with :
70+ files : .build/phpunit/logs/clover.xml
71+ token : ${{ secrets.CODECOV_TOKEN }}
72+ verbose : true
73+
74+ testing :
75+ timeout-minutes : 4
76+ runs-on : ${{ matrix.os }}
77+ concurrency :
78+ cancel-in-progress : true
79+ group : testing-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-${{ matrix.php-version }}-${{ matrix.dependencies }}
80+ strategy :
81+ fail-fast : true
82+ matrix :
83+ os :
84+ - ubuntu-latest
85+ php-version :
86+ - ' 8.1'
87+ - ' 8.2'
88+ - ' 8.3'
89+ dependencies :
90+ - lowest
91+ - locked
92+ - highest
93+ include :
94+ - php-version : ' 8.4'
95+ dependencies : highest
96+ steps :
97+ - name : 📦 Check out the codebase
98+ uses : actions/checkout@v4
99+
100+ - name : 🛠️ Setup PHP
101+ uses :
shivammathur/[email protected] 102+ with :
103+ php-version : ${{ matrix.php-version }}
104+ extensions : none, ctype, curl, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter, sockets, opcache, pcntl, posix
105+ ini-values : error_reporting=E_ALL
106+ coverage : xdebug
107+
108+ - name : 🛠️ Setup problem matchers
109+ run : |
110+ echo "::add-matcher::${{ runner.tool_cache }}/php.json"
111+ echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
112+
113+ - name : 🤖 Validate composer.json and composer.lock
114+ run : composer validate --ansi --strict
115+
116+ - name : 🔍 Get composer cache directory
117+ uses :
wayofdev/gh-actions/actions/composer/[email protected] 118+
119+ - name : ♻️ Restore cached dependencies installed with composer
120+ uses : actions/cache@v4
121+ with :
122+ path : ${{ env.COMPOSER_CACHE_DIR }}
123+ key : php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}
124+ restore-keys : php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-
125+
126+ - name : ⚙️ Remove platform configuration with composer
127+ if : matrix.dependencies != 'locked'
128+ run : composer config platform.php --ansi --unset
129+
130+ - name : 📥 Install "${{ matrix.dependencies }}" dependencies
131+ uses :
wayofdev/gh-actions/actions/composer/[email protected] 132+ with :
133+ dependencies : ${{ matrix.dependencies }}
134+
135+ - name : 🧪 Run unit tests using phpunit/phpunit
136+ run : composer test
0 commit comments