Skip to content

Commit 2b11ff1

Browse files
committed
moved composer cache to action
1 parent 843162f commit 2b11ff1

File tree

3 files changed

+81
-101
lines changed

3 files changed

+81
-101
lines changed

.github/actions/build/action.yaml

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,11 @@ runs:
4242
fi
4343
shell: bash
4444

45-
- name: "Create cache suffix"
46-
run: echo "CACHE_KEY=${{ github.run_id }}-${{ runner.os }}-${{ inputs.php }}-${{ inputs.sylius }}-${{ inputs.symfony }}" >> $GITHUB_ENV
47-
shell: bash
48-
49-
- name: "Cache composer"
50-
id: cache-composer-lock
51-
uses: actions/cache@v4
45+
- uses: ./.github/actions/composer-cache
5246
with:
53-
path: |
54-
tests/Application/composer.lock
55-
composer.lock
56-
tests/Application/vendor/
57-
vendor/
58-
key: composer-${{ hashFiles('composer.json', 'tests/Application/composer.json') }}-${{ env.CACHE_KEY }}
47+
php: ${{ inputs.php }}
48+
sylius: ${{ inputs.sylius }}
49+
symfony: ${{ inputs.symfony }}
5950

6051
- name: "Build application"
6152
uses: SyliusLabs/BuildTestAppAction@v2.4
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: "Composer cache"
2+
description: "Cache composer or retrieve cached composer"
3+
inputs:
4+
php:
5+
description: "PHP version, e.g. 8.2"
6+
required: true
7+
symfony:
8+
description: "Symfony version, e.g. ~6.4.0"
9+
required: true
10+
sylius:
11+
description: "Sylius version, e.g. ~2.0.0"
12+
required: true
13+
14+
runs:
15+
using: "composite"
16+
steps:
17+
- name: "Create cache suffix"
18+
run: echo "COMPOSER_CACHE_KEY=${{ github.run_id }}-${{ runner.os }}-${{ inputs.php }}-${{ inputs.sylius }}-${{ inputs.symfony }}" >> $GITHUB_ENV
19+
shell: bash
20+
21+
- name: "Cache composer"
22+
id: cache-composer-lock
23+
uses: actions/cache@v4
24+
with:
25+
path: |
26+
tests/Application/composer.lock
27+
composer.lock
28+
tests/Application/vendor/
29+
vendor/
30+
key: composer-${{ hashFiles('composer.json', 'tests/Application/composer.json') }}-${{ env.COMPOSER_CACHE_KEY }}

.github/workflows/ci.yaml

Lines changed: 47 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ jobs:
4848
mysql: ${{ matrix.mysql }}
4949
sylius: ${{ matrix.sylius }}
5050
symfony: ${{ matrix.symfony }}
51+
check_service_definitions: yes
5152

5253
static-analysis:
5354
name: Static analysis - PHP ${{ matrix.php || '' }}
@@ -59,27 +60,11 @@ jobs:
5960
steps:
6061
- uses: actions/checkout@v4
6162

62-
- name: "Create cache suffix"
63-
run: echo "CACHE_KEY=${{ github.run_id }}-${{ runner.os }}-${{ matrix.php }}-${{ matrix.sylius }}-${{ matrix.symfony }}" >> $GITHUB_ENV
64-
shell: bash
65-
66-
- name: "Cache composer"
67-
id: cache-composer-lock
68-
uses: actions/cache@v4
63+
- uses: ./.github/actions/composer-cache
6964
with:
70-
path: |
71-
tests/Application/composer.lock
72-
composer.lock
73-
tests/Application/vendor/
74-
vendor/
75-
key: composer-${{ hashFiles('composer.json', 'tests/Application/composer.json') }}-${{ env.CACHE_KEY }}
76-
77-
# - uses: ./.github/actions/build
78-
# with:
79-
# php: ${{ matrix.php }}
80-
# mysql: ${{ matrix.mysql }}
81-
# sylius: ${{ matrix.sylius }}
82-
# symfony: ${{ matrix.symfony }}
65+
php: ${{ matrix.php }}
66+
sylius: ${{ matrix.sylius }}
67+
symfony: ${{ matrix.symfony }}
8368

8469
- name: "PHPStan"
8570
run: vendor/bin/phpstan
@@ -97,27 +82,11 @@ jobs:
9782
steps:
9883
- uses: actions/checkout@v4
9984

