Skip to content

Commit cdff51e

Browse files
authored
Merge pull request #172 from phalcon/T168-phpunit
T168 phpunit
2 parents 7edfba7 + e0c6d03 commit cdff51e

126 files changed

Lines changed: 14686 additions & 3395 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.codacy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ exclude_paths:
33
- 'CHANGELOG.md'
44
- '.github/**'
55
- 'tests/_data/**'
6-
- 'tests/_support/**'
6+
- 'tests/support/**'

.github/workflows/main.yml

Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
name: "Tests"
2+
3+
on:
4+
push:
5+
paths-ignore:
6+
- '**.md'
7+
- '**.txt'
8+
pull_request:
9+
workflow_dispatch:
10+
11+
env:
12+
EXTENSIONS: mbstring, intl, json, pdo_mysql, pdo_pgsql
13+
COMPOSER_NO_INTERACTION: 1
14+
COMPOSER_NO_AUDIT: 1
15+
16+
permissions: {}
17+
18+
concurrency:
19+
group: ${{ github.workflow }}-${{ github.ref }}
20+
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
21+
22+
jobs:
23+
phpcs:
24+
name: "Code style and static analysis - PHP ${{ matrix.php }}"
25+
26+
permissions:
27+
contents: read
28+
29+
runs-on: ubuntu-latest
30+
31+
strategy:
32+
fail-fast: true
33+
matrix:
34+
php:
35+
- '8.2'
36+
- '8.3'
37+
- '8.4'
38+
- '8.5'
39+
40+
steps:
41+
- uses: actions/checkout@v6
42+
43+
- name: "Cache extensions"
44+
uses: shivammathur/cache-extensions@v1
45+
id: cache-ext
46+
with:
47+
php-version: ${{ matrix.php }}
48+
extensions: ${{ env.EXTENSIONS }}
49+
key: ext-cache-v1
50+
51+
- name: "Restore extensions"
52+
uses: actions/cache@v4
53+
with:
54+
path: ${{ steps.cache-ext.outputs.dir }}
55+
key: ${{ steps.cache-ext.outputs.key }}
56+
restore-keys: ${{ steps.cache-ext.outputs.key }}
57+
58+
- name: "Setup PHP"
59+
uses: shivammathur/setup-php@v2
60+
with:
61+
php-version: ${{ matrix.php }}
62+
extensions: ${{ env.EXTENSIONS }}
63+
tools: composer:v2
64+
coverage: none
65+
env:
66+
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67+
68+
- name: "Validate composer"
69+
run: composer validate --no-check-all --no-check-publish
70+
71+
- name: "Install dependencies"
72+
uses: ramsey/composer-install@v4
73+
with:
74+
composer-options: "--prefer-dist"
75+
76+
- name: "PHPCS"
77+
run: composer cs
78+
79+
- name: "PHPStan"
80+
run: composer analyze
81+
82+
- name: "Psalm"
83+
run: composer analyze-psalm
84+
85+
run-tests:
86+
name: "PHP ${{ matrix.php-versions }}"
87+
88+
permissions:
89+
contents: read
90+
91+
runs-on: ubuntu-latest
92+
93+
needs:
94+
- phpcs
95+
96+
services:
97+
mysql:
98+
image: mysql:8.0
99+
env:
100+
MYSQL_DATABASE: phalcon-migrations
101+
MYSQL_ROOT_PASSWORD: root
102+
ports:
103+
- "3306:3306"
104+
options: >-
105+
--health-cmd "mysqladmin ping --silent"
106+
--health-interval 10s
107+
--health-timeout 5s
108+
--health-retries 5
109+
postgres:
110+
image: postgres:14-alpine
111+
env:
112+
POSTGRES_PASSWORD: postgres
113+
ports:
114+
- "5432:5432"
115+
options: >-
116+
--health-cmd pg_isready
117+
--health-interval 5s
118+
--health-timeout 5s
119+
--health-retries 5
120+
121+
strategy:
122+
fail-fast: false
123+
matrix:
124+
php-versions:
125+
- '8.2'
126+
- '8.3'
127+
- '8.4'
128+
- '8.5'
129+
130+
steps:
131+
- uses: actions/checkout@v6
132+
133+
- name: "Cache extensions"
134+
uses: shivammathur/cache-extensions@v1
135+
id: cache-ext
136+
with:
137+
php-version: ${{ matrix.php-versions }}
138+
extensions: ${{ env.EXTENSIONS }}
139+
key: ext-cache-v1
140+
141+
- name: "Restore extensions"
142+
uses: actions/cache@v4
143+
with:
144+
path: ${{ steps.cache-ext.outputs.dir }}
145+
key: ${{ steps.cache-ext.outputs.key }}
146+
restore-keys: ${{ steps.cache-ext.outputs.key }}
147+
148+
- name: "Setup PHP"
149+
uses: shivammathur/setup-php@v2
150+
with:
151+
php-version: ${{ matrix.php-versions }}
152+
extensions: ${{ env.EXTENSIONS }}
153+
tools: composer:v2
154+
coverage: xdebug
155+
env:
156+
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
157+
158+
- name: "Validate composer"
159+
run: composer validate --no-check-all --no-check-publish
160+
161+
- name: "Install dependencies"
162+
uses: ramsey/composer-install@v4
163+
with:
164+
composer-options: "--prefer-dist"
165+
166+
- name: "Copy .env file"
167+
run: cp config/.env.example tests/.env
168+
169+
- name: "Run test suites"
170+
run: composer test-coverage
171+
172+
- name: "Upload coverage file artifact"
173+
uses: actions/upload-artifact@v4
174+
with:
175+
name: "coverage-${{ matrix.php-versions }}"
176+
path: "tests/_output/coverage/clover.xml"
177+
178+
upload-coverage:
179+
name: "Upload coverage"
180+
181+
permissions:
182+
contents: read
183+
184+
runs-on: ubuntu-latest
185+
186+
needs:
187+
- run-tests
188+
189+
steps:
190+
- uses: actions/checkout@v6
191+
192+
- name: "Download coverage artifacts"
193+
uses: actions/download-artifact@v4
194+
with:
195+
path: coverage
196+
197+
- name: "List coverage files"
198+
run: ls -la coverage/
199+
200+
- name: "Upload coverage to Codecov"
201+
uses: codecov/codecov-action@v6
202+
with:
203+
token: ${{ secrets.CODECOV_TOKEN }}
204+
files: >-
205+
coverage/coverage-8.2/clover.xml,
206+
coverage/coverage-8.3/clover.xml,
207+
coverage/coverage-8.4/clover.xml,
208+
coverage/coverage-8.5/clover.xml
209+
fail_ci_if_error: false

.github/workflows/tests.yml

Lines changed: 0 additions & 89 deletions
This file was deleted.

.github/workflows/validations.yml

Lines changed: 0 additions & 89 deletions
This file was deleted.

0 commit comments

Comments
 (0)