2424
2525jobs :
2626 # --------------------------------------------------------------
27- # 1. PHP dependencies setup
27+ # 1. PHP dependencies setup + cache vendor + upload as artifact
2828 # --------------------------------------------------------------
2929 php-setup :
3030 runs-on : ubuntu-latest
3131 steps :
3232 - name : Checkout code
3333 uses : actions/checkout@v4
34-
34+
3535 - name : Set up PHP & Composer
3636 uses : shivammathur/setup-php@v2
3737 with :
3838 php-version : 8.3
3939 extensions : mbstring, pdo, mysql, bcmath, tokenizer
4040 tools : composer
41-
41+
4242 - name : Cache Composer dependencies
4343 uses : actions/cache@v3
4444 with :
4545 path : vendor
4646 key : ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }}
4747 restore-keys : |
4848 ${{ runner.os }}-composer-
49-
49+
5050 - name : Install Composer dependencies
5151 run : composer install --no-interaction --prefer-dist
5252
53+ - name : Upload vendor artifact
54+ uses : actions/upload-artifact@v3
55+ with :
56+ name : vendor
57+ path : vendor
58+
5359 # --------------------------------------------------------------
54- # 2. Node/Vite build
60+ # 2. Node/Vite build + cache node_modules + upload build artifacts
5561 # --------------------------------------------------------------
5662 frontend-setup :
5763 runs-on : ubuntu-latest
@@ -78,14 +84,14 @@ jobs:
7884 - name : Build assets
7985 run : npm run build
8086
81- - name : Cache Vite build
82- uses : actions/cache @v3
87+ - name : Upload build artifact
88+ uses : actions/upload-artifact @v3
8389 with :
90+ name : public-build
8491 path : public/build
85- key : ${{ runner.os }}-vite-${{ github.sha }}
8692
8793 # --------------------------------------------------------------
88- # 3. Run tests
94+ # 3. Run tests (depends on php-setup and frontend-setup)
8995 # --------------------------------------------------------------
9096 run-feature-tests :
9197 runs-on : ubuntu-latest
@@ -104,31 +110,39 @@ jobs:
104110 --health-interval=10s
105111 --health-timeout=5s
106112 --health-retries=5
107-
113+
108114 steps :
109115 - name : Checkout code
110116 uses : actions/checkout@v4
111117
118+ - name : Download vendor artifact
119+ uses : actions/download-artifact@v3
120+ with :
121+ name : vendor
122+ path : vendor
123+
124+ - name : Download build artifact
125+ uses : actions/download-artifact@v3
126+ with :
127+ name : public-build
128+ path : public/build
129+
112130 - name : Set up PHP & Composer
113131 uses : shivammathur/setup-php@v2
114132 with :
115133 php-version : 8.3
116134 extensions : mbstring, pdo, mysql, bcmath, tokenizer
117135 tools : composer
118136
119- - name : Install Composer dependencies
120- run : composer install --no-interaction --prefer-dist
137+ # Skip composer install since vendor is restored
121138
122139 - name : Setup Node.js
123140 uses : actions/setup-node@v3
124141 with :
125142 node-version : 20
126143
127- - name : Install NPM dependencies
128- run : npm ci
129-
130- - name : Build assets
131- run : npm run build
144+ # Skip npm install/build since public/build and node_modules are already ready
145+ # (If node_modules needed, consider uploading and downloading that artifact too)
132146
133147 - name : Wait for MySQL to be ready
134148 run : |
0 commit comments