Skip to content

Commit ff26d19

Browse files
committed
Merge branch 'main' into feat-add-cdn-tests
2 parents 2f1b2a1 + c10bec8 commit ff26d19

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+2044
-458
lines changed

.changeset/mighty-cities-check.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@pagopa/monorepo-generator": patch
3+
---
4+
5+
Add PROD-IO overrides for DX_DeploymentEnvironment generator

.changeset/plain-ghosts-study.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@pagopa/dx-cli": minor
3+
---
4+
5+
Include environment generator in init command

.changeset/sparkly-steaks-punch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"make-artifact": major
3+
---
4+
5+
Extract make-artifact action form release-azure-appsvc workflow

.github/actions/build-workspace/action.yaml

Lines changed: 56 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -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 }}

.github/workflows/_release-bash-docusaurus-docs-website-azure.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ jobs:
2525
environment: "app-prod"
2626

2727
feed_docs_knowledge_base:
28-
# Only if a changeset PR is merged
29-
if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true && github.event.pull_request.title == 'Version Packages'
28+
# Only run after push to main with a "Version Packages" commit (changeset PR merge)
29+
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'Version Packages')
3030
name: Update MCP Server Knowledge Base
31-
environment: app-prod-cd
31+
environment: app-prod-ci
3232
needs: deploy_to_static_web_app
3333
runs-on: ubuntu-latest
3434
permissions:
@@ -54,4 +54,4 @@ jobs:
5454
run: |
5555
echo "Deploying documentation to knowledge base..."
5656
aws s3 sync ./${OUTPUT_DIR}/ s3://${BUCKET_NAME}/ --exclude "*" --include "*.md" --include "*.mdx" --delete
57-
aws bedrock-agent start-ingestion-job --knowledge-base-id ALSBZAYABZ --data-source-id 90H5AJLRJQ
57+
aws bedrock-agent start-ingestion-job --knowledge-base-id ALSBZAYABZ --data-source-id XITRER7DER

.github/workflows/_release-changesets-pull-request.yaml

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,12 @@ concurrency: ${{ github.workflow }}-${{ github.ref }}
99

1010
jobs:
1111
release:
12-
name: Release
13-
runs-on: ubuntu-latest
14-
environment: npm-prod-cd
1512
permissions:
1613
contents: write
1714
id-token: write
1815
pull-requests: write
19-
steps:
20-
- name: Checkout Repo
21-
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
22-
with:
23-
# https://github.com/actions/checkout/issues/1471#issuecomment-1771231294
24-
fetch-tags: "true"
25-
fetch-depth: 0
26-
27-
- name: Node Setup
28-
uses: pagopa/dx/.github/actions/node-setup@main
29-
30-
- name: Install dependencies
31-
run: pnpm install
32-
33-
# Needed to publish using trusted actions, must be >=11.5.1
34-
- name: Update npm
35-
run: npm install -g npm@11.7.0
36-
37-
- name: Create Release Pull Request or Publish to npm
38-
id: changesets
39-
uses: changesets/action@06245a4e0a36c064a573d4150030f5ec548e4fcc # v1.4.10
40-
with:
41-
version: pnpm run version
42-
publish: pnpm run release
43-
env:
44-
GITHUB_TOKEN: ${{ secrets.BOT_GH_TOKEN }}
45-
NPM_CONFIG_PROVENANCE: true
16+
uses: ./.github/workflows/release-v1.yaml
17+
with:
18+
environment: npm-prod-cd
19+
secrets:
20+
github-token: ${{ secrets.BOT_GH_TOKEN }}

