-
Notifications
You must be signed in to change notification settings - Fork 80
224 lines (204 loc) · 7.27 KB
/
Copy pathbuild-deploy-test.yml
File metadata and controls
224 lines (204 loc) · 7.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
name: Build, Deploy, and Test All Examples
on:
workflow_dispatch:
inputs:
environment:
description: "Deployment environment (dev, staging, prod)"
required: true
default: "prod"
type: choice
options:
- dev
- staging
- prod
skip_cache:
description: "Skip build cache and force rebuild all packages"
required: false
default: true
type: boolean
plugin_version:
description: "Zephyr plugin version to upgrade to (default: next)"
required: false
default: "next"
type: string
repository_dispatch:
types: [build-deploy-test]
pull_request:
branches:
- main
paths:
- "bundlers/**"
- "module-federation/**"
- "frameworks/**"
- "server/**"
- "build-systems/**"
- "scripts/**"
- ".github/workflows/**"
- ".github/actions/**"
push:
branches:
- main
paths:
- "bundlers/**"
- "module-federation/**"
- "frameworks/**"
- "server/**"
- "build-systems/**"
- "scripts/**"
- ".github/workflows/**"
- ".github/actions/**"
env:
NODE_VERSION: "24"
ZE_FAIL_BUILD: true
ZE_SECRET_TOKEN: |
${{
github.event.inputs.environment == 'dev' && secrets.ZE_SECRET_TOKEN_DEV ||
github.event.inputs.environment == 'staging' && secrets.ZE_SECRET_TOKEN_STAGING ||
secrets.ZE_SECRET_TOKEN_PROD
}}
ZE_API_GATE: |
${{
github.event.inputs.environment == 'dev' && 'https://zeapi.zephyrcloudapp.dev' ||
github.event.inputs.environment == 'staging' && 'https://zeapi.zephyrcloudapp.xyz' ||
'https://zeapi.zephyrcloud.app'
}}
ZE_API: |
${{
github.event.inputs.environment == 'dev' && 'https://api-dev.zephyr-cloud.io' ||
github.event.inputs.environment == 'staging' && 'https://zephyr-api-prerelease-1a6b535d0499.herokuapp.com' ||
'https://api.zephyr-cloud.io'
}}
PNPM_INSTALL_FLAGS: ${{ (github.event_name == 'workflow_dispatch' || github.event_name == 'repository_dispatch') && '--config.minimumReleaseAge=0 --no-frozen-lockfile' || '' }}
jobs:
build-deploy-test:
name: Build, Deploy, and Test All Examples
runs-on: depot-ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: pnpm/action-setup@v4
with:
run_install: false
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: "https://registry.npmjs.org"
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
with:
path: ${{ env.STORE_PATH }}
key: pnpm-store-${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
pnpm-store-${{ runner.os }}-
- name: Install scripts dependencies
run: |
cd scripts
pnpm install --prefer-offline ${PNPM_INSTALL_FLAGS}
- name: Upgrade Zephyr plugins
if: github.event_name != 'pull_request' && github.event_name != 'push'
run: |
cd scripts
if [ -n "${{ github.event.inputs.plugin_version }}" ]; then
echo "Upgrading plugins to version: ${{ github.event.inputs.plugin_version }}"
pnpm upgrade-plugins --version=${{ github.event.inputs.plugin_version }}
elif [ -n "${{ github.event.client_payload.plugin_version }}" ]; then
echo "Upgrading plugins to version: ${{ github.event.client_payload.plugin_version }}"
pnpm upgrade-plugins --version=${{ github.event.client_payload.plugin_version }}
else
echo "Upgrading plugins to latest (next)"
pnpm upgrade-plugins
fi
- name: Install example dependencies
run: pnpm install --prefer-offline ${PNPM_INSTALL_FLAGS}
- name: Install standalone example dependencies
run: |
standalone=(
build-systems/nx-rspack-mf
build-systems/turborepo-rspack-mf
module-federation/airbnb-clone
module-federation/react-vite-rspack-webpack
)
for example in "${standalone[@]}"; do
if [ -f "${example}/package.json" ]; then
echo "Installing dependencies for ${example}"
cd "$example"
pnpm install --prefer-offline ${PNPM_INSTALL_FLAGS}
cd "$GITHUB_WORKSPACE"
fi
done
- name: Patch Angular Rspack compiler dependencies
run: |
find node_modules/.pnpm \
-path "*/@nx/angular-rspack-compiler/patch/patch-angular-build.js" \
-print \
-exec node {} \;
- name: Clean zephyr cache before build
run: |
echo "Cleaning $HOME/.zephyr directory..."
if [ -d "$HOME/.zephyr" ]; then
echo "Found existing .zephyr directory, checking contents:"
ls -lah "$HOME/.zephyr/" || true
echo "Removing .zephyr directory..."
rm -rf "$HOME/.zephyr"
fi
echo "Creating fresh .zephyr directory..."
mkdir -p "$HOME/.zephyr"
- name: Build all examples
run: |
cd scripts
if [ "${{ github.event.inputs.skip_cache }}" == "true" ] || [ "${{ github.event.client_payload.skip_cache }}" == "true" ]; then
echo "Building all examples with --skip-cache flag"
pnpm build-packages --skip-cache
else
echo "Building all examples with cache enabled"
pnpm build-packages
fi
env:
NODE_ENV: production
ZE_SECRET_TOKEN: ${{ env.ZE_SECRET_TOKEN }}
ZE_API_GATE: ${{ env.ZE_API_GATE }}
ZE_API: ${{ env.ZE_API }}
- name: Zephyr deploy summary
if: github.event_name == 'pull_request'
uses: ZephyrCloudIO/zephyr-preview-environment-action@main
id: zephyr-summary
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload build logs
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
if: always()
with:
name: build-logs
path: scripts/tmp/build/
retention-days: 3
- name: Wait for deployments to be ready
run: |
echo "Waiting 60 seconds for all deployments to propagate..."
sleep 60
- name: Install Playwright browsers
timeout-minutes: 5
run: |
cd scripts
npx playwright install chromium
- name: Run deployment validation tests
run: |
cd scripts
pnpm test
env:
CI: true
ZE_SECRET_TOKEN: ${{ env.ZE_SECRET_TOKEN }}
ZE_API_GATE: ${{ env.ZE_API_GATE }}
ZE_API: ${{ env.ZE_API }}
- name: Upload test results
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
if: always()
with:
name: test-results
path: |
scripts/test-results/
scripts/playwright-report/
retention-days: 7