From a4cd22502452ef11e1ab244ec402e9c5b4397466 Mon Sep 17 00:00:00 2001 From: Etienne Gutbub Date: Wed, 24 Jan 2024 10:51:32 +0100 Subject: [PATCH] ci(composer cache): Update CI --- .github/workflows/recipe.yaml | 30 ++++++++++------- .github/workflows/security.yaml | 34 +++++++++---------- .github/workflows/tests.yaml | 58 ++++++++++++++++----------------- 3 files changed, 63 insertions(+), 59 deletions(-) diff --git a/.github/workflows/recipe.yaml b/.github/workflows/recipe.yaml index 6b8aa5f0..9a0b4a3b 100644 --- a/.github/workflows/recipe.yaml +++ b/.github/workflows/recipe.yaml @@ -46,18 +46,24 @@ jobs: - run: mkdir -p /home/runner/{.composer/cache,.config/composer} - - uses: actions/cache@v3 - id: cache-composer - with: - path: /home/runner/.composer/cache - key: composer2-php:${{ matrix.php }}-sylius:${{ matrix.sylius }}-${{ github.sha }} - restore-keys: composer2-php:${{ matrix.php }}-sylius:${{ matrix.sylius }}- - - - name: Composer - run: sudo composer self-update - - - name: Composer Github Auth - run: composer config -g github-oauth.github.com ${{ github.token }} + - name: Determine composer cache directory + id: composer-cache-directory + working-directory: plugin + run: echo "directory=$(composer config cache-dir)" >> $GITHUB_OUTPUT + + - name: Cache dependencies installed with composer + uses: actions/cache@v3 + id: cache-composer + with: + path: ${{ steps.composer-cache-directory.outputs.directory }} + key: composer2-php:${{ matrix.php }}-sylius:${{ matrix.sylius }}-${{ hashFiles('**/composer.json') }} + restore-keys: composer2-php:${{ matrix.php }}-sylius:${{ matrix.sylius }}- + + - name: Ensure that composer cache directory exists + run: mkdir -p ${{ steps.composer-cache-directory.outputs.directory }} + + - name: Composer Github Auth + run: composer config -g github-oauth.github.com ${{ github.token }} - name: Create Sylius-Standard project without install run: | diff --git a/.github/workflows/security.yaml b/.github/workflows/security.yaml index 630420de..0522893d 100644 --- a/.github/workflows/security.yaml +++ b/.github/workflows/security.yaml @@ -30,23 +30,23 @@ jobs: run: | echo ${{ matrix.php }} > .php-version - - uses: actions/cache@v3 - id: cache-composer - with: - path: /home/runner/.composer/cache - key: composer2-php:${{ matrix.php }}-${{ github.sha }} - restore-keys: composer2-php:${{ matrix.php }}- - - - run: mkdir -p /home/runner/{.composer/cache,.config/composer} - if: steps.cache-composer.outputs.cache-hit != 'true' - - - name: Composer - run: sudo composer self-update - - - name: Composer Github Auth - run: composer config -g github-oauth.github.com ${{ github.token }} - - - uses: actions/checkout@v2 + - name: Determine composer cache directory + id: composer-cache-directory + run: echo "directory=$(composer config cache-dir)" >> $GITHUB_OUTPUT + + - name: Cache dependencies installed with composer + uses: actions/cache@v3 + id: cache-composer + with: + path: ${{ steps.composer-cache-directory.outputs.directory }} + key: composer2-php:${{ matrix.php }}-${{ hashFiles('**/composer.json') }} + restore-keys: composer2-php:${{ matrix.php }}- + + - name: Ensure that composer cache directory exists + run: mkdir -p ${{ steps.composer-cache-directory.outputs.directory }} + + - name: Composer Github Auth + run: composer config -g github-oauth.github.com ${{ github.token }} - name: Install PHP dependencies run: composer update --prefer-dist diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 25bed714..42c05029 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -30,36 +30,34 @@ jobs: with: node-version: '14' - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - ini-values: date.timezone=UTC - - - name: Set project php-version - run: | - echo ${{ matrix.php }} > .php-version - - - name: Install symfony CLI - run: | - curl https://get.symfony.com/cli/installer | bash - echo "${HOME}/.symfony5/bin" >> $GITHUB_PATH - - - uses: actions/cache@v3 - id: cache-composer - with: - path: /home/runner/.composer/cache - key: composer2-php:${{ matrix.php }}-${{ github.sha }} - restore-keys: composer2-php:${{ matrix.php }}- - - - run: mkdir -p /home/runner/{.composer/cache,.config/composer} - if: steps.cache-composer.outputs.cache-hit != 'true' - - - name: Composer - run: sudo composer self-update - - - name: Composer Github Auth - run: composer config -g github-oauth.github.com ${{ github.token }} + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + ini-values: date.timezone=UTC + tools: symfony-cli + + - name: Set project php-version + run: | + echo ${{ matrix.php }} > .php-version + + - name: Determine composer cache directory + id: composer-cache-directory + run: echo "directory=$(composer config cache-dir)" >> $GITHUB_OUTPUT + + - name: Cache dependencies installed with composer + uses: actions/cache@v3 + id: cache-composer + with: + path: ${{ steps.composer-cache-directory.outputs.directory }} + key: composer2-php:${{ matrix.php }}-${{ hashFiles('**/composer.json') }} + restore-keys: composer2-php:${{ matrix.php }}- + + - name: Ensure that composer cache directory exists + run: mkdir -p ${{ steps.composer-cache-directory.outputs.directory }} + + - name: Composer Github Auth + run: composer config -g github-oauth.github.com ${{ github.token }} - run: make install