@@ -21,33 +21,77 @@ runs:
2121 id : node-setup
2222 uses : pagopa/dx/.github/actions/node-setup@main
2323
24+ - name : Detect build tool
25+ id : detect-build-tool
26+ shell : bash
27+ run : |
28+ if [ -f "nx.json" ]; then
29+ echo "build-tool=nx" >> $GITHUB_OUTPUT
30+ else
31+ echo "build-tool=turbo" >> $GITHUB_OUTPUT
32+ fi
33+
34+ - name : Get Workspace path
35+ id : get-workspace-path
36+ shell : bash
37+ run : |
38+ if [ "$BUILD_TOOL" == "turbo" ]; then
39+ WORKSPACE_PATH=$(npx --yes turbo ls --output=json | jq -sr --arg NAME "$WORKSPACE_NAME" '.[].packages.items[] | select(.name == $NAME).path')
40+ else
41+ WORKSPACE_PATH=$(npx --yes nx show project "$WORKSPACE_NAME" --json | jq -r .root)
42+ fi
43+ echo "workspace-path=$WORKSPACE_PATH" >> $GITHUB_OUTPUT
44+ env :
45+ WORKSPACE_NAME : ${{ inputs.workspace_name }}
46+ BUILD_TOOL : ${{ steps.detect-build-tool.outputs.build-tool }}
47+
48+ # If certain conditions are met, use flat node_modules structure
49+ - name : Enable compatibility mode
50+ id : compatibility-mode
51+ shell : bash
52+ run : |
53+ if [ "$PACKAGE_MANAGER" = "yarn" ]; then
54+ echo "enabled=true" >> $GITHUB_OUTPUT
55+ elif grep -rq --include='next.config.*' 'standalone' "$WORKSPACE_PATH"; then
56+ echo "enabled=true" >> $GITHUB_OUTPUT
57+ else
58+ echo "enabled=false" >> $GITHUB_OUTPUT
59+ fi
60+ env :
61+ WORKSPACE_PATH : ${{ steps.get-workspace-path.outputs.workspace-path }}
62+ PACKAGE_MANAGER : ${{ steps.node-setup.outputs.package-manager }}
63+
2464 - name : Install dependencies (pnpm)
2565 if : ${{ steps.node-setup.outputs.package-manager == 'pnpm' }}
2666 shell : bash
27- run : pnpm --filter "$WORKSPACE_NAME..." install
67+ run : |
68+ if [ "$COMPABILITY_MODE" = "true" ]; then
69+ pnpm config set --location=project nodeLinker hoisted
70+ rm -rf node_modules
71+ pnpm -r exec rm -rf node_modules
72+ fi
73+ pnpm --filter "$WORKSPACE_NAME..." install
2874 env :
75+ COMPABILITY_MODE : ${{ steps.compatibility-mode.outputs.enabled }}
2976 WORKSPACE_NAME : ${{ inputs.workspace_name }}
3077
3178 - name : Install dependencies (yarn)
3279 if : ${{ steps.node-setup.outputs.package-manager == 'yarn' }}
3380 shell : bash
34- run : yarn install --immutable
81+ run : |
82+ if [ "$COMPABILITY_MODE" = "true" ]; then
83+ yarn config set nodeLinker node-modules
84+ yarn config set nmHoistingLimits workspaces
85+ fi
86+ yarn install --immutable
87+ env :
88+ COMPABILITY_MODE : ${{ steps.compatibility-mode.outputs.enabled }}
3589
3690 - name : Install dependencies (npm)
3791 if : ${{ steps.node-setup.outputs.package-manager == 'npm' }}
3892 shell : bash
3993 run : npm ci
4094
41- - name : Detect build tool
42- id : detect-build-tool
43- shell : bash
44- run : |
45- if [ -f "nx.json" ]; then
46- echo "build-tool=nx" >> $GITHUB_OUTPUT
47- else
48- echo "build-tool=turbo" >> $GITHUB_OUTPUT
49- fi
50-
5195 - name : Build (turbo)
5296 if : ${{ steps.detect-build-tool.outputs.build-tool == 'turbo' }}
5397 shell : bash
@@ -61,17 +105,3 @@ runs:
61105 run : npx nx run $WORKSPACE_NAME:build
62106 env :
63107 WORKSPACE_NAME : ${{ inputs.workspace_name }}
64-
65- - name : Get Workspace path
66- id : get-workspace-path
67- shell : bash
68- run : |
69- if [ "$BUILD_TOOL" == "turbo" ]; then
70- WORKSPACE_PATH=$(npx turbo ls --output=json | jq -sr --arg NAME "$WORKSPACE_NAME" '.[].packages.items[] | select(.name == $NAME).path')
71- else
72- WORKSPACE_PATH=$(npx nx show project "$WORKSPACE_NAME" --json | jq -r .root)
73- fi
74- echo "workspace-path=$WORKSPACE_PATH" >> $GITHUB_OUTPUT
75- env :
76- WORKSPACE_NAME : ${{ inputs.workspace_name }}
77- BUILD_TOOL : ${{ steps.detect-build-tool.outputs.build-tool }}
0 commit comments