Skip to content

Commit eb113b2

Browse files
committed
[CI] Rework app-tests job to use npm as user's packages manager
1 parent 8ab561f commit eb113b2

File tree

3 files changed

+30
-7266
lines changed

3 files changed

+30
-7266
lines changed

.github/workflows/app-tests.yaml

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,44 @@ jobs:
6060
working-directory: test_apps/encore-app
6161
dependency-versions: highest
6262

63+
- name: Manually replacing "workspace:*" references
64+
run: |
65+
for PACKAGE_DATA in $(cd ../..; pnpm ls -r --json --depth -1 | jq 'map(select(.private != true))' | jq -c '.[]'); do
66+
PACKAGE_NAME=$(echo $PACKAGE_DATA | jq -r '.name')
67+
PACKAGE_ABSOLUTE_PATH=$(echo $PACKAGE_DATA | jq -r '.path')
68+
69+
# Manually replace "workspace:" constraints with the actual package version, it ensure packages can be installed with npm
70+
jq -rc '[(.dependencies // {}) + (.devDependencies // {}) | to_entries[] | select(.value == "workspace:*") | .key][]' "$PACKAGE_ABSOLUTE_PATH/package.json" | while read -r PACKAGE_FROM_WORKSPACE ; do
71+
# Extract the resolved version of the package from the workspace, e.g.: "link:../../../../assets"
72+
PACKAGE_WORKSPACE_PATH=$(cd ../..; pnpm ls --filter $PACKAGE_NAME --json --depth -1 | jq -r '.[].path')
73+
74+
echo "Found package \"$PACKAGE_FROM_WORKSPACE\" in $PACKAGE_ABSOLUTE_PATH/package.json"
75+
76+
NEW_CONSTRAINT_VERSION=file:$PACKAGE_WORKSPACE_PATH
77+
78+
# Replace the package "workspace:*" with the actual version
79+
echo "Replacing \"$PACKAGE_FROM_WORKSPACE\" with \"$NEW_CONSTRAINT_VERSION\" in $PACKAGE_ABSOLUTE_PATH/package.json"
80+
sed -i "s|\"$PACKAGE_FROM_WORKSPACE\": \"workspace:\*\"|\"$PACKAGE_FROM_WORKSPACE\": \"$NEW_CONSTRAINT_VERSION\"|g" "$PACKAGE_ABSOLUTE_PATH/package.json"
81+
done;
82+
done
83+
6384
- working-directory: test_apps/encore-app
64-
run: pnpm install --ignore-workspace
85+
run: npm install
6586

6687
- if: matrix.ux-packages-source == 'js-packages'
6788
name: Install UX JS packages with a JS package manager
6889
working-directory: test_apps/encore-app
6990
run: |
7091
PACKAGES_TO_INSTALL=''
71-
for PACKAGE in $(cd ../..; pnpm ls -r --json --depth -1 | jq 'map(select(.private != true))' | jq -c '.[]'); do
72-
PACKAGE_ABSOLUTE_PATH=$(echo $PACKAGE | jq -r '.path')
92+
for PACKAGE_DATA in $(cd ../..; pnpm ls -r --json --depth -1 | jq 'map(select(.private != true))' | jq -c '.[]'); do
93+
PACKAGE_NAME=$(echo $PACKAGE_DATA | jq -r '.name')
94+
PACKAGE_ABSOLUTE_PATH=$(echo $PACKAGE_DATA | jq -r '.path')
7395
PACKAGE_RELATIVE_PATH=$(realpath --relative-to=. "$PACKAGE_ABSOLUTE_PATH")
7496
PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL file:$PACKAGE_RELATIVE_PATH"
7597
done
98+
7699
echo "Installing packages: $PACKAGES_TO_INSTALL"
77-
pnpm add --save-dev $PACKAGES_TO_INSTALL
100+
npm add --save-dev $PACKAGES_TO_INSTALL
78101
79102
- name: Ensure UX packages are installed from "${{ env.EXPECTED_PATTERN }}"
80103
working-directory: test_apps/encore-app
@@ -97,8 +120,8 @@ jobs:
97120

98121
- name: Ensure project can be built in dev mode
99122
working-directory: test_apps/encore-app
100-
run: pnpm run dev
123+
run: npm run dev
101124

102125
- name: Ensure project can be built in prod mode
103126
working-directory: test_apps/encore-app
104-
run: pnpm run build
127+
run: npm run build

test_apps/encore-app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
composer.lock
2+
package-lock.json
23

34
###> symfony/framework-bundle ###
45
/.env.local

0 commit comments

Comments
 (0)