Skip to content

Commit b0ace11

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 b0ace11

File tree

1 file changed

+68
-1
lines changed

1 file changed

+68
-1
lines changed

.github/workflows/test.yaml

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,74 @@ 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+
- uses: shivammathur/setup-php@v2
169+
- uses: ramsey/composer-install@v3
170+
with:
171+
working-directory: test_apps/encore-app
172+
173+
- if: matrix.ux-packages-source == 'js-packages'
174+
working-directory: test_apps/encore-app
175+
run: |
176+
PACKAGES_TO_INSTALL=''
177+
for PACKAGE in $(cd ../..; yarn workspaces list --no-private --json); do
178+
PACKAGE_DIR=../../$(echo $PACKAGE | jq -r '.location')
179+
PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL $PACKAGE_DIR"
180+
done
181+
echo "Installing packages: $PACKAGES_TO_INSTALL"
182+
yarn add --dev $PACKAGES_TO_INSTALL
183+
184+
# Validations
185+
- name: Ensure UX packages are installed from "${{ matrix.ux-packages-source == 'php-vendor' && 'vendor/symfony/ux-...' || '../../../src/**/assets' }}"
186+
working-directory: test_apps/encore-app
187+
run: |
188+
for PACKAGE in $(cat package.json | jq -c '(.dependencies // {}) + (.devDependencies // {}) | to_entries[] | select(.key | startswith("@symfony/ux-")) | {name: .key, version: .value}'); do
189+
PACKAGE_NAME=$(echo $PACKAGE | jq -r '.name')
190+
PACKAGE_VERSION=$(echo $PACKAGE | jq -r '.version')
191+
192+
echo -n "Checking $PACKAGE_NAME@$PACKAGE_VERSION..."
193+
if [[ $PACKAGE_VERSION == $EXPECTED_PATTERN* ]]; then
194+
echo " OK"
195+
else
196+
echo " KO"
197+
echo "The package version of $PACKAGE_NAME must starts with the pattern (e.g.: $EXPECTED_PATTERN), got $PACKAGE_VERSION instead."
198+
exit 1
199+
fi
200+
done;
201+
env:
202+
EXPECTED_PATTERN: ${{ matrix.ux-packages-source == 'php-vendor' && 'file:vendor/symfony/*' || '../../src/*' }}
203+
204+
- name: Run Encore
205+
working-directory: test_apps/encore-app
206+
run: |
207+
yarn || (echo "Unable to install Yarn dependencies" && exit 1)
208+
yarn encore dev || (echo "Unable to build Encore assets (dev)" && exit 1)
209+
yarn encore production || (echo "Unable to build Encore assets (production)" && exit 1)

0 commit comments

Comments
 (0)