Skip to content

Commit f00ae61

Browse files
committed
ci
1 parent b0b256e commit f00ae61

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Unit Tests
2+
3+
on:
4+
push:
5+
paths-ignore:
6+
- 'src/*/doc/**'
7+
- 'src/**/*.md'
8+
pull_request:
9+
paths-ignore:
10+
- 'src/*/doc/**'
11+
- 'src/**/*.md'
12+
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
15+
cancel-in-progress: true
16+
17+
env:
18+
REQUIRED_PHP_EXTENSIONS: 'mongodb'
19+
20+
jobs:
21+
php:
22+
runs-on: ubuntu-latest
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
php-version: ['8.2', '8.3', '8.4']
27+
dependency-version: ['']
28+
symfony-version: ['']
29+
include:
30+
# lowest deps
31+
- php-version: '8.2'
32+
dependency-version: 'lowest'
33+
# LTS version of Symfony
34+
- php-version: '8.2'
35+
symfony-version: '6.4.*'
36+
37+
env:
38+
SYMFONY_REQUIRE: ${{ matrix.symfony-version || '>=6.4' }}
39+
40+
steps:
41+
- uses: actions/checkout@v4
42+
43+
- name: Configure environment
44+
run: |
45+
echo COLUMNS=120 >> $GITHUB_ENV
46+
echo COMPOSER_UP='composer update ${{ matrix.dependency-version == 'lowest' && '--prefer-lowest --prefer-stable' || '' }} --no-progress --no-interaction --ansi --ignore-platform-req=ext-mongodb' >> $GITHUB_ENV
47+
echo PHPUNIT='vendor/bin/phpunit' >> $GITHUB_ENV
48+
[ 'lowest' = '${{ matrix.dependency-version }}' ] && export SYMFONY_DEPRECATIONS_HELPER=weak
49+
50+
PACKAGES=$(find src/ -mindepth 2 -type f -name composer.json -not -path "*/vendor/*" -printf '%h\n' | sed 's/^src\///' | grep -Ev "examples" | sort | tr '\n' ' ')
51+
echo "Packages: $PACKAGES"
52+
echo "PACKAGES=$PACKAGES" >> $GITHUB_ENV
53+
54+
- name: Setup PHP
55+
uses: shivammathur/setup-php@v2
56+
with:
57+
php-version: ${{ matrix.php-version }}
58+
tools: flex
59+
extensions: "${{ env.REQUIRED_PHP_EXTENSIONS }}"
60+
61+
- name: Get composer cache directory
62+
id: composer-cache
63+
run: |
64+
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
65+
66+
- name: Cache packages dependencies
67+
uses: actions/cache@v4
68+
with:
69+
path: ${{ steps.composer-cache.outputs.dir }}
70+
key: ${{ runner.os }}-composer-packages-${{ matrix.php-version }}-${{ matrix.dependency-version }}-${{ matrix.symfony-version }}-${{ hashFiles('src/**/composer.json') }}
71+
restore-keys: |
72+
${{ runner.os }}-composer-packages-${{ matrix.php-version }}-${{ matrix.dependency-version }}-${{ matrix.symfony-version }}
73+
74+
- name: Install root dependencies
75+
uses: ramsey/composer-install@v3
76+
77+
- name: Build root packages
78+
run: php .github/build-packages.php
79+
80+
- name: Run packages tests
81+
run: |
82+
source .github/workflows/.utils.sh
83+
84+
echo "$PACKAGES" | xargs -n1 | parallel -j +3 "_run_task {} '(cd src/{} && $COMPOSER_UP && $PHPUNIT)'"

0 commit comments

Comments
 (0)