Skip to content

Commit a9ea07d

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

File tree

6 files changed

+43
-7281
lines changed

6 files changed

+43
-7281
lines changed

.github/workflows/app-tests.yaml

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,6 @@ jobs:
3636
- uses: actions/setup-node@v4
3737
with:
3838
node-version-file: '.nvmrc'
39-
cache: 'pnpm'
40-
cache-dependency-path: |
41-
package.json
42-
src/**/package.json
43-
test_apps/encore-app/pnpm-lock.yaml
44-
test_apps/encore-app/package.json
4539

4640
- uses: shivammathur/setup-php@v2
4741

@@ -60,35 +54,56 @@ jobs:
6054
working-directory: test_apps/encore-app
6155
dependency-versions: highest
6256

57+
- name: Manually replacing "workspace:*" references
58+
run: |
59+
# npm does not support "workspace:*" references, so we need to replace them with the actual package path
60+
for PACKAGE_DATA in $(pnpm ls -r --json --depth -1 | jq 'map(select(.private != true))' | jq -c '.[]'); do
61+
PACKAGE=$(echo $PACKAGE_DATA | jq -r '.name')
62+
PACKAGE_PATH=$(echo $PACKAGE_DATA | jq -r '.path')
63+
64+
echo "🔍 Searching for \"workspace:*\" references in $PACKAGE_PATH/package.json"
65+
66+
# Manually replace "workspace:" constraints with the actual package version, it ensure packages can be installed with npm
67+
jq -rc '[(.dependencies // {}) + (.devDependencies // {}) | to_entries[] | select(.value == "workspace:*") | .key][]' "$PACKAGE_PATH/package.json" | while read -r PACKAGE_FROM_WORKSPACE ; do
68+
echo "ℹ️ Found \"$PACKAGE_FROM_WORKSPACE\" with \"workspace:*\""
69+
70+
PACKAGE_FROM_WORKSPACE_PATH=$(pnpm ls --filter $PACKAGE_FROM_WORKSPACE --json --depth -1 | jq -r '.[].path')
71+
echo "ℹ️ The package \"$PACKAGE_FROM_WORKSPACE\" is located in \"$PACKAGE_FROM_WORKSPACE_PATH\" directory"
72+
73+
echo "⚒️ Replacing \"$PACKAGE_FROM_WORKSPACE\" with \"file:$PACKAGE_FROM_WORKSPACE_PATH\" in $PACKAGE_PATH/package.json"
74+
sed -i "s|\"$PACKAGE_FROM_WORKSPACE\": \"workspace:\*\"|\"$PACKAGE_FROM_WORKSPACE\": \"file:$PACKAGE_FROM_WORKSPACE_PATH\"|g" "$PACKAGE_PATH/package.json"
75+
done;
76+
done
77+
6378
- working-directory: test_apps/encore-app
64-
run: pnpm install --ignore-workspace
79+
run: npm install --install-links
6580

6681
- if: matrix.ux-packages-source == 'js-packages'
6782
name: Install UX JS packages with a JS package manager
6883
working-directory: test_apps/encore-app
6984
run: |
7085
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')
73-
PACKAGE_RELATIVE_PATH=$(realpath --relative-to=. "$PACKAGE_ABSOLUTE_PATH")
74-
PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL file:$PACKAGE_RELATIVE_PATH"
86+
for PACKAGE_DATA in $(pnpm ls -r --json --depth -1 | jq 'map(select(.private != true))' | jq -c '.[]'); do
87+
PACKAGE_PATH=$(echo $PACKAGE_DATA | jq -r '.path')
88+
PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL file:$(realpath --relative-to=. "$PACKAGE_PATH")"
7589
done
90+
7691
echo "Installing packages: $PACKAGES_TO_INSTALL"
77-
pnpm add --save-dev $PACKAGES_TO_INSTALL
92+
npm add --save-dev --install-links $PACKAGES_TO_INSTALL
7893
7994
- name: Ensure UX packages are installed from "${{ env.EXPECTED_PATTERN }}"
8095
working-directory: test_apps/encore-app
8196
run: |
82-
for PACKAGE in $(cat package.json | jq -c '(.dependencies // {}) + (.devDependencies // {}) | to_entries[] | select(.key | startswith("@symfony/ux-")) | {name: .key, version: .value}'); do
83-
PACKAGE_NAME=$(echo $PACKAGE | jq -r '.name')
84-
PACKAGE_VERSION=$(echo $PACKAGE | jq -r '.version')
97+
for PACKAGE_DATA in $(cat package.json | jq -c '(.dependencies // {}) + (.devDependencies // {}) | to_entries[] | select(.key | startswith("@symfony/ux-")) | {name: .key, version: .value}'); do
98+
PACKAGE=$(echo $PACKAGE_DATA | jq -r '.name')
99+
PACKAGE_VERSION=$(echo $PACKAGE_DATA | jq -r '.version')
85100
86-
echo -n "Checking $PACKAGE_NAME@$PACKAGE_VERSION..."
101+
echo -n "Checking $PACKAGE@$PACKAGE_VERSION..."
87102
if [[ $PACKAGE_VERSION == $EXPECTED_PATTERN* ]]; then
88-
echo " OK"
103+
echo " OK"
89104
else
90-
echo " KO"
91-
echo "The package version of $PACKAGE_NAME must starts with the pattern (e.g.: $EXPECTED_PATTERN), got $PACKAGE_VERSION instead."
105+
echo " KO"
106+
echo "ℹ️ The package version of $PACKAGE must starts with the pattern (e.g.: $EXPECTED_PATTERN), got $PACKAGE_VERSION instead."
92107
exit 1
93108
fi
94109
done;
@@ -97,8 +112,8 @@ jobs:
97112

98113
- name: Ensure project can be built in dev mode
99114
working-directory: test_apps/encore-app
100-
run: pnpm run dev
115+
run: npm run dev
101116

102117
- name: Ensure project can be built in prod mode
103118
working-directory: test_apps/encore-app
104-
run: pnpm run build
119+
run: npm run build

.github/workflows/code-quality.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ on:
66
- 'src/*/doc/**'
77
- 'src/**/*.md'
88
- 'ux.symfony.com/**'
9+
- '.github/workflows/app-tests.yaml'
910
pull_request:
1011
paths-ignore:
1112
- 'src/*/doc/**'
1213
- 'src/**/*.md'
1314
- 'ux.symfony.com/**'
15+
- '.github/workflows/app-tests.yaml'
1416

1517
concurrency:
1618
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}

.github/workflows/unit-tests.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ on:
1010
- 'src/*/doc/**'
1111
- 'src/**/*.md'
1212
- 'ux.symfony.com/**'
13+
- '.github/workflows/app-tests.yaml'
1314
pull_request:
1415
paths-ignore:
1516
- 'src/*/doc/**'
1617
- 'src/**/*.md'
1718
- 'ux.symfony.com/**'
19+
- '.github/workflows/app-tests.yaml'
1820

1921
concurrency:
2022
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}

.github/workflows/ux.symfony.com.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ on:
88
- '!src/*/doc/**'
99
- '!src/**/*.md'
1010
- '.github/**'
11+
- '!.github/workflows/app-tests.yaml'
1112
pull_request:
1213
paths:
1314
- 'ux.symfony.com/**'
1415
- 'src/*/**'
1516
- '!src/*/doc/**'
1617
- '!src/**/*.md'
1718
- '.github/**'
19+
- '!.github/workflows/app-tests.yaml'
1820

1921
jobs:
2022

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)