Skip to content

Commit 2b4cb23

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 2b4cb23

File tree

1 file changed

+82
-1
lines changed

1 file changed

+82
-1
lines changed

.github/workflows/test.yaml

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

0 commit comments

Comments
 (0)