Skip to content

Commit a47462f

Browse files
committed
[CI] Cache Composer dependencies
1 parent 1a21bc3 commit a47462f

8 files changed

+95
-27
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Install root dependencies
2+
runs:
3+
using: composite
4+
steps:
5+
- name: Cache root Composer dependencies
6+
uses: actions/cache@v4
7+
with:
8+
path: vendor
9+
key: ${{ runner.os }}-composer-root-${{ hashFiles('composer.json') }}
10+
restore-keys: |
11+
${{ runner.os }}-composer-root-
12+
working-directory: ${{ github.workspace }}
13+
14+
- name: Install root Composer dependencies
15+
run: composer install
16+
working-directory: ${{ github.workspace }}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Install website dependencies
2+
inputs:
3+
dependency-version:
4+
description: 'The version of dependencies to install. Can be "locked" or "highest"'
5+
default: 'locked'
6+
required: false
7+
runs:
8+
using: composite
9+
steps:
10+
- name: Cache website Composer dependencies
11+
uses: actions/cache@v4
12+
with:
13+
path: vendor
14+
key: ${{ runner.os }}-composer-website-${{ inputs.dependency-version }}-${{ hashFiles('composer.json') }}
15+
restore-keys: |
16+
${{ runner.os }}-composer-website-${{ inputs.dependency-version }}-
17+
working-directory: ux.symfony.com
18+
19+
- name: Install website Composer dependencies
20+
run: composer ${{ inputs.dependency-version == 'highest' && 'update' || 'install' }}
21+
working-directory: ux.symfony.com

.github/workflows/app-tests.yaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,17 @@ jobs:
4343
src/**/package.json
4444
test_apps/encore-app/package.json
4545
46+
- name: Cache Testing apps dependencies
47+
uses: actions/cache@v4
48+
with:
49+
path: vendor
50+
key: ${{ runner.os }}-composer-testing-app-${{ matrix.ux-packages-source }}-${{ hashFiles('test_apps/**/composer.json') }}
51+
restore-keys: |
52+
${{ runner.os }}-composer-testing-app-${{ matrix.ux-packages-source }}-
53+
4654
- uses: shivammathur/setup-php@v2
4755

48-
- name: Install root dependencies
49-
run: composer install
56+
- uses: ./.github/workflows/actions/install-root-dependencies.yaml
5057

5158
- name: Build root packages
5259
run: php .github/build-packages.php

.github/workflows/code-quality.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@ jobs:
8383
php-version: 8.1
8484
tools: flex
8585

86-
- name: Install root dependencies
87-
run: composer install
86+
- uses: ./.github/workflows/actions/install-root-dependencies.yaml
8887

8988
- name: Build root packages
9089
run: php .github/build-packages.php

.github/workflows/functional-tests.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ on:
1010
- '.github/workflows/functional-tests.yml'
1111
- 'src/Turbo/**'
1212

13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
15+
cancel-in-progress: true
16+
1317
jobs:
1418
turbo-tests:
1519
runs-on: ubuntu-latest
@@ -50,14 +54,21 @@ jobs:
5054
- name: Checkout
5155
uses: actions/checkout@v4
5256

57+
- name: Cache packages dependencies
58+
uses: actions/cache@v4
59+
with:
60+
path: vendor
61+
key: ${{ runner.os }}-composer-turbo-${{ matrix.php-version }}-${{ matrix.dependency-version }}-${{ matrix.symfony-version }}-${{ matrix.minimum-stability }}-${{ hashFiles('src/**/composer.json') }}
62+
restore-keys: |
63+
${{ runner.os }}-composer-turbo-${{ matrix.php-version }}-
64+
5365
- name: Setup PHP
5466
uses: shivammathur/setup-php@v2
5567
with:
5668
php-version: ${{ matrix.php-version }}
5769
tools: flex
5870

59-
- name: Install root dependencies
60-
run: composer install
71+
- uses: ./.github/workflows/actions/install-root-dependencies.yaml
6172

6273
- name: Build root packages
6374
run: php .github/build-packages.php

.github/workflows/toolkit-kits-code-quality.yaml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,18 @@ jobs:
1515
- uses: actions/checkout@v4
1616

