Skip to content

Commit 72244f0

Browse files
workflows: Add composer dependency caching (#499)
1 parent 95a22c5 commit 72244f0

2 files changed

Lines changed: 70 additions & 31 deletions

File tree

.github/workflows/code-quality.yml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,21 @@ jobs:
3030
with:
3131
php-version: '8.2'
3232

33+
- name: Get composer cache directory
34+
id: composer-cache
35+
shell: bash
36+
run: |
37+
echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
38+
39+
- name: Cache composer cache directory
40+
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
41+
with:
42+
path: ${{ steps.composer-cache.outputs.dir }}
43+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
44+
restore-keys: ${{ runner.os }}-composer-
45+
3346
- name: "Validate composer.json and composer.lock"
34-
run: "composer validate --strict"
47+
run: composer validate --strict
3548

3649
- name: Install dependencies with composer
3750
run: composer install --prefer-dist
@@ -53,6 +66,19 @@ jobs:
5366
php-version: '8.2'
5467
tools: cs2pr
5568

69+
- name: Get composer cache directory
70+
id: composer-cache
71+
shell: bash
72+
run: |
73+
echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
74+
75+
- name: Cache composer cache directory
76+
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
77+
with:
78+
path: ${{ steps.composer-cache.outputs.dir }}
79+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
80+
restore-keys: ${{ runner.os }}-composer-
81+
5682
- name: Install dependencies with composer
5783
run: composer install --prefer-dist
5884

.github/workflows/test.yml

Lines changed: 43 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -28,43 +28,56 @@ jobs:
2828
HTTPBIN_URI: "http://127.0.0.1:8081"
2929

3030
steps:
31-
- name: Checkout code
32-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
33-
34-
- name: Setup PHP
35-
uses: shivammathur/setup-php@ec406be512d7077f68eed36e63f4d91bc006edc4 # v2.35.4
36-
with:
37-
php-version: '8.2'
38-
extensions: mbstring
31+
- name: Checkout code
32+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
33+
34+
- name: Setup PHP
35+
uses: shivammathur/setup-php@ec406be512d7077f68eed36e63f4d91bc006edc4 # v2.35.4
36+
with:
37+
php-version: '8.2'
38+
extensions: mbstring
3939

40-
- name: Setup problem matchers for PHP
41-
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
40+
- name: Setup problem matchers for PHP
41+
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
42+
43+
- name: Setup problem matchers for PHPUnit
44+
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
45+
46+
- name: Get composer cache directory
47+
id: composer-cache
48+
shell: bash
49+
run: |
50+
echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
4251
43-
- name: Setup problem matchers for PHPUnit
44-
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
52+
- name: Cache composer cache directory
53+
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
54+
with:
55+
path: ${{ steps.composer-cache.outputs.dir }}
56+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
57+
restore-keys: ${{ runner.os }}-composer-
4558

46-
- name: "Validate composer.json and composer.lock"
47-
run: "composer validate --strict"
59+
- name: "Validate composer.json and composer.lock"
60+
run: composer validate --strict
4861

49-
- name: Install dependencies with composer
50-
run: composer install --prefer-dist
62+
- name: Install dependencies with composer
63+
run: composer install --prefer-dist
5164

52-
- name: Fetch & setup gotify plugin
53-
run: bash .ci/scripts/setup-plugin.sh
65+
- name: Fetch & setup gotify plugin
66+
run: bash .ci/scripts/setup-plugin.sh
5467

55-
- name: Start gotify & httpbin docker containers
56-
run: docker compose up -d
68+
- name: Start gotify & httpbin docker containers
69+
run: docker compose up -d
5770

58-
- name: Test connections to docker containers
59-
run: bash .ci/scripts/connections.sh
71+
- name: Test connections to docker containers
72+
run: bash .ci/scripts/connections.sh
6073

61-
- name: Run phpunit
62-
run: ./vendor/bin/phpunit --coverage-clover=coverage.xml --testsuite=default,plugin-endpoint
74+
- name: Run phpunit
75+
run: ./vendor/bin/phpunit --coverage-clover=coverage.xml --testsuite=default,plugin-endpoint
6376

64-
- name: Stop gotify & httpbin docker docker containers
65-
run: docker compose down
77+
- name: Stop gotify & httpbin docker docker containers
78+
run: docker compose down
6679

67-
- name: Upload coverage reports to Codecov
68-
uses: codecov/codecov-action@fdcc8476540edceab3de004e990f80d881c6cc00 # v5.5.0
69-
with:
70-
token: ${{ secrets.CODECOV_TOKEN }}
80+
- name: Upload coverage reports to Codecov
81+
uses: codecov/codecov-action@fdcc8476540edceab3de004e990f80d881c6cc00 # v5.5.0
82+
with:
83+
token: ${{ secrets.CODECOV_TOKEN }}

0 commit comments

Comments
 (0)