Skip to content

Commit b187290

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

File tree

3 files changed

+41
-7266
lines changed

3 files changed

+41
-7266
lines changed

.github/workflows/app-tests.yaml

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,55 @@ 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+
RESOLVED_VERSION=$(pnpm ls --filter $PACKAGE_NAME --json | jq -r --arg PACKAGE_FROM_WORKSPACE $PACKAGE_FROM_WORKSPACE '
73+
.[].dependencies // {} + .[].devDependencies // {} |
74+
to_entries[] |
75+
select(.value.from == $PACKAGE_FROM_WORKSPACE) |
76+
.value.version
77+
')
78+
79+
echo "pnpm ls --filter $PACKAGE_NAME --json"
80+
pnpm ls --filter $PACKAGE_NAME --json
81+
82+
83+
echo "Resolved version for $PACKAGE_FROM_WORKSPACE: $RESOLVED_VERSION"
84+
85+
86+
# Replace "link:" (pnpm) with "file:" (compatible with npm)
87+
RESOLVED_VERSION=${RESOLVED_VERSION/link:/file:}
88+
89+
# Replace the package "workspace:*" with the actual version
90+
echo "Replacing \"$PACKAGE_FROM_WORKSPACE\" with \"$RESOLVED_VERSION\" in $PACKAGE_ABSOLUTE_PATH/package.json"
91+
sed -i "s|\"$PACKAGE_FROM_WORKSPACE\": \"workspace:\*\"|\"$PACKAGE_FROM_WORKSPACE\": \"$RESOLVED_VERSION\"|g" "$PACKAGE_ABSOLUTE_PATH/package.json"
92+
done;
93+
done
94+
6395
- working-directory: test_apps/encore-app
64-
run: pnpm install --ignore-workspace
96+
run: npm install
6597

6698
- if: matrix.ux-packages-source == 'js-packages'
6799
name: Install UX JS packages with a JS package manager
68100
working-directory: test_apps/encore-app
69101
run: |
70102
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')
103+
for PACKAGE_DATA in $(cd ../..; pnpm ls -r --json --depth -1 | jq 'map(select(.private != true))' | jq -c '.[]'); do
104+
PACKAGE_NAME=$(echo $PACKAGE_DATA | jq -r '.name')
105+
PACKAGE_ABSOLUTE_PATH=$(echo $PACKAGE_DATA | jq -r '.path')
73106
PACKAGE_RELATIVE_PATH=$(realpath --relative-to=. "$PACKAGE_ABSOLUTE_PATH")
74107
PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL file:$PACKAGE_RELATIVE_PATH"
75108
done
109+
76110
echo "Installing packages: $PACKAGES_TO_INSTALL"
77-
pnpm add --save-dev $PACKAGES_TO_INSTALL
111+
npm add --save-dev $PACKAGES_TO_INSTALL
78112
79113
- name: Ensure UX packages are installed from "${{ env.EXPECTED_PATTERN }}"
80114
working-directory: test_apps/encore-app
@@ -97,8 +131,8 @@ jobs:
97131

98132
- name: Ensure project can be built in dev mode
99133
working-directory: test_apps/encore-app
100-
run: pnpm run dev
134+
run: npm run dev
101135

102136
- name: Ensure project can be built in prod mode
103137
working-directory: test_apps/encore-app
104-
run: pnpm run build
138+
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)