Skip to content

Commit 45b66c4

Browse files
committed
[CI] Add "test-app-encore-app" job, to ensure that JS packages are usable from vendor/symfony/* or from standalone JS packages
1 parent 3720ba6 commit 45b66c4

File tree

1 file changed

+86
-1
lines changed

1 file changed

+86
-1
lines changed

.github/workflows/test.yaml

Lines changed: 86 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,92 @@ jobs:
136136
cache: 'yarn'
137137
cache-dependency-path: |
138138
yarn.lock
139-
**/package.json
139+
package.json
140+
src/**/package.json
140141
- run: yarn --immutable
141142
- run: yarn playwright install
142143
- run: yarn test
144+
145+
test-app-encore-app:
146+
name: "Test Apps / Encore (${{ matrix.name}})"
147+
runs-on: ubuntu-latest
148+
strategy:
149+
matrix:
150+
include:
151+
- name: Internal (from "vendor/")
152+
ux-packages-source: php-vendor
153+
- name: External (from "yarn add")
154+
ux-packages-source: js-packages
155+
steps:
156+
# Setup
157+
- uses: actions/checkout@v4
158+
- run: corepack enable
159+
- uses: actions/setup-node@v4
160+
with:
161+
cache: 'yarn'
162+
cache-dependency-path: |
163+
yarn.lock
164+
package.json
165+
src/**/package.json
166+
test_apps/encore-app/package.json
167+
168+
- if: matrix.ux-packages-source == 'php-vendor'
169+
uses: shivammathur/setup-php@v2
170+
171+
- if: matrix.ux-packages-source == 'php-vendor'
172+
uses: ramsey/composer-install@v3
173+
with:
174+
working-directory: test_apps/encore-app
175+
176+
- if: matrix.ux-packages-source == 'js-packages'
177+
working-directory: test_apps/encore-app
178+
run: |
179+
PACKAGES_TO_INSTALL=''
180+
for PACKAGE in $(cd ../..; yarn workspaces list --no-private --json); do
181+
PACKAGE_DIR=../../$(echo $PACKAGE | jq -r '.location')
182+
PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL $PACKAGE_DIR"
183+
done
184+
echo "Installing packages: $PACKAGES_TO_INSTALL"
185+
yarn add --dev $PACKAGES_TO_INSTALL
186+
187+
# Validations
188+
- if: matrix.ux-packages-source == 'php-vendor'
189+
name: Ensure UX packages are installed from "vendor/symfony/ux-..."
190+
working-directory: test_apps/encore-app
191+
run: |
192+
for PACKAGE in $(cat package.json | jq -c '(.dependencies // {}) + (.devDependencies // {}) | to_entries[] | select(.key | startswith("@symfony/ux-")) | {name: .key, version: .value}'); do
193+
PACKAGE_NAME=$(echo $PACKAGE | jq -r '.name')
194+
PACKAGE_VERSION=$(echo $PACKAGE | jq -r '.version')
195+
echo -n "Checking $PACKAGE_NAME@$PACKAGE_VERSION..."
196+
if [[ $PACKAGE_VERSION == "file:vendor/symfony/"* ]]; then
197+
echo " OK"
198+
else
199+
echo " KO"
200+
echo "The package version of $PACKAGE_NAME must use a local path (e.g.: file:vendor/symfony/ux-chartjs), got $PACKAGE_VERSION instead."
201+
exit 1
202+
fi
203+
done;
204+
205+
- if: matrix.ux-packages-source == 'js-packages'
206+
name: Ensure UX packages are installed from "../../../src/**/assets"
207+
working-directory: test_apps/encore-app
208+
run: |
209+
for PACKAGE in $(cat package.json | jq -c '(.dependencies // {}) + (.devDependencies // {}) | to_entries[] | select(.key | startswith("@symfony/ux-")) | {name: .key, version: .value}'); do
210+
PACKAGE_NAME=$(echo $PACKAGE | jq -r '.name')
211+
PACKAGE_VERSION=$(echo $PACKAGE | jq -r '.version')
212+
echo -n "Checking $PACKAGE_NAME@$PACKAGE_VERSION..."
213+
if [[ $PACKAGE_VERSION == "../../src/"* ]]; then
214+
echo " OK"
215+
else
216+
echo " KO"
217+
echo "The package version of $PACKAGE_NAME must use a local path (e.g.: ../../src/Autocomplete/assets), got $PACKAGE_VERSION instead."
218+
exit 1
219+
fi
220+
done;
221+
222+
- name: Run Encore
223+
working-directory: test_apps/encore-app
224+
run: |
225+
yarn || echo "Unable to install Yarn dependencies" && exit 1
226+
yarn encore dev || echo "Unable to build Encore assets (dev)" && exit 1
227+
yarn encore production || echo "Unable to build Encore assets (production)" && exit 1

0 commit comments

Comments
 (0)