Skip to content

Commit 9fc903e

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 9fc903e

File tree

1 file changed

+87
-1
lines changed

1 file changed

+87
-1
lines changed

.github/workflows/test.yaml

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

0 commit comments

Comments
 (0)