-
Notifications
You must be signed in to change notification settings - Fork 10
155 lines (155 loc) · 5.53 KB
/
test.yml
File metadata and controls
155 lines (155 loc) · 5.53 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
name: Application tests
on:
pull_request:
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true
permissions:
contents: read
pull-requests: write
env:
PHP_EXTENSIONS: mbstring, xml, ctype, iconv, intl, mysql
DATABASE_URL: mysql://root:symfony@127.0.0.1:3306/symfony
REDIS_HOST: localhost
APP_ENV: test
jobs:
build:
name: Build dependencies
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # v2
with:
php-version: "8.4"
extensions: ${{ env.PHP_EXTENSIONS }}
coverage: xdebug
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
with:
path: |
${{ steps.composer-cache.outputs.dir }}
assets/vendor/
key: ${{ runner.os }}-cache-${{ hashFiles('**/composer.lock') }}-${{ hashFiles('**/importmap.php') }}
restore-keys: |
${{ runner.os }}-cache-
- name: Prepare build artifact
run: |
composer install --no-progress -a
composer run create-tls
bin/console asset-map:compile
- name: Create build artifacts archive
run: |
tar -czf build-artifacts.tar.gz assets/vendor/ tls/ var/ vendor/
- name: Upload build artifacts
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: build-artifacts
path: build-artifacts.tar.gz
retention-days: 1
static-analysis:
name: Static code analysis
runs-on: ubuntu-latest
needs: build
strategy:
fail-fast: false
matrix:
php-versions:
- "8.4"
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # v2
with:
php-version: ${{ matrix.php-versions }}
extensions: ${{ env.PHP_EXTENSIONS }}
coverage: xdebug
- name: Download build artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: build-artifacts
path: .
- name: Extract build artifacts
run: tar -xzf build-artifacts.tar.gz
- name: Cleanup archive
run: rm build-artifacts.tar.gz
- name: PHP CS Fixer
run: vendor/bin/php-cs-fixer check --diff
- name: rector
run: vendor/bin/rector process src/ --dry-run
- name: PHPStan
run: composer run phpstan
phpunit:
name: PHPUnit (PHP ${{ matrix.php-versions }})
runs-on: ubuntu-latest
needs: build
services:
mysql:
image: mysql:lts@sha256:2952e3be7807f06fc18de50b3ea1a632d5c70d63482ff7d7376fe3aa8999babf
env:
MYSQL_ALLOW_EMPTY_PASSWORD: false
MYSQL_ROOT_PASSWORD: symfony
MYSQL_DATABASE: symfony
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
redis:
image: redis@sha256:1f073813b641755b70b0200da64131bbeeb4ec5b633ca67772229b49820caafa
ports:
- 6379:6379
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3
strategy:
fail-fast: false
matrix:
php-versions:
- "8.4"
- "8.5"
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # v2
with:
php-version: ${{ matrix.php-versions }}
extensions: ${{ env.PHP_EXTENSIONS }}
coverage: xdebug
- name: Download build artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: build-artifacts
path: .
- name: Extract build artifacts
run: tar -xzf build-artifacts.tar.gz
- name: Cleanup archive
run: rm build-artifacts.tar.gz
- name: Prepare database
run: |
bin/console doctrine:schema:create
bin/console domain:add example.com
bin/console user:add --password=changeme --admin --enable admin example.com
bin/console dkim:setup --enable --selector dkim example.com
- name: Run tests
run: php -d xdebug.mode=coverage vendor/bin/phpunit --coverage-cobertura=coverage.xml
- name: Create code coverage report
if: ${{ matrix.php-versions == '8.4' }}
uses: irongut/CodeCoverageSummary@51cc3a756ddcd398d447c044c02cb6aa83fdae95 # v1.3.0
with:
filename: coverage.xml
badge: true
fail_below_min: true
format: markdown
hide_branch_rate: false
indicators: true
output: both
thresholds: '60 80'
- name: Add Coverage PR Comment
if: ${{ matrix.php-versions == '8.4' }}
uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 # v2
with:
recreate: true
path: code-coverage-results.md