.github/workflows/_validate-bash-workflows-naming.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ jobs:
5050
exit 0
5151
fi
5252
53+
# Skip validation if the workflow is named _validate-next-bundle.yaml
54+
if echo "$NEW_FILES" | grep -q '^.github/workflows/_validate-next-bundle\.yaml$'; then
55+
echo "Skipping validation for _validate-next-bundle.yaml"
56+
exit 0
57+
fi
58+
5359
# Define the naming pattern
5460
# Pattern is: [_]<scope>-<type>-<description>[-vN].yaml
5561
NAMING_PATTERN='^(_)?(cron|build|validate|release)-(docker|typescript|terraform|changesets|docusaurus|bash|go|azure|aws)-[a-z0-9-]+(-v[0-9]+)?\.yaml$'
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Integration test workflow to validate Next.js standalone builds
2+
# Action tested: "build-workspace", "make-artifact
3+
4+
on:
5+
workflow_dispatch:
6+
pull_request:
7+
types: [opened, synchronize]
8+
paths:
9+
- .github/workflows/_validate-next-bundle.yaml
10+
- .github/actions/build-workspace/action.yaml
11+
- ./actions/make-artifact/action.yaml
12+
13+
jobs:
14+
test-next-bundle:
15+
runs-on: ubuntu-latest
16+
17+
permissions:
18+
contents: read
19+
20+
strategy:
21+
matrix:
22+
package-manager: ["pnpm", "yarn"]
23+
nextjs-version: ["13", "14", "15", "16"]
24+
steps:
25+
- name: Build the project
26+
run: |
27+
echo "22.17.0" > .node-version
28+
echo '{ "name": "test", "devDependencies": { "turbo": "latest" } }' > package.json
29+
echo '{ "tasks": { "build": {} } }' > turbo.json
30+
corepack enable
31+
corepack use $PACKAGE_MANAGER@latest
32+
mkdir apps
33+
env:
34+
CI: false
35+
PACKAGE_MANAGER: ${{ matrix.package-manager }}
36+
37+
- name: Setup the pnpm workspace
38+
if: matrix.package-manager == 'pnpm'
39+
run: |
40+
pnpm config set --location=project --json packages '["apps/*"]'
41+
42+
- name: Setup the yarn workspace
43+
if: matrix.package-manager == 'yarn'
44+
run: |
45+
npm pkg set workspaces[]="apps/*"
46+
47+
- name: Scaffold Next.js app
48+
run: |
49+
"$PACKAGE_MANAGER" dlx create-next-app@$NEXTJS_VERSION "apps/my-app" \
50+
--ts --no-eslint --no-tailwind \
51+
--app --src-dir --import-alias "@/*" \
52+
--turbopack --no-react-compiler \
53+
--skip-install
54+
rm apps/my-app/next.config.*
55+
echo "module.exports = { output: 'standalone' };" > apps/my-app/next.config.js
56+
"$PACKAGE_MANAGER" install
57+
env:
58+
CI: false
59+
NEXTJS_VERSION: ${{ matrix.nextjs-version }}
60+
PACKAGE_MANAGER: ${{ matrix.package-manager }}
61+
62+
- name: Checkout repository
63+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
64+
with:
65+
fetch-tags: "true"
66+
fetch-depth: 0
67+
path: dx
68+
69+
- name: Build Package
70+
id: build-package
71+
uses: ./dx/.github/actions/build-workspace
72+
with:
73+
workspace_name: my-app
74+
75+
- name: Make artifact
76+
id: make-artifact
77+
uses: ./dx/actions/make-artifact
78+
with:
79+
package-manager: ${{ steps.build-package.outputs.package-manager }}
80+
workspace-name: my-app
81+
workspace-path: ${{ steps.build-package.outputs.workspace-path }}
82+
83+
- name: Test Next.js bundle
84+
env:
85+
ARTIFACT_PATH: ${{ steps.make-artifact.outputs.artifact-path }}
86+
run: |
87+
temp_dir=$(mktemp -d)
88+
unzip -d "$temp_dir" -q "$ARTIFACT_PATH"
89+
90+
PORT=$(($RANDOM+1024)) node "$temp_dir/server.js" &
91+
sleep 2
92+
93+
pid=$!
94+
if ! kill -0 $pid 2>/dev/null; then
95+
echo "Next.js app failed to start"
96+
exit 1
97+
fi
98+
echo "Next.js app started successfully with PID $pid"
99+
kill $pid
100+
101+
exit 0

.github/workflows/release-azure-appsvc-v1.yaml

Lines changed: 5 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -99,43 +99,11 @@ jobs:
9999
- name: Make artifact
100100
if: ${{ steps.check-artifact.outputs.exists != 'true' }}
101101
id: make-artifact
102-
env:
103-
PACKAGE_MANAGER: ${{ steps.build-package.outputs.package-manager }}
104-
WORKSPACE_PATH: ${{ steps.build-package.outputs.workspace-path }}
105-
working-directory: ${{ steps.build-package.outputs.workspace-path }}
106-
run: |
107-
if grep -rq --include='next.config.*' 'output: "standalone"' .; then
108-
echo "::debug::The workspace contains a Next.js standalone app"
109-
mv .next/static .next/standalone/"$WORKSPACE_PATH"/.next
110-
mv public .next/standalone/"$WORKSPACE_PATH"
111-
cd .next/standalone/"$WORKSPACE_PATH"
112-
zip -r "$BUNDLE_NAME".zip .
113-
echo "artifact-path=$(realpath "$BUNDLE_NAME.zip")" >> "$GITHUB_OUTPUT"
114-
exit 0
115-
fi
116-
117-
if [ "$PACKAGE_MANAGER" = "pnpm" ]; then
118-
echo "::debug::The workspace uses pnpm"
119-
# we use --legacy to avoid hardlinking workspace packages
120-
# https://github.com/orgs/pnpm/discussions/9015
121-
pnpm --filter $WORKSPACE_NAME deploy --legacy --prod bundle
122-
cd bundle && zip -yr $BUNDLE_NAME.zip .
123-
echo "artifact-path=$(realpath $BUNDLE_NAME.zip)" >> $GITHUB_OUTPUT
124-
exit 0
125-
fi
126-
127-
if [ "$PACKAGE_MANAGER" = "yarn" ]; then
128-
echo "::debug::The workspace uses yarn"
129-
yarn config set nodeLinker node-modules
130-
yarn config set nmHoistingLimits workspaces
131-
yarn workspaces focus --production
132-
zip -r $BUNDLE_NAME.zip .
133-
echo "artifact-path=$(realpath $BUNDLE_NAME.zip)" >> $GITHUB_OUTPUT
134-
exit 0
135-
fi
136-
137-
echo "::error::Unsupported package manager: $PACKAGE_MANAGER"
138-
exit 1
102+
uses: pagopa/dx/actions/make-artifact@main
103+
with:
104+
package-manager: ${{ steps.build-package.outputs.package-manager }}
105+
workspace-name: ${{ env.WORKSPACE_NAME }}
106+
workspace-path: ${{ steps.build-package.outputs.workspace-path }}
139107

140108
- name: Upload Artifact
141109
if: ${{ steps.check-artifact.outputs.exists != 'true' }}

0 commit comments

Comments
 (0)