100-
- name: "Create cache suffix"
101-
run: echo "CACHE_KEY=${{ github.run_id }}-${{ runner.os }}-${{ matrix.php }}-${{ matrix.sylius }}-${{ matrix.symfony }}" >> $GITHUB_ENV
102-
shell: bash
103-
104-
- name: "Cache composer"
105-
id: cache-composer-lock
106-
uses: actions/cache@v4
85+
- uses: ./.github/actions/composer-cache
10786
with:
108-
path: |
109-
tests/Application/composer.lock
110-
composer.lock
111-
tests/Application/vendor/
112-
vendor/
113-
key: composer-${{ hashFiles('composer.json', 'tests/Application/composer.json') }}-${{ env.CACHE_KEY }}
114-
115-
# - uses: ./.github/actions/build
116-
# with:
117-
# php: ${{ matrix.php }}
118-
# mysql: ${{ matrix.mysql }}
119-
# sylius: ${{ matrix.sylius }}
120-
# symfony: ${{ matrix.symfony }}
87+
php: ${{ matrix.php }}
88+
sylius: ${{ matrix.sylius }}
89+
symfony: ${{ matrix.symfony }}
12190

12291
- run: vendor/bin/phpunit --testsuite unit --exclude-group requires-fixes
12392

@@ -164,41 +133,40 @@ jobs:
164133
# if: always()
165134
# with:
166135
# subject: E2E tests - PHP ${{ matrix.php || '' }}
167-
#
168-
# api-tests:
169-
# name: API tests - PHP ${{ matrix.php || '' }}
170-
# needs: [ get-matrix, build ]
171-
# runs-on: ubuntu-latest
172-
# strategy:
173-
# fail-fast: false
174-
# matrix: ${{ fromJson(needs.get-matrix.outputs.matrix) }}
175-
# env:
176-
# DATABASE_URL: "mysql://root:root@127.0.0.1:3306/sylius?serverVersion=${{ matrix.mysql }}"
177-
# STATE_MACHINE_DEFAULT_ADAPTER: ${{ matrix.state_machine }}
178-
# steps:
179-
# - uses: actions/checkout@v4
180-
#
181-
# - name: "Run Mockoon"
182-
# uses: mockoon/cli-action@v2
183-
# with:
184-
# version: "latest"
185-
# data-file: "./tests/mockoon_tpay.json"
186-
# port: 4000
187-
#
188-
# - uses: ./.github/actions/build
189-
# with:
190-
# php: ${{ matrix.php }}
191-
# mysql: ${{ matrix.mysql }}
192-
# sylius: ${{ matrix.sylius }}
193-
# symfony: ${{ matrix.symfony }}
194-
#
195-
# - run: vendor/bin/phpunit --testsuite api
196-
#
197-
# - uses: ./.github/actions/upload-logs
198-
# if: always()
199-
# with:
200-
# subject: API tests - PHP ${{ matrix.php || '' }}
201-
#
136+
137+
api-tests:
138+
name: API tests - PHP ${{ matrix.php || '' }}
139+
needs: [ get-matrix, build ]
140+
runs-on: ubuntu-latest
141+
strategy:
142+
fail-fast: false
143+
matrix: ${{ fromJson(needs.get-matrix.outputs.matrix) }}
144+
env:
145+
DATABASE_URL: "mysql://root:root@127.0.0.1:3306/sylius?serverVersion=${{ matrix.mysql }}"
146+
STATE_MACHINE_DEFAULT_ADAPTER: ${{ matrix.state_machine }}
147+
steps:
148+
- uses: actions/checkout@v4
149+
150+
- name: "Run Mockoon"
151+
uses: mockoon/cli-action@v2
152+
with:
153+
version: "latest"
154+
data-file: "./tests/mockoon_tpay.json"
155+
port: 4000
156+
157+
- uses: ./.github/actions/composer-cache
158+
with:
159+
php: ${{ matrix.php }}
160+
sylius: ${{ matrix.sylius }}
161+
symfony: ${{ matrix.symfony }}
162+
163+
- run: vendor/bin/phpunit --testsuite api
164+
165+
- uses: ./.github/actions/upload-logs
166+
if: always()
167+
with:
168+
subject: API tests - PHP ${{ matrix.php || '' }}
169+
202170
contract-tests:
203171
name: Contract tests - PHP ${{ matrix.php || '' }}
204172
needs: [ get-matrix, build ]
@@ -209,20 +177,11 @@ jobs:
209177
steps:
210178
- uses: actions/checkout@v4
211179

212-
- name: "Create cache suffix"
213-
run: echo "CACHE_KEY=${{ github.run_id }}-${{ runner.os }}-${{ matrix.php }}-${{ matrix.sylius }}-${{ matrix.symfony }}" >> $GITHUB_ENV
214-
shell: bash
215-
216-
- name: "Cache composer"
217-
id: cache-composer-lock
218-
uses: actions/cache@v4
180+
- uses: ./.github/actions/composer-cache
219181
with:
220-
path: |
221-
tests/Application/composer.lock
222-
composer.lock
223-
tests/Application/vendor/
224-
vendor/
225-
key: composer-${{ hashFiles('composer.json', 'tests/Application/composer.json') }}-${{ env.CACHE_KEY }}
182+
php: ${{ matrix.php }}
183+
sylius: ${{ matrix.sylius }}
184+
symfony: ${{ matrix.symfony }}
226185

227186
- run: vendor/bin/phpunit --testsuite contract_external
228187

0 commit comments

Comments
 (0)