diff --git a/.github/actions/install-root-dependencies/action.yaml b/.github/actions/install-root-dependencies/action.yaml new file mode 100644 index 00000000000..ddfd09cb824 --- /dev/null +++ b/.github/actions/install-root-dependencies/action.yaml @@ -0,0 +1,21 @@ +name: Install root dependencies +runs: + using: composite + steps: + - name: Get Composer Cache Directory + id: composer-cache + run: | + echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + shell: bash + + - name: Cache root Composer dependencies + uses: actions/cache@v4 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-root-${{ hashFiles('composer.json') }} + restore-keys: | + ${{ runner.os }}-composer-root- + + - name: Install root Composer dependencies + run: composer install + shell: bash diff --git a/.github/actions/install-website-dependencies/action.yaml b/.github/actions/install-website-dependencies/action.yaml new file mode 100644 index 00000000000..41928fc76eb --- /dev/null +++ b/.github/actions/install-website-dependencies/action.yaml @@ -0,0 +1,27 @@ +name: Install website dependencies +inputs: + dependency-version: + description: 'The version of dependencies to install. Can be "locked" or "highest"' + default: 'locked' + required: false +runs: + using: composite + steps: + - name: Get Composer Cache Directory + id: composer-cache + run: | + echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + shell: bash + + - name: Cache website Composer dependencies + uses: actions/cache@v4 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-website-${{ inputs.dependency-version }}-${{ hashFiles('ux.symfony.com/composer.json') }} + restore-keys: | + ${{ runner.os }}-composer-website-${{ inputs.dependency-version }}- + + - name: Install website Composer dependencies + run: composer ${{ inputs.dependency-version == 'highest' && 'update' || 'install' }} + shell: bash + working-directory: ux.symfony.com diff --git a/.github/workflows/app-tests.yaml b/.github/workflows/app-tests.yaml index d28e417052b..528168d2309 100644 --- a/.github/workflows/app-tests.yaml +++ b/.github/workflows/app-tests.yaml @@ -45,8 +45,20 @@ jobs: - uses: shivammathur/setup-php@v2 - - name: Install root dependencies - run: composer install + - name: Get Composer Cache Directory + id: composer-cache + run: | + echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - name: Cache Testing apps dependencies + uses: actions/cache@v4 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-testing-app-${{ matrix.ux-packages-source }}-${{ hashFiles('test_apps/**/composer.json') }} + restore-keys: | + ${{ runner.os }}-composer-testing-app-${{ matrix.ux-packages-source }}- + + - uses: ./.github/actions/install-root-dependencies - name: Build root packages run: php .github/build-packages.php diff --git a/.github/workflows/code-quality.yaml b/.github/workflows/code-quality.yaml index bf705c0bc6f..c5477d69966 100644 --- a/.github/workflows/code-quality.yaml +++ b/.github/workflows/code-quality.yaml @@ -83,8 +83,7 @@ jobs: php-version: 8.1 tools: flex - - name: Install root dependencies - run: composer install + - uses: ./.github/actions/install-root-dependencies - name: Build root packages run: php .github/build-packages.php diff --git a/.github/workflows/functional-tests.yml b/.github/workflows/functional-tests.yml index a38db2e96ae..3674f31a7c8 100644 --- a/.github/workflows/functional-tests.yml +++ b/.github/workflows/functional-tests.yml @@ -10,6 +10,10 @@ on: - '.github/workflows/functional-tests.yml' - 'src/Turbo/**' +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + jobs: turbo-tests: runs-on: ubuntu-latest @@ -56,8 +60,20 @@ jobs: php-version: ${{ matrix.php-version }} tools: flex - - name: Install root dependencies - run: composer install + - name: Get Composer Cache Directory + id: composer-cache + run: | + echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - name: Cache packages dependencies + uses: actions/cache@v4 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-turbo-${{ matrix.php-version }}-${{ matrix.dependency-version }}-${{ matrix.symfony-version }}-${{ matrix.minimum-stability }}-${{ hashFiles('src/**/composer.json') }} + restore-keys: | + ${{ runner.os }}-composer-turbo-${{ matrix.php-version }}- + + - uses: ./.github/actions/install-root-dependencies - name: Build root packages run: php .github/build-packages.php diff --git a/.github/workflows/toolkit-kits-code-quality.yaml b/.github/workflows/toolkit-kits-code-quality.yaml index 0ed5ccfc968..af4759587c9 100644 --- a/.github/workflows/toolkit-kits-code-quality.yaml +++ b/.github/workflows/toolkit-kits-code-quality.yaml @@ -15,13 +15,23 @@ jobs: - uses: actions/checkout@v4 - uses: shivammathur/setup-php@v2 + + - name: Get Composer Cache Directory + id: composer-cache + run: | + echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - name: Cache dependencies + uses: actions/cache@v4 with: - php-version: 8.3 + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-kits-${{ hashFiles('composer.json') }} + restore-keys: | + ${{ runner.os }}-composer-kits- - name: Install composer packages - uses: ramsey/composer-install@v3 - with: - working-directory: src/Toolkit + run: composer install + working-directory: src/Toolkit - name: Check kits code style run: php vendor/bin/twig-cs-fixer check kits diff --git a/.github/workflows/unit-tests.yaml b/.github/workflows/unit-tests.yaml index facda11d330..2cb65746a00 100644 --- a/.github/workflows/unit-tests.yaml +++ b/.github/workflows/unit-tests.yaml @@ -68,8 +68,20 @@ jobs: php-version: ${{ matrix.php-version }} tools: flex - - name: Install root dependencies - run: composer install + - name: Get Composer Cache Directory + id: composer-cache + run: | + echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - name: Cache packages dependencies + uses: actions/cache@v4 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-packages-${{ matrix.php-version }}-${{ matrix.dependency-version }}-${{ matrix.symfony-version }}-${{ matrix.minimum-stability }}-${{ hashFiles('src/**/composer.json') }} + restore-keys: | + ${{ runner.os }}-composer-packages-${{ matrix.php-version }}- + + - uses: ./.github/actions/install-root-dependencies - name: Build root packages run: php .github/build-packages.php diff --git a/.github/workflows/ux.symfony.com.yaml b/.github/workflows/ux.symfony.com.yaml index d9d8a65d681..0f3afc887d2 100644 --- a/.github/workflows/ux.symfony.com.yaml +++ b/.github/workflows/ux.symfony.com.yaml @@ -26,14 +26,14 @@ jobs: working-directory: ux.symfony.com steps: - uses: actions/checkout@v4 + - uses: shivammathur/setup-php@v2 with: php-version: '8.3' tools: php-cs-fixer - - name: Install dependencies - uses: ramsey/composer-install@v3 - with: - working-directory: ux.symfony.com + + - uses: ./.github/actions/install-website-dependencies + - name: php-cs-fixer run: php-cs-fixer check --diff @@ -45,13 +45,13 @@ jobs: working-directory: ux.symfony.com steps: - uses: actions/checkout@v4 + - uses: shivammathur/setup-php@v2 with: php-version: '8.3' - - name: Install dependencies - uses: ramsey/composer-install@v3 - with: - working-directory: ux.symfony.com + + - uses: ./.github/actions/install-website-dependencies + - name: twig-cs-fixer run: vendor/bin/twig-cs-fixer lint templates --report=github @@ -63,24 +63,26 @@ jobs: working-directory: ux.symfony.com steps: - uses: actions/checkout@v4 + - uses: shivammathur/setup-php@v2 with: php-version: '8.3' - - name: Install root dependencies - uses: ramsey/composer-install@v3 - with: - working-directory: ${{ github.workspace }} + + - uses: ./.github/actions/install-root-dependencies + - name: Build root packages run: php .github/build-packages.php working-directory: ${{ github.workspace }} - - name: Install dependencies - uses: ramsey/composer-install@v3 + + - uses: ./.github/actions/install-website-dependencies with: - working-directory: ux.symfony.com dependency-versions: 'highest' + - name: Importmap dependencies run: php bin/console importmap:install + - name: Build Sass assets run: php bin/console sass:build + - name: Tests run: vendor/bin/phpunit