1717
- uses: shivammathur/setup-php@v2
18+
19+
- name: Cache dependencies
20+
uses: actions/cache@v4
1821
with:
19-
php-version: 8.3
22+
path: vendor
23+
key: ${{ runner.os }}-composer-kits-${{ hashFiles('composer.json') }}
24+
restore-keys: |
25+
${{ runner.os }}-composer-kits-
2026
2127
- name: Install composer packages
22-
uses: ramsey/composer-install@v3
23-
with:
24-
working-directory: src/Toolkit
28+
run: composer install
29+
working-directory: src/Toolkit
2530

2631
- name: Check kits code style
2732
run: php vendor/bin/twig-cs-fixer check kits

.github/workflows/unit-tests.yaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,21 @@ jobs:
6262
echo "Packages: $PACKAGES"
6363
echo "PACKAGES=$PACKAGES" >> $GITHUB_ENV
6464
65+
- name: Cache packages dependencies
66+
uses: actions/cache@v4
67+
with:
68+
path: vendor
69+
key: ${{ runner.os }}-composer-packages-${{ matrix.php-version }}-${{ matrix.dependency-version }}-${{ matrix.symfony-version }}-${{ matrix.minimum-stability }}-${{ hashFiles('src/**/composer.json') }}
70+
restore-keys: |
71+
${{ runner.os }}-composer-packages-${{ matrix.php-version }}-
72+
6573
- name: Setup PHP
6674
uses: shivammathur/setup-php@v2
6775
with:
6876
php-version: ${{ matrix.php-version }}
6977
tools: flex
7078

71-
- name: Install root dependencies
72-
run: composer install
79+
- uses: ./.github/workflows/actions/install-root-dependencies.yaml
7380

7481
- name: Build root packages
7582
run: php .github/build-packages.php

.github/workflows/ux.symfony.com.yaml

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ jobs:
2626
working-directory: ux.symfony.com
2727
steps:
2828
- uses: actions/checkout@v4
29+
2930
- uses: shivammathur/setup-php@v2
3031
with:
3132
php-version: '8.3'
3233
tools: php-cs-fixer
33-
- name: Install dependencies
34-
uses: ramsey/composer-install@v3
35-
with:
36-
working-directory: ux.symfony.com
34+
35+
- uses: ./.github/workflows/actions/install-website-dependencies.yaml
36+
3737
- name: php-cs-fixer
3838
run: php-cs-fixer check --diff
3939

@@ -45,13 +45,13 @@ jobs:
4545
working-directory: ux.symfony.com
4646
steps:
4747
- uses: actions/checkout@v4
48+
4849
- uses: shivammathur/setup-php@v2
4950
with:
5051
php-version: '8.3'
51-
- name: Install dependencies
52-
uses: ramsey/composer-install@v3
53-
with:
54-
working-directory: ux.symfony.com
52+
53+
- uses: ./.github/workflows/actions/install-website-dependencies.yaml
54+
5555
- name: twig-cs-fixer
5656
run: vendor/bin/twig-cs-fixer lint templates --report=github
5757

@@ -63,24 +63,26 @@ jobs:
6363
working-directory: ux.symfony.com
6464
steps:
6565
- uses: actions/checkout@v4
66+
6667
- uses: shivammathur/setup-php@v2
6768
with:
6869
php-version: '8.3'
69-
- name: Install root dependencies
70-
uses: ramsey/composer-install@v3
71-
with:
72-
working-directory: ${{ github.workspace }}
70+
71+
- uses: ./.github/workflows/actions/install-root-dependencies.yaml
72+
7373
- name: Build root packages
7474
run: php .github/build-packages.php
7575
working-directory: ${{ github.workspace }}
76-
- name: Install dependencies
77-
uses: ramsey/composer-install@v3
76+
77+
- uses: ./.github/workflows/actions/install-website-dependencies.yaml
7878
with:
79-
working-directory: ux.symfony.com
8079
dependency-versions: 'highest'
80+
8181
- name: Importmap dependencies
8282
run: php bin/console importmap:install
83+
8384
- name: Build Sass assets
8485
run: php bin/console sass:build
86+
8587
- name: Tests
8688
run: vendor/bin/phpunit

0 commit comments

Comments
 (0)