|
5 | 5 | paths-ignore: |
6 | 6 | - '**.md' |
7 | 7 | pull_request: |
| 8 | + paths-ignore: |
| 9 | + - '**.md' |
8 | 10 | workflow_dispatch: |
9 | 11 |
|
10 | 12 | env: |
11 | | - COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --prefer-dist --no-plugins" |
12 | | - COMPOSER_UPDATE_FLAGS: "" |
13 | | - script: demo/run.php |
| 13 | + COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --prefer-dist" |
| 14 | + SCRIPT_PATH: "demo/run.php" |
14 | 15 |
|
15 | 16 | jobs: |
16 | 17 | phpunit: |
17 | | - name: PHPUnit |
18 | | - runs-on: ubuntu-latest |
19 | | - services: |
20 | | - redis: |
21 | | - image: redis |
22 | | - ports: |
23 | | - - 6379:6379 |
24 | | - options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3 |
| 18 | + name: PHPUnit (${{ matrix.os }} - PHP ${{ matrix.php }} - ${{ matrix.dependencies }}) |
| 19 | + runs-on: ${{ matrix.os }} |
25 | 20 | strategy: |
26 | 21 | matrix: |
27 | | - php-version: [8.2, 8.3, 8.4] |
| 22 | + php: [8.1, 8.2, 8.3, 8.4] |
28 | 23 | dependencies: [highest, lowest] |
29 | | - os: [ubuntu-latest] |
30 | | - include: |
31 | | - - php-version: 8.1 |
32 | | - os: windows-latest |
33 | | - - php-version: 8.1 |
34 | | - os: macos-latest |
35 | | - - php-version: 8.2 |
36 | | - dependencies: lowest |
37 | | - os: ubuntu-latest |
38 | | - - php-version: 8.2 |
39 | | - dependencies: highest |
| 24 | + os: [ubuntu-latest, windows-latest, macos-latest] |
| 25 | + exclude: |
| 26 | + - php: 8.1 |
40 | 27 | os: ubuntu-latest |
41 | | - - php-version: 8.3 |
42 | | - dependencies: highest |
43 | | - os: ubuntu-latest |
44 | | - - php-version: 8.3 |
| 28 | + - php: 8.1 |
45 | 29 | dependencies: lowest |
46 | | - os: ubuntu-latest |
47 | | - - php-version: 8.4 |
48 | | - dependencies: highest |
49 | | - os: ubuntu-latest |
50 | | - - php-version: 8.4 |
| 30 | + os: windows-latest |
| 31 | + - php: 8.1 |
51 | 32 | dependencies: lowest |
| 33 | + os: macos-latest |
| 34 | + include: |
| 35 | + - php: 8.4 |
52 | 36 | os: ubuntu-latest |
| 37 | + experimental: true |
| 38 | + |
| 39 | + services: |
| 40 | + redis: |
| 41 | + image: redis |
| 42 | + ports: [6379:6379] |
| 43 | + options: >- |
| 44 | + --health-cmd "redis-cli ping" |
| 45 | + --health-interval 10s |
| 46 | + --health-timeout 5s |
| 47 | + --health-retries 3 |
| 48 | +
|
53 | 49 | steps: |
54 | | - - name: Checkout |
55 | | - uses: actions/checkout@v3 |
| 50 | + - name: Checkout code |
| 51 | + uses: actions/checkout@v4 |
56 | 52 |
|
57 | | - - name: Setup PHP ${{ matrix.php-version }} |
| 53 | + - name: Setup PHP |
58 | 54 | uses: shivammathur/setup-php@v2 |
59 | 55 | with: |
60 | | - php-version: ${{ matrix.php-version }} |
| 56 | + php-version: ${{ matrix.php }} |
61 | 57 | coverage: pcov |
62 | 58 | ini-values: zend.assertions=1 |
| 59 | + tools: composer |
| 60 | + experimental: ${{ contains(matrix.experimental, 'true') }} |
63 | 61 |
|
64 | | - - name: Get composer cache directory |
65 | | - id: composer-cache |
66 | | - run: echo "::set-output name=dir::$(composer config cache-files-dir)" |
67 | | - |
68 | | - - name: Cache dependencies |
69 | | - uses: actions/cache@v2 |
| 62 | + - name: Cache Composer dependencies |
| 63 | + uses: actions/cache@v4 |
70 | 64 | with: |
71 | | - path: ${{ steps.composer-cache.outputs.dir }} |
72 | | - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} |
73 | | - restore-keys: ${{ runner.os }}-composer- |
74 | | - |
75 | | - - name: Handle lowest dependencies update |
76 | | - if: contains(matrix.dependencies, 'lowest') |
77 | | - run: echo COMPOSER_UPDATE_FLAGS=$COMPOSER_UPDATE_FLAGS --prefer-lowest >> $GITHUB_ENV |
| 65 | + path: ~/.composer/cache |
| 66 | + key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }} |
| 67 | + restore-keys: | |
| 68 | + ${{ runner.os }}-php-${{ matrix.php }}-composer- |
78 | 69 |
|
79 | | - - name: Handle ignore-platform-reqs dependencies update |
80 | | - if: contains(matrix.dependencies, 'ignore') |
81 | | - run: echo COMPOSER_FLAGS=$COMPOSER_FLAGS --ignore-platform-req=php >> $GITHUB_ENV |
| 70 | + - name: Configure dependency strategy |
| 71 | + run: | |
| 72 | + if [ "${{ matrix.dependencies }}" = "lowest" ]; then |
| 73 | + composer config prefer-stable true |
| 74 | + composer config prefer-lowest true |
| 75 | + fi |
82 | 76 |
|
83 | | - - name: Remove platform config to get latest dependencies for current PHP version |
84 | | - if: contains(matrix.dependencies, 'highest') || contains(matrix.dependencies, 'lowest') |
85 | | - run: composer config platform --unset |
86 | | - |
87 | | - - name: Allow alpha releases for latest-deps builds to catch problems earlier |
88 | | - if: contains(matrix.dependencies, 'ignore') |
89 | | - run: composer config minimum-stability alpha |
90 | | - |
91 | | - - name: Update dependencies |
92 | | - run: composer update ${{ env.COMPOSER_UPDATE_FLAGS }} ${{ env.COMPOSER_FLAGS }} |
| 77 | + - name: Install dependencies |
| 78 | + run: composer update ${{ matrix.dependencies == 'lowest' && '--prefer-lowest' || '' }} ${{ env.COMPOSER_FLAGS }} |
93 | 79 |
|
94 | 80 | - name: Run test suite |
95 | 81 | run: ./vendor/bin/phpunit --coverage-clover=coverage.xml |
96 | 82 |
|
97 | | - - name: Upload coverage report |
| 83 | + - name: Upload coverage to Codecov |
98 | 84 | uses: codecov/codecov-action@v3 |
99 | 85 | with: |
100 | | - file: ./coverage.xml |
101 | | - |
102 | | - - name: Update dependencies for demo |
103 | | - run: composer require doctrine/cache ^1 ${{ env.COMPOSER_UPDATE_FLAGS }} ${{ env.COMPOSER_FLAGS }} |
| 86 | + files: coverage.xml |
| 87 | + fail_ci_if_error: true |
104 | 88 |
|
105 | | - - name: Run additional script |
106 | | - if: ${{ env.script }} |
107 | | - run: php ${{ env.script }} |
| 89 | + - name: Prepare demo environment |
| 90 | + if: matrix.os == 'ubuntu-latest' && env.SCRIPT_PATH |
| 91 | + run: | |
| 92 | + composer require doctrine/cache ^1 |
| 93 | + php ${{ env.SCRIPT_PATH }} |
0 commit comments